[xsl] strange behaviour in Xalan

Subject: [xsl] strange behaviour in Xalan
From: Jörg Heinicke <joerg.heinicke@xxxxxx>
Date: Sat, 20 Oct 2001 15:27:53 +0200
Hello,

on another list there was a question about deleting the root-element. One
reply suggested

<xsl:template match="boxes">
    <xsl:copy-of select="*|@*"/>
</xsl:template>

, which in my eyes can cause problems, if the root-element has attributes.
So I tested it with Xalan 2.2.D11. But I get a really strange output:

XML

<?xml version="1.0" encoding="UTF-8"?>
<boxes test="1">
  <box id="1234">
    <title>Ciao</title>
    <body>This is the body of the box</body>
  </box>
</boxes>

XSL

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
  <xsl:output indent="yes"/>
  <xsl:template match="boxes">
    <xsl:copy-of select="*|@*"/>
  </xsl:template>
</xsl:stylesheet>

Output

<?xml version="1.0" encoding="UTF-8"?>
<box xmlns:xml="http://www.w3.org/XML/1998/namespace"; test="1" id="1234">
  <title>Ciao</title>
  <body>This is the body of the box</body>
</box>

1. Why is the attribute test="1" not causing an error, but will be copied to
the new root-element?
2. Where does ' xmlns:xml="http://www.w3.org/XML/1998/namespace"; ' come
from?

Changing the XSL to <xsl:copy-of select="*"/> the output is like expected.
In my eyes this is more than obviously a bug, but maybe I'm wrong. What can
you say about that?

Joerg


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread