|
Subject: Re: [xsl] Group by Element based on Attribute inside container using 1.0 From: Michael Ludwig <mlu@xxxxxxxxxxxxx> Date: Thu, 06 Nov 2008 19:29:44 +0100 |
I am using 1.0 and can not use 2.0. [...] I can not alter the XML output/format.
The verbosity and redundancy of the XML vocabulary you have to deal with makes this a bit tedious.
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="valves-by-number" match="ObjectClassField[ @name = 'Valve Number']" use="."/>
<xsl:key name="inspections-by-valve-number"
match="GeodatabaseRelationships/ObjectClass/ObjectClassRows/ObjectClassRow" use="ObjectClassField[ @name = 'Valve Number']"/>
<xsl:template match="/">
<xsl:for-each select="
/*/*/GeodatabaseRelationships
//ObjectClassField[ @name = 'Valve Number']">
<xsl:sort select="." data-type="number"/>
<xsl:if test="
generate-id() =
generate-id( key( 'valves-by-number', .)[1])">
<xsl:text>Valve Number: </xsl:text>
<xsl:value-of select="."/>
<xsl:text> </xsl:text>
<!-- inspections -->
<xsl:for-each select="key( 'inspections-by-valve-number', .)">
<xsl:sort select="concat(
substring( ObjectClassField[ @name = 'Date Inspected'], 6, 4),
substring( ObjectClassField[ @name = 'Date Inspected'], 1, 2),
substring( ObjectClassField[ @name = 'Date Inspected'], 4, 2))"/>
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:template><xsl:template match="ObjectClassRow"> <!-- Extend this to display more information. --> <xsl:value-of select="ObjectClassField[ @name = 'Date Inspected']"/> <xsl:text> </xsl:text> </xsl:template>
I would be nice to be able to use a variable in the xsl:sort that rearranges the date as in:
<xsl:variable name="d" select="ObjectClassField[ @name = 'Date Inspected']"/> <xsl:sort select="concat( substring( $d, 6, 4)), ... "/>
But that is not possible. If MSXML for IE6 has EXSLT or another extension function facility, you could use that to write a function to rearrange the date and then sort by select="my:iso-date( $d)".
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Group by Element based on Att, Friend, Darris E | Thread | Re: [xsl] Group by Element based on, Friend, Darris E |
| Re: [xsl] Image overflow in FOP, Sebastien | Date | Re: [xsl] floor() and idiv, mozer |
| Month |