Subject: Re: [xsl] Keeping a map in my XSL From: andrew welch <andrew.j.welch@xxxxxxxxx> Date: Tue, 13 Sep 2005 19:40:26 +0100 |
On 9/13/05, Nathan Young (natyoung) <natyoung@xxxxxxxxx> wrote: > Hi. > > Kevin, I've done something like what you want to do using the document > function and xpaths. I agree with Andrew's suggestion about not relying > on document order to associate key/value pairs, but we have values that > can contain elements so we use something more like: > > <map> > <key name="1">value of name 1</key> > <key name="7">value of name 7</key> > </map> > > That's in a separate file from the xsl (say map.xml). > > Then in the xsl you can use: > > <xsl:variable name="map" select="document('map.xml')"/> > > To get then value for 1 you can use: > > <xsl:value-of select="$map//key[@name='1']/> > > Andrew would your xsl:key solution apply to this? If so how? Sure, define the key: <xsl:key name="mappings" match="key" use="@name"/> then: <xsl:for-each select="$map"> <xsl:value-of select="key('mappings', '1')"/> </xsl:for-each>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Keeping a map in my XSL, Nathan Young \(natyo | Thread | RE: [xsl] Keeping a map in my XSL, Kevin L. Cobb |
RE: [xsl] Is it possible to modify , Michael Kay | Date | Re: [xsl] Is it possible to modify , Jon Gorman |
Month |