[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Datatype of a node

Subject: Re: [xsl] Datatype of a node
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 10 Sep 2014 16:24:20 -0000

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

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


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

Michael Kay
+44 (0) 118 946 5893

On 10 Sep 2014, at 16:58, Timothy W. Cook tim@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> 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
> 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)

Current Thread