- From: Ravin Shah <Ravin.Shah@morganstanley.com>
- Date: Fri, 2 Nov 2001 12:51:45 -0500 (EST)
- To: xmlschema-dev@w3.org
I am trying to validate some XML files and have come across many
problems. Right now, I just want to get a sample program working that
validates. I would appreciate any kind of help.
I just want to validate an XML file against an XSD file. I have taken a
very simple example but I get these results from the parser (The xml and
xsd files are shown below):
Error :order.xml:3:121: Schema error: ComplexType 'order': Invalid child
'element' in the complex type.
Error :order.xml:3:121: Schema error: ComplexType 'shipAddress': Invalid
child 'element' in the complex type.
Error :order.xml:3:121: Schema error: ComplexType 'cdItem': Invalid
child 'element' in the complex type.
Error :order.xml:3:121: Schema error: ComplexType 'cdItems': Invalid
child 'element' in the complex type.
Error :order.xml:3:121: Element type "shipOrder" must be declared.
Error :order.xml:4:11: Element type "shipTo" must be declared.
Error :order.xml:5:11: Element type "name" must be declared.
Error :order.xml:6:13: Element type "street" must be declared.
Error :order.xml:7:14: Element type "address" must be declared.
Error :order.xml:8:14: Element type "country" must be declared.
Error :order.xml:10:10: Element type "items" must be declared.
Error :order.xml:11:11: Element type "item" must be declared.
Error :order.xml:12:14: Element type "title" must be declared.
Error :order.xml:13:17: Element type "quantity" must be declared.
Error :order.xml:14:14: Element type "price" must be declared.
Error :order.xml:16:11: Element type "item" must be declared.
Error :order.xml:17:14: Element type "title" must be declared.
Error :order.xml:18:17: Element type "quantity" must be declared.
Error :order.xml:19:14: Element type "price" must be declared.
Here is my xml file:
<?xml version="1.0" encoding="UTF-8"?>
<shipOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="AnotherTestSpace order_schema.xsd">
<shipTo>
<name>Tove Svendson</name>
<street>Ragnhildvei 2</street>
<address>4000 Stavanger</address>
<country>Norway</country>
</shipTo>
<items>
<item>
<title>Empire Burlesque</title>
<quantity>1</quantity>
<price>10.90</price>
</item>
<item>
<title>Hide your heart</title>
<quantity>1</quantity>
<price>9.90</price>
</item>
</items>
</shipOrder>
Here is my xsd file:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="AnotherTestSpace">
<xsd:element name="shipOrder" type="order"/>
<xsd:complexType name="shipAddress">
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="street" type="xsd:string"/>
<xsd:element name="address" type="xsd:string"/>
<xsd:element name="country" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="cdItem">
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="quantity" type="xsd:positiveInteger"/>
<xsd:element name="price" type="xsd:decimal"/>
</xsd:complexType>
<xsd:complexType name="cdItems">
<xsd:element name="item" type="cdItem"/>
</xsd:complexType>
<xsd:complexType name="order">
<xsd:element name="shipTo" type="shipAddress"/>
<xsd:element name="items" type="cdItems"/>
</xsd:complexType>
</xsd:schema>
Received on Saturday, 3 November 2001 06:36:39 UTC