Subject: RE: [xsl] key() and document() - scoping problem? From: "Geert Josten" <geert.josten@xxxxxxxxxxx> Date: Wed, 20 Dec 2006 08:16:54 +0100 |
If you want the span elements to repeat by the number of option elements and not just one like here: > It looks to me as though you want: > > <span class="x"> > <xsl:value-of select="count(key('key2_1', 'general'))" /> > </span> <xsl:variable name="option-keys" > select="document(string($options))/options/option"> > <span class="y"> > <xsl:value-of select="count(key('key2_1', $option-keys))" > /> </span> > > Or something of that sort. > > It happens that keys can also take node sets as arguments to > provide multiple values at once. As you can see, this can be > useful. (I use a variable for clarity but you could just > throw the document() query straight into the call to key() if > you wanted.) You could do something like the following in XSLT 1.0 , but it is not very nice: Top-level: <xsl:variable name="this-document" select="/" /> <xsl:template ...> <span class="x"> <xsl:value-of select="count(key('key2_1', 'general'))" /> </span> <xsl:for-each select="document(string($options))/options/option"> <xsl:variable name="$option" select="." /> <span class="y"> <xsl:for-each select="$this-document"> <xsl:value-of select="count(key('key2_1', $option))" /> </xsl:for-each> </span> </xsl:for-each> </xsl:template> I put the option element in a variable to show how its value can be used as a parameter of the 2nd key function HTH! Kind regards, Geert Drs. G.P.H. Josten Consultant Daidalos BV Source of Innovation Hoekeindsehof 1-4 2665 JZ Bleiswijk Tel.: +31 (0) 10 850 1200 Fax: +31 (0) 10 850 1199 www.daidalos.nl KvK 27164984 De informatie - verzonden in of met dit emailbericht - is afkomstig van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] key() and document() - sc, Michael Kay | Thread | [xsl] Using XSLT 1.0 , I have tried, Robert.A Greene |
RE: [xsl] Using XSLT 1.0 , I have t, Brian Martinez | Date | Re: [xsl] What todo when execution , Abel Braaksma |
Month |