|
Subject: Re: [xsl] parametrized return values in recursive functions? From: himanshu padmanabhi <himanshu.padmanabhi@xxxxxxxxx> Date: Sun, 5 Apr 2009 16:40:05 +0530 |
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.
On Fri, Apr 3, 2009 at 9:00 PM, Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote:
> It would help us to understand the problem, if you could please post a
> sample input and the required output.
>
> Are you using XSLT 1.0 or 2.0? Which XSLT processor are you using?
>
> On Fri, Apr 3, 2009 at 5:56 PM, himanshu padmanabhi
> <himanshu.padmanabhi@xxxxxxxxx> wrote:
>>
>> Thanks a ton for all that.
>>
>> <xsl:template match="Services">
>> <xsl:param name="flag" />
>> <tr><td>
>> <select name="args1">
>>
>> <!--
>> "$value" will contain '--name servicename1'.
>>
>> "$args1" will contain list of all service names SEPARATED BY SPACE
>> obv. including 'servicename1'.
>>
>> so this portion will only print 'servicename1' in combo eliminating
>> '--name' with help of 'flag' condition.
>>
>> I want to capture 'servicename1',so that I can pass it to next
>> tokenize which print all other service names
>>
>> from combo index 1 onwards(0th being 'servicename1').Passing parameter
>> as 'servicename1' will exclude
>>
>> it printing twice in this tokenize
>> -->
>> <xsl:if test="$value">
>> <xsl:call-template name="str:tokenize">
>> <xsl:with-param name="args" select="$value" />
>> <xsl:with-param name="flag" select="1" />
>> </xsl:call-template>
>> </xsl:if>
>> <xsl:call-template name="str:tokenize">
>> <xsl:with-param name="args" select="$args1"/>
>> <xsl:with-param name="flag" select="0" />
>> </xsl:call-template>
>> </select>
>> <td><tr>
>> </xsl:template>
>>
>> <!-- string tokenize function -->
>> <xsl:template name="str:tokenize">
>> <xsl:param name="args" select="$args" />
>> <xsl:param name="delimiters" select="' '" />
>> <xsl:param name="flag" select="$flag" />
>>
>> <xsl:call-template name="str:_tokenize-delimiters">
>> <xsl:with-param name="args" select="$args" />
>> <xsl:with-param name="delimiters" select="$delimiters" />
>> <xsl:with-param name="flag" select="$flag"/>
>> </xsl:call-template>
>> </xsl:template>
>>
>>
>> <xsl:template name="str:_tokenize-delimiters">
>> <xsl:param name="args"/>
>> <xsl:param name="delimiters"/>
>> <xsl:param name="pos" select="1"/>
>> <xsl:param name="flag" />
>>
>> <xsl:variable name="delimiter" select="substring($delimiters, 1, 1)"/>
>>
>> <xsl:variable name="left">
>> <xsl:choose>
>> <xsl:when test="not(contains($args,$delimiter))">
>> <xsl:value-of select="$args"/>
>> </xsl:when>
>>
>> <xsl:otherwise>
>> <xsl:value-of
select="substring-before($args,$delimiter)"/>
>> </xsl:otherwise>
>> </xsl:choose>
>> </xsl:variable>
>>
>> <xsl:variable name="right"
select="substring-after($args,$delimiter)"/>
>>
>> <xsl:if test="$left != ''">
>> <xsl:if test="not($flag = 1 and $pos = 1)">
>> <option pos="{$pos}"><xsl:value-of select="$left"/></option>
>> </xsl:if>
>> </xsl:if>
>>
>> <xsl:if test="$right != ''">
>> <xsl:call-template name="str:_tokenize-delimiters">
>> <xsl:with-param name="args" select="$right"/>
>> <xsl:with-param name="delimiters" select="$delimiters"/>
>> <xsl:with-param name="pos" select="$pos + 1"/>
>> <xsl:with-param name="flag" select="$flag" />
>> </xsl:call-template>
>> </xsl:if>
>> </xsl:template>
>>
-----------------------------------------------------------------------------
---------------------------------------
>> I tried using
>>
>> 1.
>>
>> <xsl:if test="$value">
>> <xsl:variable name="servname">
>> <xsl:call-template name="str:tokenize">
>> <xsl:with-param name="args" select="$value" />
>> <xsl:with-param name="flag" select="1" />
>> </xsl:call-template>
>> </xsl:variable>
>> </xsl:if>
>> <!-- and passing this variable to next tokenize call which will check
>> and wont double print it -->
>>
>> 2.
>> <xsl:call-template name="str:tokenize">
>> <xsl:with-param name="args" select="$value" />
>> <xsl:with-param name="flag" select="1" />
>> <xsl:with-param name="paramreturnvalue" />
>> </xsl:call-template>
>>
>> <!-- passing this param to every recursive call and filling this
>> parameter in the tokenize-delimiter template -->
>>
>> Both of these approaches didn't worked.
>> Can you tell me where I went wrong and which approach is better?
>>
>> On Thu, Apr 2, 2009 at 1:34 PM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
>> >
>> > > I just want to ask how to track "position" in recursive
>> > > functions like "str:_tokenize-delimiters"?
>> >
>> > Just give the function another argument, $position, and increment it by
one
>> > on each call.
>> >
>> > Michael Kay
>> > http://www.saxonica.com/
>> >
>
>> --
>> ---------------------------------
>> Thanks and Regards,
>> Himanshu Padmanabhi
>
>
>
> --
> Regards,
> Mukul Gandhi
>
>
--
---------------------------------
Thanks and Regards,
Himanshu Padmanabhi
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] parametrized return value, Mukul Gandhi | Thread | Re: [xsl] parametrized return value, Mukul Gandhi |
| Re: [xsl] Problem with <xsl:if>, Martin Honnen | Date | Re: [xsl] Problem with <xsl:if>, mozer |
| Month |