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

XSD: Behaviour of <xsd:unique>


xsd unique
Hello all,

I noticed three different behaviours with three different xml parsers with
the <xsd:unique> element. Can somebody give me an indication of which is the
right one. 

xsd file:
<xsd:schema xmlns:ipm="http://unique/test"
			xmlns:xsd="http://www.w3.org/2001/XMLSchema"
			targetNamespace="http://unique/test"
			elementFormDefault="qualified">
			
<xsd:element name="root">
	<xsd:complexType>
		<xsd:sequence>
			<xsd:element ref="ipm:mayHaveDaughter" minOccurs="0"
maxOccurs="unbounded"/>
		</xsd:sequence>
	</xsd:complexType>
	<xsd:unique name="uniqueNode">
		<xsd:selector xpath="ipm:mayHaveDaughter"/>
		<xsd:field xpath="@f1"/>
		<xsd:field xpath="ipm:d"/>
	</xsd:unique>
</xsd:element>

<xsd:element name="mayHaveDaughter">
	<xsd:complexType>
		<xsd:choice>
			<xsd:element name="d" minOccurs="0" maxOccurs="1"
type="xsd:string"/>
		</xsd:choice>
		<xsd:attribute name="f1" type="xsd:string"/>
	</xsd:complexType>
</xsd:element>

</xsd:schema>


example xml file:

<?xml version="1.0"?>

<root xmlns="http://unique/test" 
	  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	  xsi:schemaLocation="http://unique/test unique.xsd">
	  
 <mayHaveDaughter f1="a"/>
 <mayHaveDaughter f1="b"/>
 <mayHaveDaughter f1="c">
 	<s>1</s>
 </mayHaveDaughter>
 <mayHaveDaughter f1="c">
 	<s>2</s>
 </mayHaveDaughter>
</root>

What should be the behaviour when the optional tag <d> is missing. Both
MSXML 4.0 and xsdvalid still check on the f1 attribute. So if we leave out
the <d> tags in the example the file is invalid, because there are two
<mayHaveDaughter> elements with a f1 attribute value 'c'. However with xsv
no error is generated, and with XercesJ-2.3.0 I get following error: 'Not
enough values specified for <unique> identity constraint specified for
element'.

So my question is, if one of the optional elements is not available, should
this element be ignored or not. The recs seems to be not clear about that.

Kind regards,
Ismaƫl




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.