|
> Let me put it this way:
> XSLT (any version) does have an underlying
> type system, but your XSLT stylesheet doesn't
> have to specify the datatype of everything;
> you can even skip the as="" attribute on
> xsl:param if you so desire. XSLT tends to
> handle string/number/node-to-text conversions
> without a lot of fuss--it almost always
> delivers a reasonable result, even if it's not
> what you'd ideally like.
Quite *not* so. I don't think anyone who has actually written XSLT 2.0 code will make the quoted statement.
XSLT 2.0 uses XPath 2.0 which has stringent type-checking rules.
For example, even something as simple as the following transformation raises type errors, as evidenced using Saxon 8.3B:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:template match="/">
<xsl:copy-of select="*/*
[3 < substring(@n,2)]"/>
</xsl:template>
</xsl:stylesheet>
when applied on this source xml document:
<t>
<x n="n1"/>
<x n="n2"/>
<x n="n3"/>
<x n="n4"/>
<x n="n5"/>
</t>
the result is:
Saxon 8.3 from Saxonica
Java version 1.5.0_01
Error at xsl:copy-of on line 6 of file:/C:/Program%20Files/Java/jdk1.5.0_01/bin/marrowtr.xsl:
XP0006: Cannot compare xs:integer to xs:string
Failed to compile stylesheet. 1 error detected.
Best regards,
Dimitre Novatchev.
|