|
Subject: [xsl] Sorting and re-ordering down a hierarchy From: "Cole, Chris" <chris.cole@xxxxxxxxxxxxxxxxxxxxx> Date: Fri, 18 Jul 2003 15:00:30 -0000 |
Hello,
I'm struggling to re-organise my node tree.
My tree is something like this:
<input>
<node>
<rank>2</rank>
<node>
<rank>88</rank>
</node>
<node>
<rank>7</rank>
</node>
<node>
<rank>66</rank>
</node>
</node>
<node>
<rank>1</rank>
<node>
<rank>3</rank>
</node>
<node>
<rank>2</rank>
</node>
<node>
<rank>1</rank>
</node>
</node>
</input>
I need to reorganise the nodes so that they are organised in number order
down the nodes within their tree, so the output should be like this:
<output>
<node>
<rank>1</rank>
<node>
<rank>7</rank>
</node>
<node>
<rank>66</rank>
</node>
<node>
<rank>88</rank>
</node>
</node>
<node>
<rank>2</rank>
<node>
<rank>1</rank>
</node>
<node>
<rank>2</rank>
</node>
<node>
<rank>3</rank>
</node>
</node>
</output>
I can sort one level by using the code below, but I'm struggling to find a
way to re-order the second level within the first level (and the third level
later).
<xsl:template match="/input">
<xsl:call-template name="ascending-numeric-sort-l1">
<xsl:with-param name="seqnuml1" select="node/rank"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="ascending-numeric-sort-l1">
<xsl:param name="seqnuml1"/>
<xsl:for-each select="$seqnuml1">
<xsl:sort select="." data-type="number" order="ascending"/>
<xsl:copy-of select="parent::node()"/>
</xsl:for-each>
</xsl:template>
Can anybody offer any advice please?
Thanks
Chris
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] how to set the bgcolor of, David Carlisle | Thread | Re: [xsl] Sorting and re-ordering d, David Carlisle |
| Re: [xsl] how to set the bgcolor of, David Carlisle | Date | Re: [xsl] Sorting and re-ordering d, David Carlisle |
| Month |