This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: strange behaviour in Xalan
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] Re: strange behaviour in Xalan
- From: Dimitre Novatchev <dnovatchev at yahoo dot com>
- Date: Sat, 20 Oct 2001 07:12:52 -0700 (PDT)
- Reply-To: xsl-list at lists dot mulberrytech dot com
> <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?
Because your XSLT processor is buggy. An attribute node will be copied into the
current output destination only in case there is a still open element (copied)
there.
This is exactly the same as for xsl:attribute or xsl:copy.
In this specific case an XSLT processor must either signal the error (Saxon) or
ignore it silently (MSXML3). Copying an attribute to another element node is a bug.
> 2. Where does ' xmlns:xml="http://www.w3.org/XML/1998/namespace"; ' come
> from?
Every element node in a well-formed xml document has the "xml" namespace node.
However, it is "default" and need not be explicitly declared. Outputting it as a
namespace declaration may be considered as a bugette.
Cheers,
Dimitre Novatchev.
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list