473,378 Members | 1,617 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

cvc-complex-type.2.4.a: Invalid content was found

I must be going blind or dumb, because for the life of me I cannot see why I would get this error:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'config'. One of '{config}' is expected.

With the following files:

XSD:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <xs:schema
  3.     targetNamespace="http://tempuri.org/Page"
  4.     xmlns="http://tempuri.org/Page"
  5.     xmlns:xs="http://www.w3.org/2001/XMLSchema">
  6.  
  7.     <xs:element name="template">
  8.         <xs:complexType>
  9.             <xs:sequence>
  10.                 <xs:element name="config" type="configuration" minOccurs="1" maxOccurs="1" />
  11.             </xs:sequence>
  12.         </xs:complexType>
  13.     </xs:element>
  14.  
  15.     <xs:complexType name="configuration">
  16.         <xs:sequence>
  17.             <xs:element name="root" type="xs:string" minOccurs="1" maxOccurs="1" />
  18.         </xs:sequence>
  19.     </xs:complexType>
  20.  
  21. </xs:schema>
  22.  
XML:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <template
  3.     xmlns="http://tempuri.org/Page"
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5.     xsi:schemaLocation="http://tempuri.org/Page ../template.xsd">
  6.    <config>
  7.       <root>somevalue</root>
  8.    </config>
  9.  
  10. </template>
  11.  
Eclipse seems to be okay with the file reference, as the intellisense does correctly give me the tag names as expected, allows me to enter the data then gives me this error.

Any ideas?

Regards,
Rob.
Mar 12 '11 #1
2 28656
Okay,

I appear to have solved the problem, though I don't understand it. I fed the same setup into a different XML editor, and its intellisense did something I did not expect. It added a BLANK XML namespace to the <config> tag:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <template
  3.     xmlns="http://tempuri.org/Page"
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5.     xsi:schemaLocation="http://tempuri.org/Page ../template.xsd">
  6.    <config xmlns="">
  7.       <root>somevalue</root>
  8.    </config>
  9.  
  10. </template>
  11.  
I could not understand why, when the page has already been assigned a default namespace. Tried it back in Eclipse and it worked. The obvious next thing to do was to remove the default namespace:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <template
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.     xsi:schemaLocation="http://tempuri.org/Page ../template.xsd">
  5.    <config>
  6.       <root>somevalue</root>
  7.    </config>
  8.  
  9. </template>
  10.  
This now works correctly, although Eclipse throws up warnings about no namespace for the document being declared (thankfully you can turn those off).

It appears that specifying a default xmlns attribute at the root of the document is mutually exclusive with using the xsi:schemaLocation approach. I was puzzled by this as I have had it work when the XML and XSD are in the same location:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <template xmlns="http://tempuri.org/Page">
  3.    <config>
  4.       <root>somevalue</root>
  5.    </config>
  6. </template>
  7.  
As long as the two files are in the same physical location, all the XML editors I have used correctly identify and validate the schema. As soon as the files are in different locations, I seem to need the xsi:schemaLocation method, which then causes conflicts with the default namespace attribute.

If anybody can shed any light on what is going on here, it would be appreciated.

Regards,
Rob.
Mar 20 '11 #2
you should put "elementFormDefault='qualified' " in your xml schema. For more information, you can search for "elementFormDefault". I am poor at English so I cannot interpret the document for you. Good luck. I am trapped in this too.
Apr 16 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: anguo | last post by:
hi, everyone. i use mysql server version: 3.23.33. when i insert one line in a table, it can insert normaly. but then it display : null discard 9/udp sink null systat ...
0
by: Thomas Scheffler | last post by:
Hi, I use the Xerces SAXParser to read my documents in Java. For that I wrote an EntityResolver so that the parse can use a schema to validate them. Now that is the problem. The parser does...
0
by: Anand | last post by:
Hi all, I have an XML which comes through a HTTP request. I want to validate that XML with a DTD in the local machine. That XML does not have a DOCTYPE element by itself. Can someone tell me how...
1
by: Senthilvel Samatharman | last post by:
I am just curious about the case 3 in the follwouing program. I understand that case 1 is the right way to overload, while Case 2 is erroneous. But i do think that the implementation of operator...
3
by: dfielder | last post by:
I'm using the latest version of Xerces-J and parsing an XML file using the 'org.apache.xerces.parsers.SAXParser' parser. The problem I have is that a value such as 'file:///c:/#test#.jpg' is...
8
by: Dennis Gearon | last post by:
Is it possible to write functions for PL/C that have variable argument lists? I.E. UPPER( arg ) UPPER( arg, encoding_list ) LOWER( arg ) LOWER( arg, encoding_list ) SUBSTR( arg, arg, arg )
6
by: Tim Edwards | last post by:
Currently I'm running PostgreSQL 7.2.3 and having a problem sorting. I've got two colums of data, one Int4 one Varchar. When I sort ASC on the varchar I get some strange results. Here a section...
3
by: chrisvc | last post by:
I have an ASP.NET application that creates 4 threads in the Application OnStart event. Each thread is stored in the Application object collection. This code works perfectly on my dev machine,...
2
by: Marcin Cenkier | last post by:
Hi, I want to validate a DOM document, and if I build DOM from a stream using documentBuilder.parse() validation using validator.validate(DOMSource) works, but if I create the same document...
2
by: sk | last post by:
http://java.sun.com/developer/technicalArticles/xml/validationxpath/index.html I am following this sample and trying to learn how to validate xml document with the schema I am getting the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.