RE: [xsl] XPath 2.0 Datatypes namespace

Subject: RE: [xsl] XPath 2.0 Datatypes namespace
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 4 Aug 2006 12:21:39 +0100
> 1. According to 
> xs:dayTimeDuration  is a type defined in the 
> namespace. Why, then, can I 
> only get this to work in the
> namespace when using Saxon 8?

The W3C made the decision to put these names in the XML schema namespace on
22 Feb 2006, and I implemented the decision in the next release of Saxon,
which was version 8.7.1 released on 13 April 2006.

Please try to keep up with the latest releases - I know there are better
things to do than installing new versions all the time, but you will
otherwise get tripped up by small changes like this.
> 2. Why do I need to declare the datatype atall given that the 
> function is expecting a dayTime Duration datatype, ie why can't 
> I just use:
> <xsl:sequence 
> select="adjust-time-to-timezone(xs:time('10:00:00-04:00'),
> PT4H)"/> ?

PT4H is a path expression, it's short for child::PT4H, and will return an
empty sequence unless you have an element of that name.

Perhaps you meant to write 'PT4H'. The answer there is that XSLT 2.0 has
moved towards stronger type checking.  To put the case for this in a
nutshell, it means you have to be a bit more explicit in your code about the
data types you are using, and in return you get better diagnostics when you
make mistakes (like leaving out quotation marks), and therefore easier
> 3. Am I unwise to be using this functionality until these 
> standards become recommendations?

For many people the gain from exploiting the new features exceeds the pain
caused by the occasional change in the specification. There have been very
few changes over the last 2 years that would stop existing code working
except in obscure edge cases (this change of namespaces is one of the
biggest. Saxon still supports the old namespace in new releases, but of
course it doesn't support the new namespace in old releases.) But of course,
only you can do the risk assessment for your own project.

Michael Kay

Current Thread