This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Variable names *as* variables
- To: xsl-list at mulberrytech dot com
- Subject: Variable names *as* variables
- From: "John E. Simpson" <simpson at polaris dot net>
- Date: Thu, 12 Oct 2000 12:23:06 -0400
- Reply-To: xsl-list at mulberrytech dot com
I have a feeling that what I'm trying to do can't be done without
extensions, like Saxon's eval. Unfortunately I can't use an extension
function for this case, and thought I'd fly it past the list to see if any
of you have a brainstorm.
Sample XML:
<someroot>
<event date="2000-10-11">
<locale place="location1"/>
<locale place="location2"/>
<locale place="location3"/>
</even>
<event date="2000-10_12">
<locale place="location1"/>
<locale place="location3"/>
</even>
</someroot>
If I want to display literal text (e.g. "Midtown" for place="location1"), I
could of course use an xsl:choose block, with an xsl:when for each of the
valid values of the place attribute. What I'd like to do instead (for
maintainability, whatever) is set up global variables to be used in place
of the values of the place attributes. Something like:
<xsl:variable name="location1">Midtown</xsl:variable>
<xsl:variable name="location2">Greater Northeast</xsl:variable>
<xsl:variable name="location3">Dallas-Ft. Worth</xsl:variable>
Then in the template (so goes the theory) I'd just need to do something like:
<xsl:value-of select="concat('$', @place)"/>
But -- duh -- all this does is produce the *string* "$location1,"
"$location2," and "$location3."
Any ideas? Can't be done with straight XSLT, right?
===============================================================
John E. Simpson | "He asked me if I knew what
http://www.flixml.org | time it was. I said, 'Yes, but
XML Q&A: http://www.xml.com | not right now.'" (Steven Wright)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list