Re: [xsl] are all strings in a sequence valid potential QNames

Subject: Re: [xsl] are all strings in a sequence valid potential QNames
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Thu, 4 Feb 2010 11:36:09 +0000
> But thinking about it, perhaps it isn't all that bizarre at all, Andrew ...
> consider the following:
>
> T:\ftemp>type ken2.xsl
> <?xml version="1.0" encoding="US-ASCII"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>                xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>                version="2.0">
>
> <xsl:output method="text"/>
>
> <xsl:template match="/">
> 'abcdef':   <xsl:value-of select="'abcdef' castable as xsd:QName"/>
> 'abc:def':  <xsl:value-of select="'abc:def' castable as xsd:QName"/>
> 'xsd:def':  <xsl:value-of select="'xsd:def' castable as xsd:QName"/>
> </xsl:template>
>
> </xsl:stylesheet>
>
> T:\ftemp>xslt2 ken2.xsl ken2.xsl
>
> 'abcdef':   true
> 'abc:def':  false
> 'xsd:def':  true
> T:\ftemp>
>
> The second string being cast above is obliged to return false() because
> there is no prefix binding for 'abc'.

Sure, but you don't really need to test if it's castable as xs:QName
as you can tell from static analysis of the stylesheet it will fail.
The more realistic use case is to test an unknown value.


> Now consider a string variable:  the string is in the lexical space for the
> QName, but without an indication of which node to base the value space
> evaluation for the given string, it is impossible to create a complete
QName
> value.  And there is no opportunity in the syntax of "castable as" to
supply
> a second input operand being the context node for the evaluation of the
> value-space for the given lexical string.

That's a good point.  But would there be any problems if it used in
the in-scope-prefixes of the context node?   At least then it can
achieve its main use case.  Flatly refusing any string literal means
you can't even work around it by testing the prefix against the
in-scope-prefixes yourself, and then checking the local part is
castable as an xs:QName...

And of course, "silently" returning false like this seems a bit XSLT
1.0...   :-)





--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

Current Thread