|
Subject: [xsl] XSL String Mapping Problem. From: "Jos van Roosmalen" <jos.v.roosmalen@xxxxxxxxx> Date: Wed, 10 Dec 2008 11:20:54 +0100 |
Hello,
I am looking for a very nice mapper "Design Pattern".
I used the XML/XSL snippet below. However the "@key eq ." seems not to work.
If I introduce a variable it works fine:
<xsl:variable name="var" select="."/>
<xsl:value-of select="$map[@key eq $var]/@val"/>
Questions:
1. How to get this mapper working without variable?
2. What is the the 'defacto XPath standard' for mapping a list
hardcoded keys to hardcoded values?
Thanks, Jos
<demos>
<demo><keyAttr>key1</keyAttr></demo>
<demo><keyAttr>key2</keyAttr></demo>
</demos>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:variable name="map" as="element()+">
<elem key="key1" val="value1"/>
<elem key="key2" val="value2"/>
<elem key="key3" val="value3"/>
</xsl:variable>
<xsl:template match="demos/demo">
Found key: <xsl:value-of select="."/>
Corresponding value: <xsl:value-of select="$map[@key eq .]/@val"/>
<br/>
</xsl:template>
</xsl:stylesheet>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re[2]: [xsl] Trying to avoid quirks, Arthur Maloney | Thread | RE: [xsl] XSL String Mapping Proble, Michael Kay |
| Re: [xsl] Trying to avoid quirks mo, Andrew Welch | Date | RE: [xsl] XSL String Mapping Proble, Michael Kay |
| Month |