RE: optional, but at least one required

> 
> And, just to confirm that the simple case does not hide any 
> nasties when extended up to bigger examples, Marie's case 
> would simply be (ignoring the specific names):
> 
>     <xs:assert test="a|b|c|d|e|f|..."/>

Of course, you could also reduce it to test="*", or if you want a less terse
expression

test="exists(child::*)"

> 
> BTW - If, in another schema snippet, I wanted either 
> attribute A or element E, but not both, then my expression would be:
> 
>     <xs:assert test="@A and fn:not(E) or fn:not(@A) and E"/>

I've toyed with different ways of writing this, and I'm inclined to:

<xs:assert test="exists(@A) = empty(E)"/>
> 
> I don't think I can do the following though, because I can't 
> do "...eq 1":
> 
>     <xs:assert test="op:count(@A|E) eq 1"/>
> 

The current draft spec defines a very restricted subset of XPath 2.0 which
processors must implement, but allows them to implement the whole of XPath
2.0 if they prefer. That's what the Saxon implementation does (it's
supported in 8.9.9.2 which is out as a beta release). I hope that other
processors, and indeed the spec, will follow suit. (If you agree, please
comment on the last call draft!) I personally find it very frustrating to
work within the subset.

Michael Kay
http://www.saxonica.com/

Received on Thursday, 11 October 2007 15:02:57 UTC