[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: passing parameters to XSL,what if no value in some

Subject: RE: passing parameters to XSL,what if no value in some cases
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 6 Mar 2009 09:38:59 -0000
RE:  passing parameters to XSL
I can't help with the first part, because you are using a programming
language and transformation API of which I have no knowledge.

But for the second part, your XSLT code can define a default value for a
stylesheet parameter

<xsl:param name="x" select="'****'"/>

and if you choose an appropriate default value, this ensures that you can
detect when no value is passed, by testing against the default value. (It
does allow the user to pass the default value explicitly, but that's good
design practice anyway.)

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: himanshu padmanabhi [mailto:himanshu.padmanabhi@xxxxxxxxx]
> Sent: 06 March 2009 09:28
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  passing parameters to XSL,what if no value in
> some cases
>
> First time,code will go to 'else' part,it again returns to
> this form and 'if' part executes.
>
> <CODE>
>         my $parser = XML::LibXML->new();
>         my $xslt = XML::LibXSLT->new();
>
>         my $source = $parser->parse_file($xmlfile);
>         my $style_doc = $parser->parse_file($xslfile);
>
>         my $stylesheet = $xslt->parse_stylesheet($style_doc);
>         if($in{'flag'} eq "2") {
>             my $results = $stylesheet->transform($source,
> XML::LibXSLT::xpath_to_string(args => "$in{'args'}",val =>
> "1",new => "$in{'new'}"));
>             print $stylesheet->output_string($results);
>         }else{
>             my $results = $stylesheet->transform($source,
> XML::LibXSLT::xpath_to_string(args => "",val => "3",new =>
> "$in{'new'}"));
>             print $stylesheet->output_string($results);
>         }
> </CODE>
>
> 1.In my 'else' above,I don't want to pass 'args'(can I do it?),
>
> 2.How can I check in my xsl file whether it is passed or not
> probably using some 'if' statement or something like this?
> <CODE>
>     <xsl:choose>
>     <xsl:when test="args_is_given">
>          <some code>
>     </xsl:when>
>     </xsl:choose>
> </CODE>
>
>
> -----------------------------
> Regards,
> Himanshu Padmanabhi

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.