|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: recursive passing parameter
At 99/09/07 11:50 -0400, Honglin Su wrote:
I want the following stylesheet to produce an output like this:... ...<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"> <xsl:variable name="var" select="'init value ...'" /> <!-- process the children recursively --> <xsl:template match="*"> The variable value before passing is:: <xsl:value-of select="$var"/> <xsl:param name="var" select="name(.)"/> The variable value after passing is :: <xsl:value-of select="$var"/> <xsl:apply-templates/> </xsl:template> But the actually output is that every before passing value is 'init value ...". What's wrong with my stylesheet? The stylesheet is giving you what you are asking for because the scope of "$var" at the beginning of <xsl:template> is the globally scoped variable, not the locally scoped variable. Once you declare the $var within the template, subsequent references in that template are to that locally scoped variable. Perhaps your misunderstanding is the expectation that the value of the variable $var actually varies ... it does not vary. The <xsl:param> is declaring a variable and is supplying a default value to bind to that variable if the <xsl:apply-templates> or <xsl:call-templates> doesn't provide a <xsl:with-param> value as an overriding value to bind. Once a value is bound to the variable, it does not change. What you are seeing is a question of the scope of your variable reference, not an issue of variable values. I hope this helps. ............ Ken -- G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) Website: XSL/XML/DSSSL/SGML services, training, libraries, products. Practical Transformation Using XSLT and XPath ISBN 1-894049-01-2 Next instructor-led training: 1999-09-24, 1999-11-08, 1999-12-05/06, 1999-12-07, 2000-02-27/28, 2000-05-11/12 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








