[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Keeping a map in my XSL
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>
|
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
|