Hi Eric,
You have a problem in your xml file. The 'Cube' element which is a child of envelope is bound to the ecb namespace (http://www.ecb.int/vocabulary/2002-08-01/eurofxref). However its children elements (which are also named Cube), are not bound to a namespace. In your xml, you have defined xmlns to be bound to the ecb namespace, which means all elements with no prefix will have an ecb namespace. As a result, the inner 'Cube' element is invalid. If you change the xmlns declaration to xmlns:eb, and use the eb prefix with the 'Cube' child element of Envelope, your XML document will parse fine.
Regards,
Khaled
"Erik Rydgren"
<[EMAIL PROTECTED]>
11/04/2004 10:57 AM
|
|
I'm having problems getting some xml through the xerces validator. The
file is valid through Altova XmlSpy but not in Xerces for some reason.
The file is downloaded from the European central bank and looks like
this:
<?xml version="1.0" encoding="UTF-8"?>
<gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01"
xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.gesmes.org/xml/2002-08-01 gesmes.xsd">
<gesmes:subject>Reference rates</gesmes:subject>
<gesmes:Sender>
<gesmes:name>European Central Bank</gesmes:name>
</gesmes:Sender>
<Cube>
<Cube time='2004-10-27'>
<Cube currency='USD' rate='1.2792'/>
<Cube currency='JPY' rate='136.37'/>
<Cube currency='DKK' rate='7.4348'/>
</Cube>
</Cube>
</gesmes:Envelope>
There are also two schemas involved. First gesmes.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.gesmes.org/xml/2002-08-01"
xmlns:ecb="http://www.ecb.int/vocabulary/2002-08-01/eurofxref"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01"
elementFormDefault="qualified">
<xs:import
namespace="http://www.ecb.int/vocabulary/2002-08-01/eurofxref"
schemaLocation="ecb.xsd"/>
<xs:complexType name="subjectType"/>
<xs:complexType name="SenderType">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="rootType">
<xs:sequence>
<xs:element name="subject" type="xs:string"/>
<xs:element name="Sender" type="gesmes:SenderType"/>
<xs:element ref="ecb:Cube"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Envelope" type="gesmes:rootType"/>
</xs:schema>
The second schema is ecb.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
targetNamespace="http://www.ecb.int/vocabulary/2002-08-01/eurofxref"
xmlns:ecb="http://www.ecb.int/vocabulary/2002-08-01/eurofxref"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified">
<xs:complexType name="CubeType3">
<xs:attribute name="currency" type="xs:string"/>
<xs:attribute name="rate" type="xs:decimal"/>
</xs:complexType>
<xs:complexType name="CubeType2">
<xs:sequence>
<xs:element name="Cube" type="ecb:CubeType3" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="time" type="xs:date"/>
</xs:complexType>
<xs:complexType name="CubeType">
<xs:sequence>
<xs:element name="Cube" type="ecb:CubeType2" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Cube" type="ecb:CubeType"/>
</xs:schema>
As I said XmlSpy regards the data as valid but Xerces tells me that Cube
is not valid content to envelope. I can't figure out what the problem
is. Any help would be greatly appriciated.
Best regards
Erik Rydgren
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]