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

Re: parametrized return values in recursive functions?

Subject: Re: parametrized return values in recursive functions?
From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
Date: Sun, 5 Apr 2009 20:15:51 +0530
Re:  parametrized return values in recursive functions?
Supposing, we have following input XML:

<conf>
  <value>--name httpd</value>
  <args1>acd anadrom bcd cccd ddr gcd httpd iscsi xine</args1>
</conf>

The stylesheet for the problem you described will be:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                       xmlns:str="http://exslt.org/strings"
		       exclude-result-prefixes="str"
                       version="1.0">

   <xsl:output method="html" indent="yes" />

   <xsl:template match="conf">
     <html>
       <head>
         <title/>
       </head>
       <body>
         <xsl:variable name="sel" select="str:tokenize(value, ' ')[2]" />
         <form action="someaction">
	   <select name="x">
             <xsl:for-each select="str:tokenize(args1, ' ')">
	       <xsl:choose>
	         <xsl:when test=". = $sel">
                   <option value="{.}"
selected="selected"><xsl:value-of select="." /></option>
	         </xsl:when>
		 <xsl:otherwise>
                   <option value="{.}"><xsl:value-of select="." /></option>
		 </xsl:otherwise>
	       </xsl:choose>
	     </xsl:for-each>
	   </select>
	 </form>
       </body>
     </html>
   </xsl:template>

</xsl:stylesheet>

I do not have the Perl:libXSLT processor with me. I tested the above
stylesheet with Xalan and the  EXSLT tokenize extension.

Please check if Perl:libXSLT supports this extension function.
Otherwise, you can write it yourself as a callable named template.

On Sun, Apr 5, 2009 at 4:40 PM, himanshu padmanabhi
<himanshu.padmanabhi@xxxxxxxxx> wrote:
> Extremely sorry.here it is.
>
> input
>
> [ both are space separated,so I need to first tokenize '$value' to get
'httpd',
> then tokenize '$args1' to display other elements(excluding httpd) ]
> B  $value = --name httpd
> B  $args1 = acd anadrom bcd cccd ddr gcd httpd iscsi .... xine
>
> Output
>
> B  'httpd' as the selected element in combo and other elements from
'$args1'.
>
> I am using XSLT 1.0 and XSLT processor as Perl:libXSLT.
>
> Thanks and Regards,
> Himanshu Padmanabhi.



--
Regards,
Mukul Gandhi

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-2013 All Rights Reserved.