File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes [XSL]  sort element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "[XSL]  sort element " Watch "[XSL]  sort element " New topic
Author

[XSL] sort element

Brian Grey
Ranch Hand

Joined: Nov 15, 2002
Posts: 43
I have to "sort" an XML using the following XSL. This XSL gets rid of the node characteristic of type SETTINGSET.


I was thinking to use xsl:sort. I found examples using values but none using nodes as criteria.

I have to move up the parm element just before the node characteristic.


current XSL
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" indent="yes"/>

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()[not(@type='SETTINGSET')]"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>



actual XML

<characteristic type="PXLOGICAL">
<characteristic type="PORT">
<parm name="PORTNBR" value="8080"/>
</characteristic>
<characteristic type="PXPHYSICAL">
<parm name="PXADDR" value="131.111.3.4"/>
<parm name="PXADDRTYPE" value="IPV4"/>
<parm name="TO-NAPID" value="Browsing_GPRS"/>
</characteristic>


<parm name="PROXY-ID" value="PROXY1"/>
<parm name="NAME" value="Proxy 1"/>


</characteristic>



Expected XML:

<characteristic type="PXLOGICAL">

<parm name="PROXY-ID" value="PROXY1"/>
<parm name="NAME" value="Proxy 1"/>

<characteristic type="PORT">
<parm name="PORTNBR" value="8080"/>
</characteristic>

<characteristic type="PXPHYSICAL">
<parm name="PXADDR" value="131.111.3.4"/>
<parm name="PXADDRTYPE" value="IPV4"/>
<parm name="TO-NAPID" value="Browsing_GPRS"/>
</characteristic>

</characteristic>

Edit Comment: Disabled smiles in the post.
[ April 02, 2005: Message edited by: Madhav Lakkapragada ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [XSL] sort element