OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Namespaces and XML Schema validation

[ Lists Home | Date Index | Thread Index ]

Henry, Priscilla, and David,

Thanks for your valuable tips! Although I haven't used Relax NG so far,
David, it does look tempting...

However, I still have a problem with making my example validate in XML Spy,
and I'm beginning to fear that it is something with my set up of XML Spy (or
incorrect interpretation of the standards by the software, heaven forbid ;)
rather than errors in XML. Can you help me in understanding where my problem
lies?

XML Spy says: "Mandatory element 'b1' expected in place of 'b:b1'", and I
suppose it would react similarly on 'c:c1' as well. When I receved this
error message before, I assumed that I had got something wrong with the use
of the namespaces, and that was one reason for asking the first question.
But even with your help, it does give me the same error message... And I'm
sure my other problems (with nesting of namespaces etc) stems from the same
thing as this.

By the way, I had to include the 'xsi' namespace attribute in the document
as well, otherwise I got an error for "unexpected attribute"...


I have:

XML DOCUMENT:
<?xml version="1.0"?>
<a1 xsi:noNamespaceSchemaLocation="a.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xmlns:b="http:\\example.org\b\"
    xmlns:c="http:\\example.org\c\">
	<b:b1>This is element B1 from namespace B</b:b1>
	<a2>This is the second element from schema a</a2>
	<c:c1>This element is from namespace c</c:c1>
</a1>


XML SCHEMA a.xsd:
<?xml version="1.0"?>
<xs:schema xmlns:c="http://example.org/c/";
           xmlns:b="http://example.org/b/";
           xmlns:xs="http://www.w3.org/2001/XMLSchema";>
	<xs:import namespace="http://example.org/b/"; schemaLocation="b.xsd"/>
	<xs:import namespace="http://example.org/c/"; schemaLocation="c.xsd"/>
	<xs:element name="a1">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="b:b1"/>
				<xs:element name="a2"/>
				<xs:element ref="c:c1"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>


XML SCHEMA b.xsd:
<?xml version="1.0"?>
<xs:schema targetNamespace="http://example.org/b/";
           xmlns:xs="http://www.w3.org/2001/XMLSchema";>
	<xs:element name="b1"/>
</xs:schema>


XML SCHEMA c.xsd:
<?xml version="1.0"?>
<xs:schema targetNamespace="http://example.org/c/";
           xmlns:xs="http://www.w3.org/2001/XMLSchema";>
	<xs:element name="c1"/>
</xs:schema>


I should mention that I tried the attribute elementForm="qualified" in some
of those xsd files, but I could not notice any different behaviour.

Thanx!
Peter
--
Peter Bergstrom
Eurostep AB
Vasagatan 38
SE-111 20 Stockholm
Sweden

mobile phone:    +46 708 111 966
mobile fax:      +46 708 111 965
home office fax: +46 470 711 930

http://www.eurostep.com/
Open solutions for open organisations and people






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS