[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

"Dynamic" Variables in XSL

Subject: "Dynamic" Variables in XSL
From: Ronald Kent Gibson <Kent.Gibson@xxxxxxxxxxx>
Date: Fri, 21 Mar 2003 18:16:29 +0100
xsl dynamic variable
ear All

What I want to do is create a large number of variables, all with unique
names, I extract these names from an xml file each time I transfrom it with
my stylsheet. The varaible names comes from the parent node and the values
from an attribute of the child. 

After I construct this variable I will need to access it somehow, ie
$varaible, or key() or anything like this. 

I have experimented with key(), and trying to make dynamic variable and/or
parameter names with no luck. The only thing I have not tried is to
add nodes to the xml doc and then read them. I really do not want to write
to the XML document though.

The source below makes the following output:

name="nameA_begin" select="x"
name="nameB_begin" select="y"

The idea was to make a <xsl:variable name="nameA_begin" select="x/>
statment.

Does anyone have any clever ideas?


       <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">	
	<xsl:output method="text" encoding="Windows-1252" />	
	<xsl:template name="page" match = "/">		
		<xsl:for-each select="//token">			
			<xsl:text>name="</xsl:text>			
			<xsl:value-of select="name(parent::*)"/>

			<xsl:text>_begin</xsl:text>			
			<xsl:text>"</xsl:text>			
			<xsl:text> select="</xsl:text>			
			<xsl:value-of select="@bmacro"/>

			<xsl:text>"</xsl:text>			
			<xsl:text>&#xA;</xsl:text>		
		</xsl:for-each >	
	</xsl:template>
</xsl:stylesheet>

<?xml version="1.0"?>
<root>
	<nameA>      
		<token bmacro    = "x">      </token>
	</nameA>
	<nameB>      
		<token  bmacro    = "y">      </token>
	</nameB>
</root>

thanks a bunch,

kent


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.