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>
</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