Andreas Martens created XALANJ-2852:
---------------------------------------
Summary: No-namespace element copied into an RTF inside a
default-namespace element gets the parent's namespace URI (interpretive and
XSLTC)
Key: XALANJ-2852
URL: https://issues.apache.org/jira/browse/XALANJ-2852
Project: XalanJ2
Issue Type: Bug
Security Level: No security risk; visible to anyone (Ordinary problems in
Xalan projects. Anybody can view the issue.)
Components: Serialization, Xalan, XSLTC
Affects Versions: 2.7.3
Environment: any
Reporter: Andreas Martens
{{xsl:copy-of}} of a no-namespace element into a result tree fragment, inside
an element that declares a default namespace, changes the copied element's
namespace URI to the default namespace. {{namespace-uri()}} on the node,
reached through {{{}exsl:node-set(){}}}, returns the wrong value.
Input:
{{<r:root xmlns:r="urn:test"><item/></r:root>}}
Stylesheet:
{{<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"}}
{{xmlns:r="urn:test" xmlns:exsl="http://exslt.org/common"}}
{{extension-element-prefixes="exsl" exclude-result-prefixes="r exsl">}}
{{ <xsl:output method="xml" omit-xml-declaration="yes"/>}}
{{ <xsl:variable name="v">}}
{{ <container xmlns="urn:test"><xsl:copy-of
select="/r:root/item"/></container>}}
{{ </xsl:variable>}}
{{ <xsl:template match="/">}}
{{ <uri><xsl:value-of
select="namespace-uri(exsl:node-set($v)/*[local-name()='container']/*[local-name()='item'])"/></uri>}}
{{ </xsl:template>}}
{{</xsl:stylesheet>}}
Expected result:
{{<uri/>}}
Actual result:
{{<uri>urn:test</uri>}}
Reference:
XSLT 1.0 §11.3: the copy keeps its expanded name
Testing with Saxon and the older IBM XL TXE give the "expected" result.
Related:
XALANJ-978 (same inheritance problem, serialized output, interpretive path),
XALANJ-2404 (XSLTC namespace loss on RTF {{{}copy-of{}}}). the fix for these
_might_ solve them, but they seem different _enough_ to warrant a new Issue.
Details (current knowledge):
When an element in no namespace is copied via {{xsl:copy-of}} into a Result
Tree Fragment (RTF) that contains an enclosing element with a default namespace
declaration, Xalan incorrectly assigns the enclosing default namespace URI to
the copied element rather than preserving its no-namespace identity. This
causes {{namespace-uri()}} to return the wrong value and unprefixed XPath steps
to fail to match. A secondary defect means that even when the in-memory
identity is correct, the serialized XML output omits the {{xmlns=""}}
undeclaration attribute required to signal no-namespace to a downstream XML
parser.
My current fix ensures the element's explicit no-namespace URI is preserved
through the RTF construction pipeline in both the interpretive and XSLTC
engines, and extends the serializer to emit {{xmlns=""}} whenever an unprefixed
no-namespace element is written inside an active default-namespace scope. I'm
going to start testing this.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]