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

Re: How to create variable element from a couple of st

Subject: Re: How to create variable element from a couple of strings
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 24 May 2001 00:19:48 -0700 (PDT)
xsl create variable
Hi Yang,

While you cannot do this with a xsl:variable -- you could create a xsl:variable (but
with another prefix) in a stylesheet that will be the output of your transformation.

Another possibility for you is to create an RTF (put the output of the templates
you're calling into the contents of an xsl:variable) -- something like this:

<xsl:variable name="myVar">
  <xsl:call-template name="yourTemplate">
    <!-- Whatever xsl:with-param-s here-->
  </xsl:call-template>
</xsl:variable>

And, of course, in yourTemplate you should be using xsl:element (not xsl:variable)
to dynamically construct the desired nodes.

Then you'd use the nodes that were dynamically constructed for example like this:

<xsl:copy-of select="msxsl(or whatever):node-set($myVar)"/>


Cheers,
Dimitre Novatchev.

sfyang@xxxxxxxxxxxxx wrote:

Hi, all

I want to set up a set of variable elements  from  two given strings,
(**string** - for variable value  and   **vname** - for variable name )

   <variable name="x1" select="a"/>
   <variable name="x2" select="b"/>
   ...

I am using recursive method to extract each pair value successfully.
However when I add variable statement I get the error of
                Required attribute 'name' is missing'

from mxxml 3 parser.

**xslt listing **

<?xml-stylesheet href="decompose.xsl" type="text/xsl"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<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:call-template name="decompose">
<xsl:with-param name="s" select="$string"/>
<xsl:with-param name="nx" select="$vname"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="decompose">
<xsl:param name="s" />
<xsl:param name="nx" />
<xsl:if test="string($s)" >
<xsl:value-of select="substring-before($nx,',')"/>
<xsl:value-of select="substring-before($s,',')"/>

<!-- following variable element causes error messages -->
<xsl:variable>
<xsl:attribute name="name"><xsl:value-of
select="substring-before($nx,',')"/>
</xsl:attribute>
<xsl:value-of select="substring-before($s,',')"/>
</xsl:variable>

<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:stylesheet>

Thanks in advance for any help.

Sun-fu Yang

sfyang@xxxxxxxxxxxxx





__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

 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.