Depending on your command line interpreter, you have to do different
things.  The first is that, if you want your params to be strings, you make
them strings:

   Xalan -p TITLE 'Bar' -o param.out param.xml param.xsl

Since some command line interpreters use ' as a special character, you may
need to escape it.  If you don't know how your command line interpreter
works, you should consult the documentation.  On Win32, for example, the
following:

   Xalan -p TITLE "'Bar'" -o param.out param.xml param.xsl

yields:

   Testing title for the value(Bar)

   Testing the title:  Foo
   Testing the title:  Bar

   Found the title you wanted!
   Testing the title:  Baz

I'm assuming using param.out as the stylesheet file is a typo...

Dave




                                                                                
                                                        
                      "Rachael                                                  
                                                        
                      Ludwick-Sandefer         To:      
<[email protected]>                                                  
                      "                        cc:      (bcc: David N 
Bertoni/Cambridge/IBM)                                            
                      <[EMAIL PROTECTED]         Subject: Stylesheet parameters 
                                                          
                      d.com>                                                    
                                                        
                                                                                
                                                        
                      12/11/2002 09:47                                          
                                                        
                      AM                                                        
                                                        
                                                                                
                                                        



I wanted to use XalanTransformer::setStylesheetParam in an application, but
I wanted to test out how it worked (i.e. how to indicate the param in the
stylesheet itself). I have this xml (param.xml)

<?xml version="1.0"?>
<books>
                                                 <title>Foo</title>
                                                 <title>Bar</title>
                                                 <title>Baz</title>
</books>

Being used with this stylesheet (param.xsl)

<xsl:stylesheet version = '1.0'
             xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
             <xsl:output method="text"/>

             <xsl:param name="TITLE"/>

             <xsl:template match="/">
                         <xsl:text>
Testing title for the value(</xsl:text><xsl:value-of
select="$TITLE"/><xsl:text>)

</xsl:text>
                         <xsl:apply-templates select="//title"/>
             </xsl:template>

             <xsl:template match="title">
<xsl:text>Testing the title:  </xsl:text><xsl:value-of
select="text()"/><xsl:text>
</xsl:text>
                         <xsl:if test="$TITLE = text()"><xsl:text>
Found the title you wanted!
</xsl:text>
                         </xsl:if>
             </xsl:template>
</xsl:stylesheet>

Using this command-line: Xalan -p TITLE Bar -o param.out param.xml
param.out

param.out looks like this:

Testing title for the value()

Testing the title:  Foo
Testing the title:  Bar
Testing the title:  Baz

I would expect that the value in the parenthesis to be Bar and to get a
match from the $TITLE = text() line, but I don't.

Am I just completely misunderstanding how this works? I couldn't find a bug
in bugzilla for this, so I'm guessing it's user error here, not Xalan. This
example is similar to an example given in an XSLT faq at: <
http://www.dpawson.co.uk/xsl/sect2/N5982.html#d5626e85>

Thanks,
Rachael
************************************************
No employee or agent is authorized to conclude any binding agreement on
behalf of MGB Ltd. with another party by email without express written
confirmation by MGB Ltd. officers.


Reply via email to