Validation problem csvc-complex-type.2.4.a Invalid content - But element is in the list!
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 3
- Joined: Mon May 21, 2012 4:19 pm
Validation problem csvc-complex-type.2.4.a Invalid content - But element is in the list!
Hi all,
I'm a firsttimer with writing XSD's and now I've hit a validation error which I cannot seem to resolve. Hope one of you could help me out.
XML I want to validate:
Schema:
I get the following error:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'object_id'. One of '{object_id, description, level}' is expected. which I found odd because object_id is present in the list, why isn't it recognised?
Thanks in advance for any help.
I'm a firsttimer with writing XSD's and now I've hit a validation error which I cannot seem to resolve. Hope one of you could help me out.
XML I want to validate:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<DOStreetLightList xmlns="http://munisense.com/webservices/v1/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://munisense.com/webservices/v1/ muniws.xsd">
<DOStreetLight id="12">
<object_id value="2334">32ef:8903:328df</object_id>
<description error="434" />
<level error="434" />
</DOStreetLight>
<DOStreetLight id="12">
<object_id value="23214">234:234:as23</object_id>
<level error="12" />
</DOStreetLight>
</DOStreetLightList>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:muniws="http://munisense.com/webservices/v1/"
targetNamespace="http://munisense.com/webservices/v1/">
<xs:element name="DOStreetLightList">
<xs:complexType>
<xs:sequence>
<xs:element ref="muniws:DOStreetLight" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="DOStreetLight">
<xs:complexType>
<xs:all>
<xs:element name="object_id" type="muniws:DOProperty" minOccurs="0" />
<xs:element name="description" type="muniws:DOProperty" minOccurs="0" />
<xs:element name="level" type="muniws:DOProperty" minOccurs="0" />
</xs:all>
<xs:attribute name="id" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:complexType name="DOProperty">
<xs:attribute name="error" use="optional" type="xs:string" />
<xs:attribute name="value" use="optional" type="xs:string" />
</xs:complexType>
</xs:schema>
cvc-complex-type.2.4.a: Invalid content was found starting with element 'object_id'. One of '{object_id, description, level}' is expected. which I found odd because object_id is present in the list, why isn't it recognised?
Thanks in advance for any help.
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Validation problem csvc-complex-type.2.4.a Invalid content - But element is in the list!
Hello,
The problem is that your schema hides (localizes) the namespaces (by default), but your XML instance is defined as if they are exposed.
If you find these concepts confusing, there is an explanation and a straightforward example here:
http://www.xfront.com/HideVersusExpose.html
In short, what you have to do to make this work correctly in its current form, is expose the namespaces in the schema. In practice that means you should add the attribute: elementFormDefault="qualified" to the root element of your schema.
Another possibility is to leave the schema as it is and adjust the XML instance to match the current schema. For that you have to bring object_id, description and level in "no namespace". That means you should specify xmlns="" for each of them.
Regards,
Adrian
The problem is that your schema hides (localizes) the namespaces (by default), but your XML instance is defined as if they are exposed.
If you find these concepts confusing, there is an explanation and a straightforward example here:
http://www.xfront.com/HideVersusExpose.html
In short, what you have to do to make this work correctly in its current form, is expose the namespaces in the schema. In practice that means you should add the attribute: elementFormDefault="qualified" to the root element of your schema.
Another possibility is to leave the schema as it is and adjust the XML instance to match the current schema. For that you have to bring object_id, description and level in "no namespace". That means you should specify xmlns="" for each of them.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 9423
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Validation problem csvc-complex-type.2.4.a Invalid content - But element is in the list!
Hi,
In your XML Schema these three elements are declared locally (inside the xs:all):
According to the XML Schema specification, this means that they are declared to be in "no namespace" instead of the XML Schema's target namespace.
In your XML instance you seem to expect that the "object_id" element should belong to the namespace http://munisense.com/webservices/v1/.
You have several possible fixes:
1) On the xs:schema root element add this additional attribute elementFormDefault="qualified". This way, every locally declared element will be considered to pertain to the schema's target namespace.
2) When declaring the local elements add form="qualified" to them like:
form="qualified".
3) Instead of declaring the elements locally, declare them globally.
Usually XML Schema editors use the first option because there are seldom cases in which someone wants to declare a local element in "no namespace".
Please see this part of the specification:
http://www.w3.org/TR/xmlschema-0/#UnqualLocals
Regards,
Radu
In your XML Schema these three elements are declared locally (inside the xs:all):
Code: Select all
<xs:element name="object_id" type="muniws:DOProperty" minOccurs="0"/>
<xs:element name="description" type="muniws:DOProperty" minOccurs="0" />
<xs:element name="level" type="muniws:DOProperty" minOccurs="0" />
In your XML instance you seem to expect that the "object_id" element should belong to the namespace http://munisense.com/webservices/v1/.
You have several possible fixes:
1) On the xs:schema root element add this additional attribute elementFormDefault="qualified". This way, every locally declared element will be considered to pertain to the schema's target namespace.
2) When declaring the local elements add form="qualified" to them like:
Code: Select all
<xs:element name="object_id" type="muniws:DOProperty" minOccurs="0" form="qualified"/>
3) Instead of declaring the elements locally, declare them globally.
Usually XML Schema editors use the first option because there are seldom cases in which someone wants to declare a local element in "no namespace".
Please see this part of the specification:
http://www.w3.org/TR/xmlschema-0/#UnqualLocals
Indeed the error given by the Xerces validator is veru cryptic, we'll see if we can improve on this.Qualification of local elements and attributes can be globally specified by a pair of attributes, elementFormDefault and attributeFormDefault, on the schema element, or can be specified separately for each local declaration using the form attribute. All such attributes' values may each be set to unqualified or qualified, to indicate whether or not locally declared elements and attributes must be unqualified.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 3
- Joined: Mon May 21, 2012 4:19 pm
Re: Validation problem csvc-complex-type.2.4.a Invalid content - But element is in the list!
Thanks both for the fast reaction! I've added elementFormDefault qualified and the error is gone and replaced by:
cvc-complex-type.2.1: Element 'object_id' must have no character or element information item [children], because the type's content type is empty.
This error disappears when I leave the object ID empty instead.
Seems that
forces object_id to be empty but that is not the desired behavior.
Any idea's? Thanks!
cvc-complex-type.2.1: Element 'object_id' must have no character or element information item [children], because the type's content type is empty.
This error disappears when I leave the object ID empty instead.
Code: Select all
<object_id value="2334"/>
Code: Select all
<xs:element name="object_id" type="muniws:DOProperty" minOccurs="0" />
Any idea's? Thanks!
-
- Posts: 3
- Joined: Mon May 21, 2012 4:19 pm
Re: Validation problem csvc-complex-type.2.4.a Invalid content - But element is in the list!
Update:
Probleem in post hierboven inmiddels opgelost door het te wrappen in een
Ik heb het werkend nu, cheers 
Probleem in post hierboven inmiddels opgelost door het te wrappen in een
Code: Select all
<xs:complexType name="DOProperty" >
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="error" use="optional" type="xs:string" />
<xs:attribute name="value" use="optional" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>

Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service