XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] XSD 1.1 - assert a condition of a complex type depending on another element's attribute value

>     <xs:complexType>
>       <xs:attribute name="start" type="xs:integer" use="required"/>
>       <xs:attribute name="end" type="xs:integer" use="required"/>
>       <xs:assert test="@start ge root(.)/cd/pd/@start"/>
>       <xs:assert test="@end le root(.)/cd/pd/@end"/>
>     </xs:complexType>

xs:assert sees a tree fragment rooted at the element E whose type you are
testing against. root(.) returns the root of this tree, that is, the element
E. The idea is that validation of an element depends only on the content of
that element, not on the context in which it appears. XSLT, for example,
assumes that if you copy a valid element to a new tree, then it will still
be valid (against the original type).

> 
> What I want is to assert that the value of the start 
> attribute of each s element is greater or equal than that of 
> the start attribute of the pd element (and vice versa for the 
> end attribute).
> 

You need to put the assertion at the level of the common ancestor: that is,
identify the element that contains all the data needed to compute the
assertion, and put the assertion on the type of that element.

Regards,

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



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


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS