Schema validation using multiple schemas 2003-08-25 - By Adachi Seiichi
Hi All,
I am trying to validate an xml file using multiple schema files using Xerces-J 2.5.0. The xml file specifies the location of schema#1 using schemaLocation. Inside of schema#1, schema#2 is specified using xsd:import. I get an error when the root element of the xml file is an element defined in schema#2.
I have used the sample program dom.Counter that comes with Xerces-J 2.5.0, and get the error : [Error] test.xml:4:70: cvc-elt.1: Cannot find the declaration of elment 'ns2:report'. (I have tried using XML Spy Ver.5 Rel.4 and the DOMCount.exe of Xerces-C 2.3.0 but do not get an error.)
Any help will be greatly appreciated. Here is the sample data I used:
test.xml -------- <ns2:report xmlns='http://foo.com/namespace1' xmlns:ns2='http://foo.com/namespace2' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://foo.com/namespace1 ns1.xsd'> <textData>sample XML file</textData> </ns2:report>
ns1.xsd (Schema#1) ------------------ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://foo.com/namespace1" xmlns="http://foo.com/namespace1" xmlns:ns2="http://foo.com/namespace2" elementFormDefault="qualified">
<xsd:import namespace="http://foo.com/namespace2" schemaLocation="ns2.xsd" />
<xsd:element name="textData" type="xsd:string" substitutionGroup="ns2:body"/>
</xsd:schema>
ns2.xsd (Schema#2) ------------------ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://foo.com/namespace2" xmlns="http://foo.com/namespace2" elementFormDefault="qualified">
<xsd:element name="report"> <xsd:complexType> <xsd:sequence> <xsd:element ref="body"/> </xsd:sequence> </xsd:complexType> </xsd:element>
<xsd:element name="body" type="xsd:string"/>
</xsd:schema>
Thanks,
Seiichi
_________________________________________________________________ $B2q0wEPO?$OL5NA(B $B=<<B$7$?=PIJ%"%$%F%`$J$i(B MSN $B%*!<%/%7%g%s(B http://auction.msn.co.jp/
--------------------------------------------------------------------- To unsubscribe, e-mail: xerces-j-user-unsubscribe@(protected) For additional commands, e-mail: xerces-j-user-help@(protected)
|
|