Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jdom/xalan changes attribute order

Status
Not open for further replies.

bettyboo1701

Programmer
Joined
Jul 6, 2004
Messages
3
Location
DE
Hello,

hope you can help,

we create a web application using xml+jdom+xslt


<node attribute1="this" attribute2="that" attribute3="something" attribute4="somethingelse">

how can we tell jdom that it has to keep this order?

as it has to create nodes on it's own, it mixes the attributes of the node, i.e.

<node attribute2="that" attribute4="somethingelse" attribute1="this" attribute3="something" >

any ideas??
bettina
 
In xml, attributes don't really have an order.
You might say that a 'brown-eyed handsome man' is the same as a 'handsome brown-eyed man'.
Nodes do have an order, (for example: in x-path expressions you can select the 'preceding nodes') so you might consider to use childnodes instead of attributes.
If order is that important I would add an attribute 'SerialNr' or whatever to this childnode, this is much easier to handle, and is indepedent of the actual order of the nodes in the xml file.

That leaves one qustion: is order that important in your case?
Usually, attributes are referred to by name, so order doesn't matter.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top