Subject: RE: Variable names *as* variables From: "Meltsner, Kenneth" <Kenneth.Meltsner@xxxxxx> Date: Thu, 12 Oct 2000 13:51:52 -0400 |
You could use an association list-like trick <xsl:variable name="location-list">'location1Miami/location2New York/location3Schenectady'</xsl:variable> <xsl:value-of select="substring-before(substring-after ($1, @place) , '/')" /> Warning: Hand-typed. Did not check. Ken -----Original Message----- From: John E. Simpson [mailto:simpson@xxxxxxxxxxx] Sent: Thursday, October 12, 2000 11:23 AM To: xsl-list@xxxxxxxxxxxxxxxx Subject: Variable names *as* variables 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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Variable names *as* variables, Paul Tchistopolskii | Thread | Re: Variable names *as* variables, David Carlisle |
SAX or DOM for XSLT, Phil Hobgen | Date | Concatenate element values based on, BC Huang |
Month |