tags:

views:

40

answers:

3

I want to be able to guarantee uniqueness for two types of elements : MainQuestion and AlternateQuestion. In the select query for my xsd:key, can I specify something that would do "//MainQuestion or //AlternateQuestion"? Someone told me that something like this existed, but it seems that XSD only supports a subset of the XPath syntax...

A: 

Do you have tried the or ? http://w3schools.com/xpath/xpath_operators.asp

mere-teresa
+2  A: 

You should be able to use | as usual:

//MainQuestion | //AlternateQuestion

the syntax is indeed restricted - it is roughly the same as restrictions for template patterns in XSLT 1.0, but in addition to that it cannot have any filters in path steps. However, | is explicitly listed as supported.

Pavel Minaev
thanks for your response, I don't know how I didn't find that myself, that was pretty easy...
lau
+1  A: 

Supporting Pavel's answer that you can use "|" in an XPath in XML Schema.

XML Schema supports a subset of XPath (which I think of as "fake XPath"). What it supports is explicitly stated in the spec. You have to trace through a few sections to find it. This is a link to the exact section:

http://www.w3.org/TR/xmlschema-1/#c-selector-xpath

13ren