W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2008

RE: Uniqueness

From: Dutta, Abhijit <abhijit.dutta@logicacmg.com>
Date: Thu, 17 Jan 2008 15:45:44 +0530
Message-ID: <90293B373640D5409D53D4119A6096D1651076@in-ex005.groupinfra.com>
To: "Michael Kay" <mike@saxonica.com>, <xmlschema-dev@w3.org>
Hi Michael,


First, I want name and index *both* should be unique.  I went through
the definition of  xs:unique, which usually put constraint on the
values. But I want the uniqueness in the element attribute-value pair.
For example,


xsd file:
<xsd:schema <http://www.stylusstudio.com/xml_schema_editor.html>
<xsd:element name="root">
ref="ipm:mayHaveDaughter" minOccurs="0" maxOccurs="unbounded"/>
      <xsd:unique name="uniqueNode">
                               <xsd:selector xpath
<http://www.stylusstudio.com/xpath.html> ="ipm:mayHaveDaughter"/>
                               <xsd:field xpath="@f1"/>
                               <xsd:field xpath="ipm:s"/>
<xsd:element name="mayHaveDaughter">
                                              <xsd:element name="s"
minOccurs="0" maxOccurs="1" type="xsd:string"/>
                               <xsd:attribute name="f1"
example xml file <http://blogs.stylusstudio.com/> :
<?xml version="1.0"?>
<root xmlns="http://unique/test" 
                 xsi:schemaLocation="http://unique/test unique.xsd">
  <mayHaveDaughter f1="c">
 <mayHaveDaughter f1="c">
Now in the above example values are different 100, 200 etc., since there
is a unique constraint. My question is can I put restriction such that
the element "mayHaveDaughter"   *must* have different element attrib/
value pairs like, f1="c", f1="d" etc.
Hope that clarifies my doubt. 




From: Michael Kay [mailto:mike@saxonica.com] 
Sent: Thursday, January 17, 2008 2:39 PM
To: Dutta, Abhijit; xmlschema-dev@w3.org
Subject: RE: Uniqueness



	Is there a way in XSD to specify that the name and index will be
unique for a set of fields? If so, could you please give an example..


	You can use xs:unique. But exactly how you use it depends on
having a clearer specification. Are you saying "name must be unique and
index must also be unique", or are you saying "the combination of name
and index must be unique" (the second option would allow two things to
have the same name provided they have a different index).


	Also, uniqueness applies within some scope - typically there is
some element E within which each child/descendant element F has a unique
value for V. You need to tell us something about E, because that is
where you define the constraint.


	Michael Kay




This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
Received on Thursday, 17 January 2008 10:17:02 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:45 UTC