GNOME Bugzilla – Bug 341463
Namespace-alias using #default for result-prefix with no default namespace in scope
Last modified: 2006-06-19 18:31:16 UTC
Namespace-alias using #default for result-prefix with no default namespace in scope, will incorrectly put an element in a default namespace in-scope of the literal element. But the target namespace URI must be the namespace in-scope of the xsl:namespace-alias element, not be evaluated dynamically for every literal result element. xsltApplyOneTemplateInt() calls copy->ns = xsltGetNamespace(ctxt, copy, copy->ns, copy); ... which will search at transformation-time for a default namespace in-scope for the literal result. if (URI == UNDEFINED_DEFAULT_NS) { xmlNsPtr dflt; dflt = xmlSearchNs(cur->doc, cur, NULL); Example: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="urn:test:foo"> <xsl:namespace-alias stylesheet-prefix="foo" result-prefix="#default"/> <xsl:template match="/" xmlns="urn:test:default"> <foo:foo > <foo:bar/> </foo:foo> </xsl:template> </xsl:stylesheet> <!-- Result of Libxslt: <foo xmlns="urn:test:default" xmlns:foo="urn:test:default"><foo:bar/></foo> Xalan-J: "NullPointerException" Saxon 6.5.3: <foo:foo xmlns:foo="" xmlns="urn:test:default"><foo:bar/></foo:foo> Saxon 8.1.1: "java.lang.RuntimeException: Cannot output a namespace node for the default namespace when the element is in no namespace" MSXML .NET: <foo><bar/></foo> -->
We'll go the .NET way here. Fixed in CVS HEAD. Current result: <?xml version="1.0"?> <foo><bar/></foo>