#103 Conflicting namespace names

v6.5.2
closed
Michael Kay
5
2012-10-08
2002-11-12
Michael Kay
No

When an attempt is made to add a namespace node to an
element, and the namespace node uses a prefix that is
already in use for the element name, but with a
different URI, Saxon reports an error. For example,
with Saxon 7.2, the following fails:

<ns:e xmlns:ns="nsone.uri">
<xsl:namespace name="ns">nstwo.uri</xsl:namespace>
</ns:e>

The same failure occurs in Saxon 6.5.2, if the
namespace node is created using <xsl:copy/> or
<xsl:copy-of/>.

This should not fail, because technically according to
the specification, a prefix for the element name is
only created at serialization time (or namespace fixup
time in XSLT 2.0), in other words no prefix for element
<{nsone.uri}e> should be allocated until the namespace
node has been successfully created.

The error message is "Cannot create two namespace nodes
with the same name".

Applies to 7.2, 6.5.2, and all earlier releases.

Test cases: nspc39, nspc40

Discussion

  • Michael Kay
    Michael Kay
    2002-11-12

    Logged In: YES
    user_id=251681

    The example is incorrect, because literal result elements
    are required to copy their namespace nodes. The following
    example illustrates the problem with 6.5.2:

    <xsl:element name="ns:e" namespace="nsone.uri">
    <xsl:copy-of select="doc/namespace::ns"/>
    </xsl:element>

    Here the "ns" prefix in xsl:element is only a suggested
    prefix, it should not be used in the result tree until it is
    known that the prefix is not being used for a different purpose.

    Source code fixed in 7.x branch.

    A fix for 6.5.x will be more difficult and I might not
    attempt it: it isn't worth risking destabilising the code
    for such an obscure problem.

     
  • Michael Kay
    Michael Kay
    2002-11-18

    Logged In: YES
    user_id=251681

    Fixed in 7.3