Re: string concat with apply template

Discussion in 'XML' started by Martin Honnen, Mar 3, 2013.

  1. Philipp Kraus wrote:
    > Hello,
    >
    >
    > I have got two rules:
    >
    >
    > <xsl:templatematch="templateparamlist">
    > <xsl:for-eachselect="param">
    > <xsl:value-ofselect="concat(., ',')"/>
    > </xsl:for-each>
    > </xsl:template>
    >
    > <xsl:templatematch="templateparamlist/param">
    > <xsl:value-ofselect="replace(type, 'typename', '')"/>
    > <xsl:iftest="defname">
    > <xsl:text></xsl:text>
    > <xsl:value-ofselect="defname"/>
    > <xsl:iftest="defval">
    > <xsl:text>=</xsl:text>
    > <xsl:value-ofselect="defval"/>
    > </xsl:if>
    > </xsl:if>
    > </xsl:template>
    >
    >
    >
    > How can I do this?
    >
    > I need in the for-each concationation the call of the param node,
    >
    > so that I concat the result of the
    > <xsl:templatematch="templateparamlist/param">


    Either change the first template to do
    <xsl:apply-templates select="param"/>
    instead of the for-each and then in the second template use
    <xsl:templatte match="templateparamlist/param">
    add
    <xsl:if test="position() gt 1">,</xsl:if>
    and the beginning of the template or in the first template use
    <xsl:for-each select="param">
    <xsl:if test="position() gt 1">,</xsl:if>
    <xsl:apply-templates select="."/>
    </xsl:for-each>
     
    Martin Honnen, Mar 3, 2013
    #1
    1. Advertising

  2. On 2013-03-03 17:41:36 +0100, Martin Honnen said:

    > Philipp Kraus wrote:
    >> Hello,
    >>
    >>
    >> I have got two rules:
    >>
    >>
    >> <xsl:templatematch="templateparamlist">
    >> <xsl:for-eachselect="param">
    >> <xsl:value-ofselect="concat(., ',')"/>
    >> </xsl:for-each>
    >> </xsl:template>
    >>
    >> <xsl:templatematch="templateparamlist/param">
    >> <xsl:value-ofselect="replace(type, 'typename', '')"/>
    >> <xsl:iftest="defname">
    >> <xsl:text></xsl:text>
    >> <xsl:value-ofselect="defname"/>
    >> <xsl:iftest="defval">
    >> <xsl:text>=</xsl:text>
    >> <xsl:value-ofselect="defval"/>
    >> </xsl:if>
    >> </xsl:if>
    >> </xsl:template>
    >>
    >>
    >>
    >> How can I do this?
    >>
    >> I need in the for-each concationation the call of the param node,
    >>
    >> so that I concat the result of the
    >> <xsl:templatematch="templateparamlist/param">

    >
    > Either change the first template to do
    > <xsl:apply-templates select="param"/>
    > instead of the for-each and then in the second template use
    > <xsl:templatte match="templateparamlist/param">
    > add
    > <xsl:if test="position() gt 1">,</xsl:if>
    > and the beginning of the template or in the first template use
    > <xsl:for-each select="param">
    > <xsl:if test="position() gt 1">,</xsl:if>
    > <xsl:apply-templates select="."/>
    > </xsl:for-each>


    Thanks, that's easy

    Phil
     
    Philipp Kraus, Mar 3, 2013
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bruce Sam
    Replies:
    7
    Views:
    688
    John C. Bollinger
    Nov 9, 2004
  2. Stefan Siegl
    Replies:
    1
    Views:
    964
    Marrow
    Jul 18, 2003
  3. collinm

    Concat string (not ended ...)

    collinm, Mar 24, 2005, in forum: C Programming
    Replies:
    13
    Views:
    652
    Peter Shaggy Haywood
    Mar 30, 2005
  4. Raman

    String concat using Recursion

    Raman, Jan 23, 2007, in forum: C Programming
    Replies:
    13
    Views:
    1,305
    Richard Bos
    Jan 24, 2007
  5. Rodman S. Regier

    String length/concat problems in Ruby 1.8.0?

    Rodman S. Regier, Oct 9, 2003, in forum: Ruby
    Replies:
    1
    Views:
    196
    Harry Ohlsen
    Oct 9, 2003
Loading...

Share This Page