whats wrong with my XSD file
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 1
- Joined: Sat Jan 17, 2015 2:09 pm
whats wrong with my XSD file
I get the follwing error
> The element 'order' in namespace 'OrdersSchema' has invalid child
> element 'deliveryAddress'. List of possible elements expected:
> 'deliveryAddress' in namespace 'OrdersSchema'.
dunno if i understand it correct but isn't deliveryaddress a child of order ? so why is it complaining that its not expecting it ? or am i wrong in my think path
This is the XML file ? This file cant be changed i need to construct my XSD to validate this xml
> The element 'order' in namespace 'OrdersSchema' has invalid child
> element 'deliveryAddress'. List of possible elements expected:
> 'deliveryAddress' in namespace 'OrdersSchema'.
dunno if i understand it correct but isn't deliveryaddress a child of order ? so why is it complaining that its not expecting it ? or am i wrong in my think path
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:os="OrdersSchema"
targetNamespace="OrdersSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<element name="orders">
<complexType >
<sequence>
<element name="order" maxOccurs="unbounded">
<complexType>
<sequence>
<element name="deliveryAddress">
<complexType>
<sequence>
<element name='line1' type='os:lineType'/>
<element name='line2' type='os:lineType'/>
<element name='line3' type='os:lineType'/>
<element name='line4' type='os:lineType' minOccurs='0'/>
</sequence>
<attribute name="orderId" type="string" use="required" >
</attribute>
</complexType>
<unique name="uniqueOrderIdPerOrder">
<selector xpath="os:order"/>
<field xpath="orderId"/>
</unique>
</element>
<element name='items'>
<complexType>
<sequence>
<element name="item">
<complexType>
<attribute name='productId' type='os:productIdType'/>
<attribute name='quantity'>
<simpleType>
<restriction base='positiveInteger'>
</restriction>
</simpleType>
</attribute>
</complexType>
</element>
</sequence>
</complexType>
</element>
<element name='note' minOccurs='0' type='string'/>
</sequence>
<attribute name="orderId" type="string" use="required" >
</attribute>
<attribute name="type" type="os:typeType" use="required"/>
</complexType>
</element>
</sequence>
</complexType>
</element>
<simpleType name='lineType'>
<restriction base='string'>
<minLength value='1'/>
</restriction>
</simpleType>
<simpleType name='typeType'>
<restriction base='string'>
<enumeration value='standard'/>
<enumeration value='express'/>
</restriction>
</simpleType>
<simpleType name='productIdType'>
<restriction base='string'>
<pattern value='(?i)p[-\s](150|1[0-4][0-9]|[[1-9][0-9]|[1-9])\.[a-z][a-z][a-z][a-z][a-z][a-z]'/>
<pattern value='A...+[$XYZ]\b'/>
</restriction>
</simpleType>
</schema>
This is the XML file ? This file cant be changed i need to construct my XSD to validate this xml
Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<os:orders xmlns:os="OrdersSchema">
<os:order orderId="ord0001" type="standard">
<deliveryAddress>
<line1>5, Elmstreet</line1>
<line2>90210 Beverly Hills</line2>
<line3>California</line3>
</deliveryAddress>
<items>
<item productId="P 150.aabaac" quantity="5" />
</items>
<note>Deliver after 5 pm.</note>
</os:order>
<os:order orderId="ord0003" type="express">
<deliveryAddress>
<line1>Voskenslaan 30</line1>
<line2>BE9000 Gent</line2>
<line3>Oost-Vlaanderen</line3>
<line4>Belgium</line4>
</deliveryAddress>
<items>
<item productId="A3546sdfsdf6546sdf654Z" quantity="10" />
<item productId="p 149.SLKDOZ" quantity="5" />
<item productId="P 100.xcvZEr" quantity="15" />
</items>
</os:order>
<os:order orderId="ord0002" type="express">
<deliveryAddress>
<line1>Voskenslaan 32</line1>
<line2>BE9000 Gent</line2>
<line3>Oost-Vlaanderen</line3>
<line4>Belgium</line4>
</deliveryAddress>
<items>
<item productId="P-99.ruioze" quantity="15" />
<item productId="A123qze46548X" quantity="50" />
<item productId="P 1.sqmfze" quantity="1" />
<item productId="AoknY" quantity="20" />
</items>
<note>This is <b>very urgent</b> !</note>
</os:order>
</os:orders>
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: whats wrong with my XSD file
Hi,
This is a namespace problem.
In your XML, 'deliveryAddress' is in "no namespace" (or "null namespace", if you prefer) because you have not specified the default namespace for your XML (or individual elements).
Since your XML schema only accepts 'deliveryAddress' from the "OrdersSchema" namespace, the validator raises the error you mentioned.
A quick and dirty fix is to declare the default namespace on the root of the XML:
However, if you're going to do this, you might as well remove the 'os' namespace prefix everywhere and just work with the default namespace. e.g.
The alternative is to use the declared namespace prefix, "os", everywhere. e.g.
Regards,
Adrian
This is a namespace problem.
In your XML, 'deliveryAddress' is in "no namespace" (or "null namespace", if you prefer) because you have not specified the default namespace for your XML (or individual elements).
Since your XML schema only accepts 'deliveryAddress' from the "OrdersSchema" namespace, the validator raises the error you mentioned.
A quick and dirty fix is to declare the default namespace on the root of the XML:
Code: Select all
<os:orders xmlns:os="OrdersSchema" xmlns="OrdersSchema">
Code: Select all
<orders xmlns="OrdersSchema">
<order orderId="ord0001" type="standard">
...
Code: Select all
<os:orders xmlns:os="OrdersSchema">
<os:order orderId="ord0001" type="standard">
<os:deliveryAddress>
...
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
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