[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"
<xsd:element name="root">
			<xsd:element ref="ipm:mayHaveDaughter" minOccurs="0"
	<xsd:unique name="uniqueNode">
		<xsd:selector xpath="ipm:mayHaveDaughter"/>
		<xsd:field xpath="@f1"/>
		<xsd:field xpath="ipm:d"/>

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


example xml file:

<?xml version="1.0"?>

<root xmlns="http://unique/test" 
	  xsi:schemaLocation="http://unique/test unique.xsd">
 <mayHaveDaughter f1="a"/>
 <mayHaveDaughter f1="b"/>
 <mayHaveDaughter f1="c">
 <mayHaveDaughter f1="c">

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

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,


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.
First Name
Last Name
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.