himanshu.padmanabhi has asked for the wisdom of the Perl Monks concerning the following question:
Actually I want that it should check '$in' hash.It contains '$in{args<number>}'.number is changing thing from 1 onwards.It should pass these '$in{args<number>}' variables to XSL file.#Defining objects for XML,XSLT. my $parser = XML::LibXML->new(); my $xslt = XML::LibXSLT->new(); #Parsing both files my $source = $parser->parse_file($xmlfile); # '$style_doc' represents 'XML::LibXML::Document' object representing +an XSLT file. my $style_doc = $parser->parse_file($xslfile); my $stylesheet = $xslt->parse_stylesheet($style_doc); # 'Transform' returns a scalar that is the XSLT rendering of the 'XML: +:LibXML::Document' object using the desired output format(specified i +n the xsl:output tag in the stylesheet) my $results = $stylesheet->transform($source, XML::LibXSLT::xpath_to +_string(args1=> "$in{'args1'}",args2=> "$in{'args2'}",args3=> "$in{'a +rgs3'}",idx => "$in{'idx'}",newperiod => "$in{'newperiod'}")); # IN ABOVE CASE,I DN'T WANT TO HARDCODE 'ARGS' LIKE 3 ABOVE.I AM GETTI +NG TOTAL NUMBER OF PARAMETERS IN VARIABLE.SO IF ARGS CAN BE 5 IN SOME + CASE,ABOVE LINE SHOULD BE LIKE THIS.. # my $results = $stylesheet->transform($source, XML::LibXSLT::xpath_to +_string(args1=> "$in{'args1'}",args2=> "$in{'args2'}",args3=> "$in{'a +rgs3'}",args4=> "$in{'args4'}",args5=> "$in{'args5'}",idx => "$in{'id +x'}",newperiod => "$in{'newperiod'}")); print $stylesheet->output_string($results);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: passing variable arguments to XSL from perl
by dHarry (Abbot) on Apr 07, 2009 at 11:27 UTC | |
by himanshu.padmanabhi (Acolyte) on Apr 08, 2009 at 05:20 UTC | |
|
Re: passing variable arguments to XSL from perl
by derby (Abbot) on Apr 07, 2009 at 11:11 UTC | |
|
passing variable arguments to XSLT
by Anonymous Monk on Apr 07, 2009 at 09:56 UTC | |
by jethro (Monsignor) on Apr 07, 2009 at 10:06 UTC |