Re: [xsl] Obtaining a node's schema type

Subject: Re: [xsl] Obtaining a node's schema type
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Mon, 26 Jul 2010 12:21:52 +0100
There's no standard function to get the type annotation name of a node; the nearest thing is that you can test whether the node is of type X (or a subtype of X) using "instance of". Saxon fills this gap with saxon:type-annotation(). I'm not sure I can present the case why the WG decided not to provide such a function, but the essence of the argument is probably that implementations always have freedom to use a subtype, which might not be meaningful to the user, and might not be interoperable - for example the result of 3+3 is specified in the spec to be xs:integer, but an implementation might use xs:positiveInteger, or xs:int, or my:integer-in-range-4-to-8, provided these are subtypes of xs:integer.

Michael Kay
Saxonica

On 26/07/2010 11:04, Wolfgang Laun wrote:
Given an XPath denoting a "leaf" element or an attribute of the input
XML and that the XML Schema describing this document is available, I'd
like to obtain the XML Schema type of that item. I think that I can
implement such a function (for this particular application) without
spraining too many synapses, but, being lazy:

- Is such a function (XSLT 2.0) freely available, and where?

- Would this be an out-of-the-box function of a schema-aware XSLT processor?

Regards
Wolfgang

Current Thread