* Zachary Turner wrote in comp.text.xml:
>Let's say I have a variable defined as follows:
>
><xsl:variable name="test_variable_1" value="'test_value_A'"/>
><xsl:variable name="test_variable_2" value="'test_value_B'"/>
><xsl:variable name="test_variable_3" value="'test_value_C'"/>
This is not a good idea. I would recommend to use something like
<my:map xmlns:my='http://example.org/...'>
<my:item key='1' value='test_value_A' />
<my:item key='2' value='test_value_B' />
...
>Then, somewhere else in my source document I have some elements like
>this:
>
><some-doc-element param="2"/>
><some-doc-element param="3"/>
><some-doc-element param="1"/>
>
>I want to transform this into the following:
>
><destination-element value="'test_value_B'"/>
><destination-element value="'test_value_C'"/>
><destination-element value="'test_value_A'"/>
.... then you can simply use something like
...
<xsl:variable name='param' select='@param' />
<destination-element value="{
document('')//my:map/my:item[ @key = $param ]/@value
}"/>
...
The document('') refers to the XSLT document, then it looks up the map
in it based on the key (the param attribute) and uses the value of the
value attribute in the map in the output.
>3) Retrieve the 'value' parameter of the variable determined in #2.
That is not possible using only XSLT 1.0 features, and poor design.
--
Björn Höhrmann · private.php?do=newpm&u= ·
http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 ·
http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 ·
http://www.websitedev.de/