By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,827 Members | 2,140 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,827 IT Pros & Developers. It's quick & easy.

Help-Error validating multiple documents

P: n/a
Hello. I've got a total of 5 schemas. They are:

1 - 1.xsd - a description of a city
2 - 2.xsd - a description of a town
3 - CityHall.xsd - a description of a cityhall-meant to be part of a
document based on 1.xsd in "user area".
4 - TownHall.xsd - a description of a townhall-meant to be part of a
document based on 2.xsd in "user area".
5 - testmultischema.xsd - a document which combines in a batch instances
of cities and towns based upon 1.xsd and 2.xsd.

I get the following xml validation error:

ERROR: The 'http://adamExt.org:TownHall' element is not declared. An
error occur
red at file:///c:/adamtestschema/testmultischema.xml, (21, 4).

in a testmultischema doc that contains both an instance of city and
town. However, if I only have one instance of either in the testmulti
doc, it validates perfectly.

Thanks in advance.

1.xsd
-----

<xsd:schema targetNamespace="http://adam.org"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://adam.org"
elementFormDefault="qualified">
<xsd:element name="City" type="CityType"/>
<xsd:complexType name="CityType">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="UserAreaCity" type="UserAreaCityType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="UserAreaCityType">
<xsd:sequence minOccurs="0">
<xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

2.xsd
------

<xsd:schema targetNamespace="http://adam.org"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://adam.org"
elementFormDefault="qualified">
<xsd:element name="Village" type="VillageType"/>
<xsd:complexType name="VillageType">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="UserAreaTown" type="UserAreaTownType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="UserAreaTownType">
<xsd:sequence minOccurs="0">
<xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

testmultischema.xsd
-------------------
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="http://localhost/adamMulti.org"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://localhost/adamMulti.org"
xmlns:h="http://adam.org"
elementFormDefault="qualified" id="Multiple">
<xs:import namespace="http://adam.org"
schemaLocation="http://localhost/adamtestschema/1.xsd" />
<xs:import namespace="http://adam.org"
schemaLocation="http://localhost/adamtestschema/2.xsd" />
<xs:complexType name="MessageType">
<xs:sequence>
<xs:element name="Id" type="xs:integer" />
<xs:choice>
<xs:element ref="h:City" />
<xs:element ref="h:Village" />
</xs:choice>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MessagesType">
<xs:sequence>
<xs:element name="Message" type="MessageType" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="MultipleType">
<xs:sequence>
<xs:element name="Messages" type="MessagesType" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:element name="Multiple" type="MultipleType" />
</xs:schema>

instance of testmultischema which fails validation
--------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<Multiple xmlns="http://localhost/adamMulti.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://localhost/adamMulti.org
http://localhost/adamtestschema/testmultischema.xsd">
<Messages>
<Message>
<Id>1</Id>
<City xmlns="http://adam.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://adam.org
http://localhost/adamtestschema/1.xsd">
<name>New York</name>
<UserAreaCity>
<CityHall xsi:schemaLocation="http://adamExt.org
http://localhost/adamtestschema/CityHall.xsd"
xmlns="http://adamExt.org">
City Hall Building
</CityHall>
</UserAreaCity>
</City>
</Message>
<Message>
<Id>2</Id>
<Village xmlns="http://adam.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://adam.org
http://localhost/adamtestschema/2.xsd">
<name>Ramapo</name>
<UserAreaTown>
<TownHall xsi:schemaLocation="http://adamExt.org
http://localhost/adamtestschema/TownHall.xsd"
xmlns="http://adamExt.org">
Town Hall Building
</TownHall>
</UserAreaTown>
</Village>
</Message>
</Messages>
</Multiple>
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.