This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re:Re:How tocreate variable element from a couple of strings


Hi, Dimitre

Using your second suggestion which employs RTF to wrap the contructed
xsl:element
I get some progress.  The hidden solution turns into a set of desired
variable element,

for example,   <xsl:variable name="x1" select="a"/>
               <xsl:variable name="x2" select="b"/>
                ..
Now I ask for a help so I am able to use $x1 and $x2 .. explicitly.
for example   <xsl:value-of select="$x1"/>.

Would you please point me some direction?

A xslt is fyi.

Thanks.

Sun-fu Yang

sfyang@unisvr.net.tw


<?xml-stylesheet href="decompose.xsl" type="text/xsl"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:msxsl="urn:schemas-microsoft-com:xslt" >
<xsl:output method="xml" indent="yes"/>
<xsl:param name="string" select="'a,b,c,d,e,f,'"/>
<xsl:param name="vname"  select="'x1,x2,x3,x4,x5,x6,'"/>

<xsl:template match="/">

<xsl:variable name="tempVar">
<xsl:call-template name="decompose">
<xsl:with-param name="s" select="$string"/>
<xsl:with-param name="nx" select="$vname"/>
</xsl:call-template>
</xsl:variable>
<xsl:copy-of select="msxsl:node-set($tempVar)"/>

<xsl:value-of select="$x1"/><====how to explicitly use x1 variable..etc.
</xsl:template>

<xsl:template name="decompose">
<xsl:param name="s" />
<xsl:param name="nx" />
<xsl:if test="string($s)" >

<xsl:call-template name="yourTemplate">
<xsl:with-param name="ss" select="substring-before($s,',')"/>
<xsl:with-param name="nnx" select="substring-before($nx,',')"/>
</xsl:call-template>

<xsl:call-template name="decompose">
<xsl:with-param name="s" select="substring-after($s,',')"/>
<xsl:with-param name="nx" select="substring-after($nx,',')"/>
</xsl:call-template>
</xsl:if>
</xsl:template>


<xsl:template name="yourTemplate">
<xsl:param name="ss" />
<xsl:param name="nnx" />
<xsl:element name="variable">
<xsl:attribute name="name"><xsl:value-of select="$nnx"/></xsl:attribute>
<xsl:attribute name="select"><xsl:value-of select="$ss"/></xsl:attribute>
</xsl:element>
</xsl:template>

</xsl:stylesheet>



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]