D
Dominique
Hi all,
I am trying to create a schema (conf.xsd) that includes 2 other
schemas (a.xsd, b.xsd). in my xml file, I have namespaces for each of
these schemas, but my XML file doesn't validate... It's definitely a
grammar problem.
I have spent quite a bit of time playing with it, and can't find
related examples on the net, anyone has experience with this?
here are my example files:
------------------------ main.xml -------------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<conf:CONF xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://test.com/CONF conf.xsd
http://test.com/A a.xsd
http://test.com/B b.xsd"
xmlns:conf="http://test.com/CONF"
xmlns:namea="http://test.com/A"
xmlns:nameb="http://test.com/B"
<namea:ROOT>
<namea:ELEM1>12345</namea:ELEM1>
<namea:ELEM2>TEST</namea:ELEM2>
</namea:ROOT>
<nameb:ROOT>
<namea:ELEMI>2020</namea:ELEMI>
<namea:ELEMJ>DATA</namea:ELEMJ>
</nameb:ROOT>
</conf:CONF>
------------------------ conf.xsd -------------------------
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://test.com/CONF"
xmlns="http://test.com/CONF"
xmlns:a="http://test.com/A"
xmlns:b="http://test.com/B"
<xs:import namespace="http://test.com/A" schemaLocation="a.xsd" />
<xs:import namespace="http://test.com/B" schemaLocation="b.xsd" />
<xs:element name="CONF">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="a:ROOT" minOccurs="0"/>
<xs:element ref="b:ROOT" minOccurs="0"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
------------------------ a.xsd -------------------------
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://test.com/A"
xmlns="http://test.com/A">
<xs:element name="ROOT">
<xs:complexType>
<xs:sequence>
<xs:element name="ELEM1" type="xsositiveInteger" />
<xs:element name="ELEM2" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
------------------------ b.xsd -------------------------
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://test.com/B"
xmlns="http://test.com/B">
<xs:element name="ROOT">
<xs:complexType>
<xs:sequence>
<xs:element name="ELEMI" type="xsositiveInteger" />
<xs:element name="ELEMJ" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I am trying to create a schema (conf.xsd) that includes 2 other
schemas (a.xsd, b.xsd). in my xml file, I have namespaces for each of
these schemas, but my XML file doesn't validate... It's definitely a
grammar problem.
I have spent quite a bit of time playing with it, and can't find
related examples on the net, anyone has experience with this?
here are my example files:
------------------------ main.xml -------------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<conf:CONF xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://test.com/CONF conf.xsd
http://test.com/A a.xsd
http://test.com/B b.xsd"
xmlns:conf="http://test.com/CONF"
xmlns:namea="http://test.com/A"
xmlns:nameb="http://test.com/B"
<namea:ROOT>
<namea:ELEM1>12345</namea:ELEM1>
<namea:ELEM2>TEST</namea:ELEM2>
</namea:ROOT>
<nameb:ROOT>
<namea:ELEMI>2020</namea:ELEMI>
<namea:ELEMJ>DATA</namea:ELEMJ>
</nameb:ROOT>
</conf:CONF>
------------------------ conf.xsd -------------------------
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://test.com/CONF"
xmlns="http://test.com/CONF"
xmlns:a="http://test.com/A"
xmlns:b="http://test.com/B"
<xs:import namespace="http://test.com/A" schemaLocation="a.xsd" />
<xs:import namespace="http://test.com/B" schemaLocation="b.xsd" />
<xs:element name="CONF">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="a:ROOT" minOccurs="0"/>
<xs:element ref="b:ROOT" minOccurs="0"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
------------------------ a.xsd -------------------------
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://test.com/A"
xmlns="http://test.com/A">
<xs:element name="ROOT">
<xs:complexType>
<xs:sequence>
<xs:element name="ELEM1" type="xsositiveInteger" />
<xs:element name="ELEM2" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
------------------------ b.xsd -------------------------
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://test.com/B"
xmlns="http://test.com/B">
<xs:element name="ROOT">
<xs:complexType>
<xs:sequence>
<xs:element name="ELEMI" type="xsositiveInteger" />
<xs:element name="ELEMJ" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>