Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: Uniqueness

From: "Dutta, Abhijit" <abhijit.dutta@---------.--->
To: "Michael Kay" <mike@--------.--->, <xmlschema-dev@--.--->
Date: 1/17/2008 9:04:00 PM
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 <www.---.com;
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
<www.---.com; ="ipm:mayHaveDaughter"/>
                               <xsd:field xpath="@f1"/>
                               <xsd:field xpath="ipm:s"/>
      </xsd:unique>
</xsd:element>
 
<xsd:element name="mayHaveDaughter">
               <xsd:complexType>
                               <xsd:choice>
                                              <xsd:element name="s"
minOccurs="0" maxOccurs="1" type="xsd:string"/>
                               </xsd:choice>
                               <xsd:attribute name="f1"
type="xsd:string"/>
               </xsd:complexType>
</xsd:element>
 
example xml file <http://blogs.stylusstudio.com/> :
 
<?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="c">
               <s>100</s>
 </mayHaveDaughter>
 
 <mayHaveDaughter f1="c">
               <s>200</s>
 </mayHaveDaughter>
</root>
 
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. 
 
~Thanx
Abhijit
 
 
 

 

 

________________________________

From: Michael Kay [mailto:mike@s...] 
Sent: Thursday, January 17, 2008 2:39 PM
To: Dutta, Abhijit; xmlschema-dev@w...
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..

=09 

	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).

=09 

	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.

=09 

	Michael Kay

	http://www.saxonica.com/

 

 



This e-mail and any attachment is for authorised use by the intended recipi=
ent(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 recipien=
t then please promptly delete this e-mail and any attachment and all copies=
 and inform the sender. Thank you.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent