cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William Brogden" <>
Subject RE: Cocoon reversing element attributes at output?
Date Wed, 25 Dec 2002 17:02:33 GMT
-----Original Message-----
From: Anna Afonchenko [] 
Sent: Wednesday, December 25, 2002 5:38 AM
To: cocoon-users
Subject: Cocoon reversing element attributes at output?

Hi All.
I am writing xsl file that will catch some nodes (according given XPath)
and will output these nodes
as a string.
Here is the code snippet that outputs the matching node:

<xsl:value-of select="concat(name(),' ')"/>
<xsl:for-each select="@*">
    <xsl:value-of select="name()"/>
    <xsl:value-of select="."/>
    <xsl:text>" </xsl:text>
So, if, for example, the node <img src="some.gif" alt=""/> is caught,
then it will be output as is.
When I was running this xsl using batch file, everything was OK.
Now I am running it using Cocoon, and although I get correct nodes
caught, for each node all attributes are output in the reverse order,
e.g. for the previous example the result in Cocoon is
<img alt="" src="some.gif"/>
This is not a disaster, but it is rather frustrating, because I would
want to copy this node and search it in the code, but if the attributes
are reversed, I wouldn't be able to do it.
Does anybody know why Cocoon reverses attributes order when outputting a
Thank you very much for help.

The SAX event for the start of an element carries attributes in an
collection. The JavaDocs say "the order of attributes in the list is
unspecified and may vary
from implementation to implementation."  Therefore you can't rely on the
being preserved.
Author of Soap Programming with Java - Sybex; ISBN: 0782129285
Coauthor of Cocoon 2 Programming - Sybex; ISBN: 0782141315


View raw message