N
noureensyed
Hi there,
Any ideas on how to sort an xml of the type below. I want to output the
exact same xml as well just sorted. However in my case I want to select
a particular column tag below, say "Last Name" and then sort all row by
the VALUE attribute of this particular column. So I have to first check
if the ID Attribute matches to my desired sort key and then sort
according to value.
....(more parent nodes here)
<ROW ID="0">
<COLUMN ID="Id" VALUE="2SIA-1772Z"></COLUMN>
<COLUMN ID="First Name" VALUE="Ed"></COLUMN>
<COLUMN ID="Last Name" VALUE="Holden"></COLUMN>
<COLUMN ID="Type" VALUE=""></COLUMN>
<COLUMN ID="Primary Specialty"
VALUE=""></COLUMN>
<COLUMN ID="Street Address" VALUE="1 Brookside
Ln."></COLUMN>
<COLUMN ID="City" VALUE="Salt Lake
City"></COLUMN>
<COLUMN ID="State" VALUE="UT"></COLUMN>
<COLUMN ID="Postal Code"
VALUE="84105"></COLUMN>
</ROW>
<ROW ID="1">
<COLUMN ID="Id" VALUE="2-AGN"></COLUMN>
<COLUMN ID="First Name" VALUE="Petra"></COLUMN>
<COLUMN ID="Last Name" VALUE="H?ndel"></COLUMN>
<COLUMN ID="Type" VALUE=""></COLUMN>
<COLUMN ID="Primary Specialty"
VALUE=""></COLUMN>
<COLUMN ID="Street Address" VALUE=""></COLUMN>
<COLUMN ID="City" VALUE=""></COLUMN>
<COLUMN ID="State" VALUE=""></COLUMN>
<COLUMN ID="Postal Code" VALUE=""></COLUMN>
</ROW>
<ROW ID="2">
<COLUMN ID="Id" VALUE="1-11G4"></COLUMN>
<COLUMN ID="First Name"
VALUE="Patricia"></COLUMN>
<COLUMN ID="Last Name" VALUE="Haas"></COLUMN>
<COLUMN ID="Type" VALUE=""></COLUMN>
<COLUMN ID="Primary Specialty"
VALUE=""></COLUMN>
<COLUMN ID="Street Address" VALUE=""></COLUMN>
<COLUMN ID="City" VALUE=""></COLUMN>
<COLUMN ID="State" VALUE=""></COLUMN>
<COLUMN ID="Postal Code" VALUE=""></COLUMN>
</ROW>
....
I have no clue on how to go about sorting this right now. My current
xsl looks like as below and simply returns the row nodes, with
immediate parent back to me. Which is what I want but with sorting, for
the new xml.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="DATATABLES/DATATABLE[@ID='TARGET']">
<xsl:apply-templates select="ROW"/>
</xsl:template>
<xsl:template match="ROW">
<xsl:copy-of select=".."/> <xsl:value-of select=".."/>
</xsl:template>
</xsl:stylesheet>
Thanks in advance.
Any ideas on how to sort an xml of the type below. I want to output the
exact same xml as well just sorted. However in my case I want to select
a particular column tag below, say "Last Name" and then sort all row by
the VALUE attribute of this particular column. So I have to first check
if the ID Attribute matches to my desired sort key and then sort
according to value.
....(more parent nodes here)
<ROW ID="0">
<COLUMN ID="Id" VALUE="2SIA-1772Z"></COLUMN>
<COLUMN ID="First Name" VALUE="Ed"></COLUMN>
<COLUMN ID="Last Name" VALUE="Holden"></COLUMN>
<COLUMN ID="Type" VALUE=""></COLUMN>
<COLUMN ID="Primary Specialty"
VALUE=""></COLUMN>
<COLUMN ID="Street Address" VALUE="1 Brookside
Ln."></COLUMN>
<COLUMN ID="City" VALUE="Salt Lake
City"></COLUMN>
<COLUMN ID="State" VALUE="UT"></COLUMN>
<COLUMN ID="Postal Code"
VALUE="84105"></COLUMN>
</ROW>
<ROW ID="1">
<COLUMN ID="Id" VALUE="2-AGN"></COLUMN>
<COLUMN ID="First Name" VALUE="Petra"></COLUMN>
<COLUMN ID="Last Name" VALUE="H?ndel"></COLUMN>
<COLUMN ID="Type" VALUE=""></COLUMN>
<COLUMN ID="Primary Specialty"
VALUE=""></COLUMN>
<COLUMN ID="Street Address" VALUE=""></COLUMN>
<COLUMN ID="City" VALUE=""></COLUMN>
<COLUMN ID="State" VALUE=""></COLUMN>
<COLUMN ID="Postal Code" VALUE=""></COLUMN>
</ROW>
<ROW ID="2">
<COLUMN ID="Id" VALUE="1-11G4"></COLUMN>
<COLUMN ID="First Name"
VALUE="Patricia"></COLUMN>
<COLUMN ID="Last Name" VALUE="Haas"></COLUMN>
<COLUMN ID="Type" VALUE=""></COLUMN>
<COLUMN ID="Primary Specialty"
VALUE=""></COLUMN>
<COLUMN ID="Street Address" VALUE=""></COLUMN>
<COLUMN ID="City" VALUE=""></COLUMN>
<COLUMN ID="State" VALUE=""></COLUMN>
<COLUMN ID="Postal Code" VALUE=""></COLUMN>
</ROW>
....
I have no clue on how to go about sorting this right now. My current
xsl looks like as below and simply returns the row nodes, with
immediate parent back to me. Which is what I want but with sorting, for
the new xml.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="DATATABLES/DATATABLE[@ID='TARGET']">
<xsl:apply-templates select="ROW"/>
</xsl:template>
<xsl:template match="ROW">
<xsl:copy-of select=".."/> <xsl:value-of select=".."/>
</xsl:template>
</xsl:stylesheet>
Thanks in advance.