Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] parametrized return values in recursive functions?

From: Mukul Gandhi <gandhi.mukul@--------->
To:
Date: 4/5/2009 2:47:00 PM
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent