• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSLT - how to tell do not sort in any order

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have following in my stylesheet.

When I parse thru' following via xalan coming with jdk any 1.4 version I always get attributes sorted. I do not want to sort. What <xsl: .....) command I can use not to sort.


<xsl:when test="contains(Status/@success,'false')">
<xsl:element name="error">
<xsl:attribute name="L">mee</xsl:attribute>
<xsl:attribute name="C">xxx</xsl:attribute>
<xsl:attribute name="A">blah</xsl:attribute>
</xsl:element>
</xsl:when>

Output of the parser is always

<error A="blah" C="xxx" L="mee"/>

But required output is

<error C="xxx" A="blah" L="mee">
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Order of attributes is not significant according to XML spec. So parsers are free to return them in any order (i.e behavior is parser specific) you cannot control that.

your application should not depend on the order of attributes

Hope that helps,
Rajagopal
[ January 18, 2006: Message edited by: Rajagopal Manohar ]
 
Marie
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I explain to the client the same. But client tells us the way the vendor has written the code they need to maintain the order.

Any ideas on changing the position of attributes?
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could write your own "super-XML" serializer that does allow the user to control the order of attributes. I would budget several months for somebody very familiar with the rules of XML to do that.

Or you could write a post-processor that reorders attributes just for the files you produce for this particular customer.

Unfortunately explaining to customers that they don't know what they are talking about is never an option.
reply
    Bookmark Topic Watch Topic
  • New Topic