Hi Ryan,

First of all, you need an xsl:param element instead of an xsl:variable
element:

   <xsl:param name="TYPE"/>

If you want a default value, use the select attribute to set the value of
no param is passed in:

   <xsl:param name="TYPE" select="'default'"/>

Otherwise, the default is an empty string.  That's the only way to pass
parameters into a stylesheet.

Then, you must set the value correctly.  Since a param is an XPath
expression, and your stylesheet is expecting a string, you need to set it
appropriately:

   transformer->setStylesheetParam( "TYPE", "'Request'" );

You should avoid using this form for xsl:param and xsl:variable which are
used as strings, because it creates a result tree fragment:

   <xsl:variable name="TYPE">Request</xsl:variable>

This is fine if you really need an RTF, but is less efficient if you only
use the param or variable as a string.

Dave



                                                                                
                                         
                      Ryan Sawatzky                                             
                                         
                      <[EMAIL PROTECTED]         To:      
[email protected]                                     
                      ox.com>                  cc:      (bcc: David N 
Bertoni/Cambridge/IBM)                             
                                               Subject: XSLT Variables / 
Parameters                                      
                      03/26/2003 12:56                                          
                                         
                      PM                                                        
                                         
                                                                                
                                         



Hi everyone,

  Im trying to set a stylesheet variable through Xalan, but I can't seem
to get it to work.  When I specify the value of the variable in my
stylesheet I can use it just fine.

Here is my stylesheet ----
<?xml version='1.0'?>
<xsl:variable name="TYPE"></xsl:variable>

<xsl:template match="nletsContent">

<xsl:text>Type =  </xsl:text>
<xsl:value-of select="$TYPE"/>
......

Then in my code I have the following----
transformer->setStylesheetParam( "TYPE", "Request" );

And when I run it, My output is just
Type =
....

If I change the stylesheet to look like this ----
<?xml version='1.0'?>
<xsl:variable name="TYPE">Request</xsl:variable>

<xsl:template match="nletsContent">

<xsl:text>Type =  </xsl:text>
<xsl:value-of select="$TYPE"/>
......

Then it outputs----
Type = Request
.....

Does anyone have an idea why this wouldn't work?  Any help is appreciated.

Thanks,
Ryan



Reply via email to