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

How to Unique contraint

  • From: smcardle@s...
  • To: xml-dev@l...
  • Date: Wed, 21 Mar 2007 12:30:58 +0100

How to Unique contraint
Hi,

I am trying to use a unique contraint <xsd:unique> in my xsd file that covers  
several attributes.

example:

<root>
	<anElement port="123" debug-port="234"/>
	<anElement port="125" debug-port="678"/>
</root>

here the constraint is that no port or debug-port can have the same number.

I can do them individually in the XSD like this

<xs:unique name="port">
	<xs:selector xpath="anElement"/>
	<xs:field xpath="@port"/>
</xs:unique>
<xs:unique name="debug-port">
	<xs:selector xpath="anElement"/>
	<xs:field xpath="@debug-port"/>
</xs:unique>

But this only means that the port attributes cannot contain the same value and 
the debug-port attribute cannot contain the same value.

What I want is that no port or debug-port can have the same value. BTW debug-
port is an optional attribute.

Does anybody know how to do this so it looks something like the following 
INVALID constraint, but I hope you get the picture.

<xs:unique name="port">
	<xs:selector xpath="anElement"/>
	<xs:field xpath="@debug-port | @port"/>
</xs:unique>

or maybe somebody can tell me how to get all attributes with the value 'port' 
in their name (not in thier content) i.e. so that it matches both @port and 
@debug-port. Something like the following (which does not work either):

<xs:unique name="port">
	<xs:selector xpath="anElement"/>
	<xs:field xpath="@*[contains('port`)]"/>
</xs:unique>

And if <xsd:unique> requires to match only a single or empty node-list response 
and it can´t do what I want, can anybody help with an alternative approach or 
solution???


Regards

Steve





[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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.