[Home] [By Thread] [By Date] [Recent Entries]

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

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]


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member