|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl:key on variable containing result of apply-tem
Jorge,
I mistyped your solution when I tried it first - sorry! After a good night's rest I tried it again and it works perfectly! Thank you, this had been a big help. Grainne. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://icl.com/saxon" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl saxon"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:key name="alphabetKey" match="newAlphabet" use="@col"/> <xsl:variable name="alphabet"> <xsl:apply-templates select="/test/alphabetList/alphabet" mode="loadList"/> </xsl:variable> <xsl:variable name="alphabet-exslNodeSet" select="exsl:node-set($alphabet)"/> <xsl:template match="numbers">
<xsl:for-each select="number">
<xsl:variable name="curPosition" select="position()"/>
<xsl:for-each select="$alphabet-exslNodeSet">
<!-- NB context changed to converted node set -->
<xsl:copy-of select="key('alphabetKey', $curPosition)"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template><xsl:template match="/"> <xsl:apply-templates select="test/numbers"/> </xsl:template> <xsl:template match="alphabet" mode="loadList">
<newAlphabet col="{@col}"><xsl:value-of select="."/></newAlphabet>
</xsl:template></xsl:stylesheet> >..<snip/>... > The key declaration must be then: > <xsl:key name="alphabets" match="alphabet" use="@col"/> > > And later the usage of key(): > <xsl:template match="numbers"> > <xsl:for-each select="number"> > <xsl:variable name="curPosition" select="position()"/> > <xsl:for-each select="$alphabet-exslNodeSet"> > <!-- context changed to converted node set --> > <xsl:copy-of select="key('myKey', $curPosition)"/> > </xsl:for-each> > </xsl:for-each> ></xsl:template> >...<snip/>... 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








