Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

string concat with apply template

9 views
Skip to first unread message

Philipp Kraus

unread,
Mar 3, 2013, 10:41:52 AM3/3/13
to

Hello,


I have got two rules:


    <xsl:template match="templateparamlist">
       
<xsl:for-each select="param">
           
<xsl:value-of select="concat(., ',')" />
       
</xsl:for-each>
   
</xsl:template>

   
<xsl:template match="templateparamlist/param">
       
<xsl:value-of select="replace(type, 'typename', '')"/>
       
<xsl:if test="defname">
           
<xsl:text> </xsl:text>
           
<xsl:value-of select="defname"/>
           
<xsl:if test="defval">
               
<xsl:text>=</xsl:text>
               
<xsl:value-of select="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:template match="templateparamlist/param">


How can I do this?


Thanks


Phil

Martin Honnen

unread,
Mar 3, 2013, 11:41:36 AM3/3/13
to
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>


Philipp Kraus

unread,
Mar 3, 2013, 1:29:19 PM3/3/13
to
Thanks, that's easy

Phil

0 new messages