Z
Zachary Turner
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'"/>
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'"/>
Essentially, this would consist of a couple steps:
1) Reading the value of the proper source element attribute
2) Programmatically create a string that specifies the name of the
variable to look up
3) Retrieve the 'value' parameter of the variable determined in #2.
4) Output the value determined in #3 to the document.
Step 3 is what I don't know how to do. I have the -name- of a
variable stored in the value of another variable, and I want to use
that variable to find the variable with that name.
Is something like this even possible? I can make a huge if statement
if necessary, but this seems more elegant, and easier to understand.
Thanks
<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'"/>
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'"/>
Essentially, this would consist of a couple steps:
1) Reading the value of the proper source element attribute
2) Programmatically create a string that specifies the name of the
variable to look up
3) Retrieve the 'value' parameter of the variable determined in #2.
4) Output the value determined in #3 to the document.
Step 3 is what I don't know how to do. I have the -name- of a
variable stored in the value of another variable, and I want to use
that variable to find the variable with that name.
Is something like this even possible? I can make a huge if statement
if necessary, but this seems more elegant, and easier to understand.
Thanks