xsl-list
[Top] [All Lists]

Re: [xsl] Datatype of a node

2014-09-10 11:24:37
This is only marginally on-topic for this list. I think the list covers XPath, 
and XSD assertions use XPath, so let's see if Tommie lets us get away with it.

Assertions are evaluated against a data model instance constructed as described 
in rule 1 here:

http://www.w3.org/TR/xmlschema11-1/#cvc-assertion

The essence of this is that the assertion is run on a tree that has been 
partially validated, using all the constraints in the schema except the 
assertions themselves; and the resulting PSVI will include the governing type 
against which the validation was performed. This PSVI is then translated into 
an XDM instance (conceptually, in implementation terms this is likely to be a 
no-op), and the XPath assertion is run against this XDM instance.

The net result is that if an element is validated against type T, the 
expression (used in the assertion) "E instance of element(T)" should be true.

So you can test whether two elements E and F both have the governing type T. 
What you can't do is to test whether they have the same type, without knowing 
the name of that type. This is because there is no function in XPath to obtain 
the type annotation of a node, only to test whether it matches some specified 
type.

Michael Kay
Saxonica
mike(_at_)saxonica(_dot_)com
+44 (0) 118 946 5893




On 10 Sep 2014, at 16:58, Timothy W. Cook tim(_at_)mlhim(_dot_)org 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:


How can I check if two nodes have the same datatype? 

I have to xs:choice section in a schema and the choices are of different 
datatypes and of course the elements have different names.

I want to add an assert to the schema so that the value in the second element 
is greater than the first and that the datatypes of the two choices are the 
same or validation fails.  

So I have this: <xs:assert test="(child::node()[2] gt child::node()[1]) and 
(???)"/>

But I cannot find how to replace the the ??? with the test I need.

MAYBE what I have written so far isn't correct either.  So any tips are 
appreciated. 

Thanks,
Tim



============================================
Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org

XSL-List info and archive
EasyUnsubscribe (by email)
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>