[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Namespaces and XML Schema validation


xml schema mandatory element
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



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.