Hi.
I'm trying to sort a node by an attribute of it's last child.
The way I understand things, the following code SHOULD work, but it only sorts the nodes in the reverse order they were entered, and not by the date & time.
xsl template extract
Code:<xsl:template match="topic" mode="toc"> <xsl:apply-templates select="subject" mode="toc"> <xsl:sort select="message[last()]/@dd" data-type="number" order="descending"/> <xsl:sort select="message[last()]/@mm" data-type="number" order="descending"/> <xsl:sort select="message[last()]/@yyyy" data-type="number" order="descending"/> <xsl:sort select="message[last()]/@time" data-type="number" order="descending"/> </xsl:apply-templates> </xsl:template>
xml file extract
Code:<forum> <category name="Category 1 New new" dd="13" mm="11" yyyy="2002" time="15:57:42" type="c" id="1"> <topic name="New" description="Testing 55" username="ashleym" alias="Ashes" dd="13" mm="11" yyyy="2002" time="15:50:06" type="t" id="1"> <subject name="blah" username="ashleym" alias="Ashes" read="52" dd="13" mm="11" yyyy="2002" time="15:12:47" type="s" id="1"> <message username="ashleym" alias="Ashes" dd="13" mm="11" yyyy="2002" time="15:12:47" type="m" id="1">[}:)]</message> <message username="ashleym" alias="Ashes" dd="13" mm="11" yyyy="2002" time="15:12:58" type="m" id="2">hu????</message> <message username="ashleym" alias="Ashes" dd="13" mm="11" yyyy="2002" time="15:13:03" type="m" id="3">what?</message> <message username="ashleym" alias="Ashes" dd="13" mm="11" yyyy="2002" time="15:13:33" type="m" id="4">not you again</message> <message username="ashleym" alias="Ashes" dd="13" mm="11" yyyy="2002" time="15:51:06" type="m" id="5">Oh yes[;)]</message> <message username="ashleym" alias="Ashes" dd="14" mm="11" yyyy="2002" time="09:19:24" type="m" id="7">blah</message> <message username="ashleym" alias="Ashes" dd="14" mm="11" yyyy="2002" time="10:37:39" type="m" id="10">hey?</message> </subject> </topic> </category> </forum>
Sorry I don't really know how to explain this any better.
Any help will be appreciated.
Thanks




Reply With Quote