W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2007

RE: optional, but at least one required

From: Michael Kay <mike@saxonica.com>
Date: Thu, 11 Oct 2007 16:02:32 +0100
To: "'Pete Cordell'" <petexmldev@tech-know-ware.com>, "'Marie Bilde Rasmussen'" <mariebilderas@gmail.com>
Cc: "'Virginia Wiswell'" <vwiswell@verizon.net>, <xmlschema-dev@w3.org>
Message-ID: <007901c80c17$c13e8420$4063a8c0@turtle>

> 
> 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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:00 GMT