Subject: Re: parametrized return values in recursive functions?
From: himanshu padmanabhi <himanshu.padmanabhi@xxxxxxxxx>
Date: Tue, 7 Apr 2009 12:35:38 +0530
|
Thank you very very much Mukul.
This is what I was exactly looking for.
Regards,
Himanshu Padmanabhi.
On Sun, Apr 5, 2009 at 8:15 PM, Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote:
>
> 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) ]
> > $value = --name httpd
> > $args1 = acd anadrom bcd cccd ddr gcd httpd iscsi .... xine
> >
> > Output
> >
> > '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
>
--
---------------------------------
Thanks and Regards,
Himanshu Padmanabhi
|