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

RE: Change the value of a parameter in a template

Subject: RE: Change the value of a parameter in a template
From: Ed Staub <estaub@xxxxxxxx>
Date: Mon, 13 Nov 2000 16:09:58 -0500
xsl param change value
You can't change the value of a parameter or variable.

xsl:param is only allowed at top-level or at the beginning of a template;
your usage is illegal.

If you want to get the result back from a template into a variable, emit the
result into the output stream within the template, and then use something
like:

<xsl:variable name="find">
	<xsl:call-template name="findRelation">
		<xsl:with-param name="article" select="$article"/>
	</xsl:call-template>
</xsl:variable>

See Michael Kay's "XSLT" book, around page 545 ("Computational
Stylesheets"); it covers this area very well.

-Ed Staub

-----Original Message-----
From: fredric larsson [mailto:fredric.larsson@xxxxxxxxxx]
Sent: Monday, November 13, 2000 10:52 AM
To: xsl-list@xxxxxxxxxxxxxxxx
Cc: mikael granhed
Subject: Change the value of a parameter in a template 


Hi.
I have got the same problem as Laurent has in his mail dated 6 Nov 2000
08:46:48 +0000 from e-mail address: "Ext.ZXSPRCR2A015@xxxxxxxxxx".
Here is my problem:
I want to compare XML-data with a value of a parameter in my XSL-stylesheet.
XML-data looks like this:

<wc:INSTANCE CLASS="Rel">
    <Left>id11</Left>
    <Right>id12</Right>
    <OBID>id1</OBID>
</wc:INSTANCE>
<wc:INSTANCE CLASS="Rel">
    <Left>id21</Left>
    <Right>id22</Right>
    <OBID>id2</OBID>
</wc:INSTANCE>

I've got a template, called "Relation", with two parameters:

<xsl:param name="article" select='OBID'/>
<xsl:param name="find"/>

I call a new template called "findRelation" and apply the parameters:

<xsl:call-template name="findRelation">
<xsl:with-param name="article" select="$article"/>
	<xsl:with-param name="find" select="$find"/>
</xsl:call-template>

In the template "findRelation" I compare the parameter "article" with the
XML-data in a loop ("for-each").
When an element, <Left>, is equal to the parameter "article" I store the
<Right> element in the parameter "find ": 

<xsl:template name="findRelation">
	<xsl:param name="article"/>
	<xsl:param name="find"/>
	<xsl:for-each select="//wc:INSTANCE"> 
		<xsl:if test="Left=$article">
			<xsl:param name="find" select='Right'/>		 
		</xsl:if>
	</xsl:for-each>
</xsl:template>			 

Then I want to access the parameter "find", with its new value, from the
calling template "Relation". 
Does anybody know how to do that? 
  
Regards
Fredric


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


 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.