|
Subject: [xsl] Difficulty with document() and for-each scope From: Adam Nielsen <adam.nielsen@xxxxxxxxx> Date: Mon, 16 Jun 2008 15:15:27 +1000 |
Many thanks, Adam.
<!-- Group items by numerical month (e.g. '02' in '2001-02-03') --> <xsl:key name="by-month" match="/items/item" use="substring(deadline, 6, 2)" />
<me:monthnames> <me:month>January</me:month> <me:month>February</me:month> <me:month>March</me:month> <me:month>April</me:month> <me:month>May</me:month> <!-- etc --> </me:monthnames>
<xsl:for-each select="document('')//me:month">
<xsl:variable name="month" select="format-number(position(), '00')"/> <ul>
<!-- This template never gets applied -->
<xsl:apply-templates select="key('by-month', $month)">
<xsl:sort select="deadline"/>
</xsl:apply-templates>
</ul> <ul>
<xsl:apply-templates select="key('by-month', '05')">
<xsl:sort select="deadline"/>
</xsl:apply-templates>
</ul><xsl:template match="item"> <li><xsl:value-of select="name"/>: <xsl:value-of select="deadline"/></li> </xsl:template>
--- begin loop.xml --- <?xml version="1.0" encoding="UTF-8" ?> <items>
<item>
<name>Item One</name>
<deadline>2008-01-01</deadline>
</item> <item>
<name>Item Two</name>
<deadline>2008-02-01</deadline>
</item> <item>
<name>Item Three</name>
<deadline>2008-05-03</deadline>
</item> <item>
<name>Item Four</name>
<deadline>2008-05-04</deadline>
</item>| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] a table-of-contents for X, Ivan Shmakov | Thread | Re: [xsl] Difficulty with document(, Abel Braaksma |
| Re: [xsl] a table-of-contents for X, Ivan Shmakov | Date | Re: [xsl] Difficulty with document(, Abel Braaksma |
| Month |