Re: Cocoon reversing element attributes at output?

2002-12-28 Thread Steven Noels
Anna Afonchenko wrote:


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:textlt;/xsl:text
xsl:value-of select=concat(name(),' ')/
xsl:for-each select=@*
xsl:value-of select=name()/
xsl:text=/xsl:text
xsl:value-of select=./
xsl:text /xsl:text
/xsl:for-each
xsl:textgt;/xsl:text
 
So, if, for example, the node img src=some.gif alt=/ is caught, 
then it will be output as is.

Also, consider the use of an identity template and xsl:copy for such tasks:

http://www.dpawson.co.uk/xsl/sect2/identity.html
http://www.dpawson.co.uk/xsl/sect2/N1930.html

/Steven
--
Steven Noelshttp://outerthought.org/
Outerthought - Open Source, Java  XML Competence Support Center
Read my weblog at  http://radio.weblogs.com/0103539/
stevenn at outerthought.orgstevenn at apache.org


-
Please check that your question  has not already been answered in the
FAQ before posting. http://xml.apache.org/cocoon/faq/index.html

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail:   [EMAIL PROTECTED]




Cocoon reversing element attributes at output?

2002-12-25 Thread Anna Afonchenko



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:textlt;/xsl:text
xsl:value-of 
select="concat(name(),' ')"/
xsl:for-each 
select="@*"
 
xsl:value-of select="name()"/
 
xsl:text="/xsl:text
 
xsl:value-of select="."/
 
xsl:text" /xsl:text
/xsl:for-each
xsl:textgt;/xsl:text

So, if, for example, the node img 
src="" 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=""/
This is not a disaster, but it is rather 
frustrating, because I would want to copy this node and search it in the code, 
butif the attributes are reversed, I wouldn't be able to do 
it.

Does anybody know why Cocoon reverses attributes 
order when outputting a node?

Thank you very much for help.
Anna


RE: Cocoon reversing element attributes at output?

2002-12-25 Thread William Brogden
Title: Message



-Original Message-From: Anna 
Afonchenko [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 25, 
2002 5:38 AMTo: cocoon-usersSubject: 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:textlt;/xsl:text
  xsl:value-of 
  select="concat(name(),' ')"/
  xsl:for-each 
  select="@*"
   
  xsl:value-of select="name()"/
   
  xsl:text="/xsl:text
   
  xsl:value-of select="."/
   
  xsl:text" /xsl:text
  /xsl:for-each
  xsl:textgt;/xsl:text
  
  So, if, for example, the node img 
  src="" 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=""/
  This is not a disaster, but it is rather 
  frustrating, because I would want to copy this node and search it in the code, 
  butif the attributes are reversed, I wouldn't be able to do 
  it.
  
  Does anybody know why Cocoon reverses 
  attributes order when outputting a node?
  
  Thank you very much for help.
  Anna
  
  
  The 
  SAX event for the start of an element carries attributes in an 
  Attributes
  collection. The JavaDocs say "the order of attributes in the list 
  isunspecified and may vary
  from 
  implementation to implementation." Therefore you can't rely on the 
  order
  being preserved.
  
  [EMAIL PROTECTED]Author of Soap Programming with Java - 
  Sybex; ISBN: 0782129285Coauthor of Cocoon 2 Programming - Sybex; ISBN: 
  0782141315