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

Re: Uniqueness across different child element types


xmlspy xerces
Don,

You'll be happy to know that this very issue was a recent thread here on
XML-DEV. I don't recall the final outcome, but I would recommend you
start with [1] and progress through the thread.

Kind Regards,
Joe Chiusano
Booz | Allen | Hamilton

[1] http://lists.xml.org/archives/xml-dev/200305/msg00577.html

Don Bate wrote:
> 
> I believe that I've found a bug in both XMLSpy and Xerces and I'm
> looking for some confirmation. If I understand the rec correctly the
> xml document at the bottom should fail the uniqueness constraint and
> not be valid using the schema above it. However, both XMLSpy and
> Xerces say it is valid.
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>     elementFormDefault="qualified"
>     attributeFormDefault="unqualified">
>  <xs:element name="a">
>   <xs:complexType>
>   <xs:sequence>
>    <xs:element ref="b" maxOccurs="unbounded"/>
>    <xs:element ref="c" maxOccurs="unbounded"/>
>   </xs:sequence>
>   </xs:complexType>
>   <xs:unique name="xUnique">
>    <xs:selector xpath="a|b"/>
>    <xs:field xpath="@x"/>
>   </xs:unique>
>  </xs:element>
>  <xs:element name="b">
>   <xs:complexType>
>    <xs:attribute name="x" type="xs:string" use="required"/>
>   </xs:complexType>
>  </xs:element>
>  <xs:element name="c">
>   <xs:complexType>
>    <xs:attribute name="x" type="xs:string" use="required"/>
>   </xs:complexType>
>  </xs:element>
> </xs:schema>
> 
> 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"
>     xsi:noNamespaceSchemaLocation="test.xsd">
>  <b x="foo"/>
>  <c x="foo"/>
> </a>
> Also, if I duplicate the "b" element (and it also has the value of
> "foo" for the "x" attribute) both XMLSpy and Xerces will fail the
> document.
> 
> Is this a bug? If it's not a bug then could someone point out to me
> the relevant part of the rec that says that the pairwise comparison
> only occurs on elements with the same name? Am I doing something
> wrong? Do I not have my xpath selector correctly
> written?
> 
> BTW, I've already posted this question to the comp.text.xml newsgroup
> and the Altova discussion forum but have not received _any_ responses
> yet otherwise I wouldn't have bothered this list.
> 
> Don Bate
begin:vcard 
n:Chiusano;Joseph
tel;work:(703) 902-6923
x-mozilla-html:FALSE
url:www.bah.com
org:Booz | Allen | Hamilton;IT Digital Strategies Team
adr:;;8283 Greensboro Drive;McLean;VA;22012;
version:2.1
email;internet:chiusano_joseph@b...
title:Senior Consultant
fn:Joseph M. Chiusano
end:vcard

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.