This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[XSL] sort element

 
Brian Grey
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic