namespace collision with namespace-alias
I'm trying to write a sort of generative XSLT: an XSLT stylesheet which creates another XSLT stylesheet. Unfortunately, I've confused xsltproc.
The simplest example if the following. I copy content of "xsl:stylesheet" as is and added a dummy template.
[code]
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" xmlns:axsl = "http://www.w3.org/1999/XSL/TransformAlias" version = "1.0"> <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/> <xsl:template match="xsl:stylesheet"> <xsl:copy> <xsl:copy-of select="node()|@*"/> <axsl:template match="none"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
[/code]
Note that "xsl:copy-of" and "axsl:template" are in different namespaces. Now apply this stylesheet to itself. Result is the following.
[code]
<?xml version="1.0"?> <axsl:stylesheet xmlns:axsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <axsl:namespace-alias xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias" stylesheet-prefix="axsl" result-prefix="xsl"/> <axsl:template xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias" match="xsl:stylesheet"> <axsl:copy> <axsl:copy-of select="node()|@*"/> <axsl:template match="none"/> </axsl:copy> </axsl:template> <axsl:template match="none"/></axsl:stylesheet>
[/code]
Now "axsl:copy-of" and "axml:template" are in the same namespace. It is incorrect.
By the way:
1) I expected that output prefix should be "xsl", not "axsl" (despite the specification doesn't require it).
2) Here is output from Saxon:
[code]
<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias" version="1.0"> <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/> <xsl:template match="xsl:stylesheet"> <xsl:copy> <xsl:copy-of select="node()|@*"/> <axsl:template match="none"/> </xsl:copy> </xsl:template> <axsl:template xmlns:axsl="http://www.w3.org/1999/XSL/Transform" match="none"/></xsl:stylesheet>
[/code]
Categories: