Subject: Re: Transforming text into a variable name From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 02 Nov 1999 19:32:44 -0800 |
Is there a way in XSLT to transform a attribute text value to a variable name.
For Example:
<search title="Search for record" var="test">
In the XSL I want to transform 'test' to the equivalent of <xsl:value-of select="$test"/>
T:\sanders>type sanders.xml <?xml version="1.0"?> <test> <search title="Search for record" var="test1"/> <search title="Search for another" var="test2"/> </test>
T:\sanders>type sanders.xsl <?xml version="1.0"?> <!DOCTYPE xsl:stylesheet [<!ENTITY nl "
">]> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:variable name="test1">Value of first variable</xsl:variable> <xsl:variable name="test2">Value of second variable</xsl:variable>
<xsl:template match="/"> <result> <xsl:apply-templates/> </result> </xsl:template>
<xsl:template match="search"> <!--go to the stylesheet file and find the top-level variable declaration whose name attribute is equal to the current node's var attribute--> <xsl:value-of select="@title"/>: '<xsl:value-of select="document('')/*/xsl:variable[@name=current()/@var]"/>' </xsl:template>
T:\sanders>xt sanders.xml sanders.xsl <result> Search for record: 'Value of first variable'
</result> T:\sanders>
-- G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) Web site: XSL/XML/DSSSL/SGML services, training, libraries, products. Practical Transformation Using XSLT and XPath ISBN 1-894049-02-0 Next instructor-led training: 1999-11-08, 1999-11-09, 1999-12-05/06, - 1999-12-07, 2000-02-27/28, 2000-05-11/12, 2000-05-15
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Transforming text into a variable n, Scott Sanders | Thread | RE: server side xml/xsl parsing, Linda van den Brink |
Re: Dependency Sorting, first of ki, James Clark | Date | Re: XML/XSL on the client for dynam, James Clark |
Month |