in reply to Re: Push + variable argument
in thread Push + variable argument

I think you're mixing up syntax. From the documentation (modified):

my $results = $stylesheet->transform_file('abc.xml', arg => "$str");

Or more general:

transform_file(filename, %params);

The usage of the Xpath syntax is also explained in the documentation:

$stylesheet->transform($doc, param => "'string'");

Note the "' and '" !

And where does $str come from and what does it contain? Please put use strict; and use warnings; in your script.

Replies are listed 'Best First'.
Re^3: Push + variable argument
by himanshu.padmanabhi (Acolyte) on Feb 11, 2009 at 06:48 UTC
    Thank you very much all especially dHarry.Now it is working. $str comes from another cgi script and contains values separated by spaces.
    $str=$in{'values_separated_by_spaces'};
    I am getting values in $str and they are passed to XSL script using XPath mechanism as you told. I want to separate these space values in XSL script so to display individual ones.Can you tell how to do this?

      Do the separating in Perl (for example with the split statement) and pass the individual arguments/parameters to the XSLT. So something like:

      In the xslt:

      <xsl:param name="param_1"/> <xsl:param name="param_2"/>

      In the Perl script:

      my ($par1, $par2) = split (/ /,$str); my $results = $stylesheet->transform($source, XML::LibXSLT::xpath_to_string(param_1 => $par1), XML::LibXSLT::xpath_to_string(param_2 => $par2) );

      NB The utility function xpath_to_string takes care of the quoting. This is probably the better/easier way of doing things. See the documentation for details. See playing with XSLT for a bigger example.

Re^3: Push + variable argument
by himanshu.padmanabhi (Acolyte) on Feb 11, 2009 at 09:23 UTC
    <xsl:value-of select="substring-before($arg,' ')"/>
    I got this way of separating the values.Now looking for displaying them individually in COMBO box using "<xsl:for each>"