Michael Kay wrote:
Hi
> There's also sometimes a theoretical risk that prefixes
> will be changed because XSLT 1.0 permits it
Yes, it is what I thought about.
> but mainstream processors all do the decent thing in
> straightforward cases.
And that is why I use it. But I'm not very comfortable
with the use of this "observable behaviour" without knowing
exactly how this happens (prefixes will be changed in
particular cases or not?).
In XSLT 2.0, the transformation fails if you try to create
a namespace node whose the prefix is already bound to
another namespace URI. I like that. In XSLT 1.0, the
transformation succeed, your result is not correct and the
error will propagate further in the chain.
Mmh, before to post, I just wrote a little test. Input:
<my:same xmlns:my="namespace-double.xsl">
<my:other xmlns:my="other-uri"/>
</my:same>
Stylesheet:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:my="namespace-double.xsl"
exclude-result-prefixes="exsl"
version="1.0">
<xsl:output indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="*">
<xsl:variable name="dummy-ns">
<my:e/>
</xsl:variable>
<xsl:copy>
<xsl:copy-of select="
exsl:node-set($dummy-ns)/*/namespace::*"/>
<xsl:attribute name="added">my:value</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()" priority="-1">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
I tested it with Saxon 6, Saxon 8, Xalan and xsltproc.
Actually, Saxon 6 was the only one to generate an error:
Error at xsl:copy-of on line 16 of namespace-double.xsl:
Cannot create two namespace nodes with the same name
Transformation failed: Run-time errors were reported
I thought in this case an XSLT 1.0 processor will change
one of the prefixes and not generate an error, but I didn't
find the right verses in the XSLT 1.0 REC. Does any one
know those verses?
Furthemore, I thought Saxon 8 didn't throw an error
because it was in compatibility mode, but the transformation
succeed even with an XSLT 2.0 stylesheet. It fails if we
use xsl:namespace to create the node, but not if we use
xsl:copy-of to copy it. Again, I didn't find in the XSLT
2.0 REC the difference between xsl:namespace and xsl:copy-of
regarding the duplicate namespace node names. Any pointer?
Regards,
--drkm
___________________________________________________________________________
Dicouvrez une nouvelle fagon d'obtenir des riponses ` toutes vos questions