470,810 Members | 1,272 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

uniqueness across different child elements

I'm having a problem with the "unique" feature of XML Schema. I'm
relatively new to using this feature so it may be that I'm
misunderstanding something. Let's assume that I have the following

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
<xs:element name="a">
<xs:element ref="b" maxOccurs="unbounded"/>
<xs:element ref="c" maxOccurs="unbounded"/>
<xs:unique name="xUnique">
<xs:selector xpath="a|b"/>
<xs:field xpath="@x"/>
<xs:element name="b">
<xs:attribute name="x" type="xs:string"
<xs:element name="c">
<xs:attribute name="x" type="xs:string"

where an element "a" has two child elements "b" and "c". Each of these
child elements have a string attribute "x". "x" is supposed to be unique
within "a" regardless of whether it's in "b" or "c". I believe that the
above schema captures that.

However, the following document is valid according to XMLSpy and Xerces
when I believe that it is invalid:

<?xml version="1.0" encoding="UTF-8"?>
<a xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<b x="foo"/>
<c x="foo"/>

Am I doing something wrong? Do I not have my xpath selector correctly
written? Is this a bug?

Don Bate
Jul 20 '05 #1
0 1402

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Puvendran Selvaratnam | last post: by
10 posts views Thread by Mike Dickens | last post: by
5 posts views Thread by Alan Little | last post: by
3 posts views Thread by PC Paul | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.