|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: comparison of attribute values
Hello J.Pietschmann,
your stylesheet looks a bit more than buggy ;-) key('fee-currency') is not possible and the Muenchian Method for grouping is missing. Hello John, here is my stylesheet: <xsl:key name="fee-currency" match="fee" use="@currency"/> <xsl:template match="fees"> <xsl:variable name="unique-currencies" select="*/fee[count( . | key('fee-currency', @currency)[1]) = 1]"/> <table border="1"> <tr> <td>fee</td> <xsl:for-each select="$unique-currencies"> <td><xsl:value-of select="@currency"/></td> </xsl:for-each> </tr> <xsl:for-each select="*/fee"> <tr> <td><xsl:value-of select="@name"/></td> <xsl:variable name="this-fee" select="."/> <xsl:for-each select="$unique-currencies"> <td> <xsl:value-of select="$this-fee[@currency = current()/@currency]/amount"/> </td> </xsl:for-each> </tr> </xsl:for-each> <tr> <td>total</td> <xsl:for-each select="$unique-currencies"> <td><xsl:value-of select="/fees/total[@currency = current()/@currency]"/></td> </xsl:for-each> </tr> </table> </xsl:template> Note: I used the suggestion with <fee name="fee1"/>. So the XML looks like: <fees>
<basic-fees>
<fee name="fee1" currency="USD"><amount>20</amount></fee>
<fee name="fee2" currency="EUR"><amount>25</amount></fee>
</basic-fees>
<special-fees>
<fee name="fee3" currency="EUR"><amount>20</amount></fee>
</special-fees>
<total currency="USD">65</total>
</fees>Result: <table border="1">
<tr>
<td>fee</td>
<td>USD</td>
<td>EUR</td>
</tr>
<tr>
<td>fee1</td>
<td>20</td>
<td></td>
</tr>
<tr>
<td>fee2</td>
<td></td>
<td>25</td>
</tr>
<tr>
<td>fee3</td>
<td></td>
<td>20</td>
</tr>
<tr>
<td>total</td>
<td>65</td>
<td></td>
</tr>
</table>For more information on Muenchian Method have a look at http://www.jenitennison.com/xslt/grouping/muenchian.xml. Regards, Joerg J.Pietschmann wrote: jdunning wrote: XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








