Subject: Re: [xsl] Using the key function From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Wed, 23 May 2007 15:55:44 +0200 |
My xsl code does work giving all the values under the house element as
well as some others, but I'm not able to get the length value from the
corresponding trail element. The trail element contains information
belonging to the house element and is associated by matching the ref and
id values. The only way I know how to do this is by using the key
function, but it's not working.
I can't easily change the group-by function because that is what is used in production and I can't change the "property[@name='number']/@val" because all the other elements (not shown) are grouped by this unique property except the trail element.
--- XSL ---
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="html"/>
<xsl:key name="numkey" match="//house" use="member/@ref"/>
<html>
<body>
<table ... (table format)
<xsl:for-each-group select="//project" group-
by="property[@name='number']/@val">
<xsl:sort select="@number"/>
<tr>
<td>
<xsl:value-of
select="current-grouping-
key()"/>
</td>
<td>
<xsl:value-of
select="@name"/>
</td>
<td>
<xsl:value-of
select="key('numkey',@id)/@length"/>
</td>
</tr>
</xsl:for-each-group>
</table>
</body>
</html>
</stylesheet>
<html> <body> <table> <tr> <td>123L0001</td> <td>1_CAD</td> <td>50.5</td> </tr> <tr> <td>123L0002</td> <td>2_CAB</td> <td>40.0</td> </tr> </table> </body> </html>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/"> <html> <body> <table> <xsl:for-each-group select="$input/project/house" group-by="property[@name='number']/@val">
<xsl:apply-templates select="." /> </xsl:for-each-group> </table> </body> </html> </xsl:template>
Cheers, -- Abel Braaksma
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Using the key function, David Carlisle | Thread | Re: [xsl] Using the key function, David Carlisle |
Re: [xsl] order as defined in the s, David Carlisle | Date | [xsl] Sorting help, Vandna Sharma |
Month |