xsl-list
[Top] [All Lists]

RE: Comma in between!

2004-09-13 04:52:20
Hi,

>
> I have this structure, where I need to insert a comma in
> between all <B>
> nodes and <C>. There can be one, two or three <B>s. The first <B> will
> always start at position 2. The number of nodes after <C> changes.
>
> <Root>
> <A>a</A>
> <B>b1</B>
> <B>b2</B>
> <B>b3</B>
> <C>c</C>
> <D>d</D>
> <E>e</E>
> <F>f</F>
> </Root>


With my little knowledge I can only think of following solution :-

<xsl:template match="/Root">
        <xsl:for-each select="child::B | child::C">
                <xsl:if test="position() > 1">
                        <xsl:text>, </xsl:text>
                </xsl:if>
                <xsl:value-of select="."/>
        </xsl:for-each>
</xsl:template>

Cheers.

Arun



From: "Michael Kay" <mhk(_at_)mhk(_dot_)me(_dot_)uk>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: RE: [xsl] Comma in between!
Date: Mon, 13 Sep 2004 12:04:37 +0100

<xsl:template match="B">
<xsl:value-of select="."/>
<xsl:text>, </xsl:text>
</xsl:template>

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Kenny Bogoe (BogoeMD) [mailto:kenny(_at_)bogoe(_dot_)com]
> Sent: 13 September 2004 10:22
> To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
> Subject: [xsl] Comma in between!
>
> Hi,
>
> I have this structure, where I need to insert a comma in
> between all <B>
> nodes and <C>. There can be one, two or three <B>s. The first <B> will
> always start at position 2. The number of nodes after <C> changes.
>
> <Root>
> <A>a</A>
> <B>b1</B>
> <B>b2</B>
> <B>b3</B>
> <C>c</C>
> <D>d</D>
> <E>e</E>
> <F>f</F>
> </Root>
>
> The result should be: b1, b2, b3, c
>
> And with this structure:
> <Root>
> <A>a</A>
> <B>b1</B>
> <C>c</C>
> <D>d</D>
> <E>e</E>
> </Root>
>
> the result should be: b1, c
>
> I really hope someone is able to help with this.
>
> Thanks a lot.
> Kenny Bogoe
>
>
>
>
> --+------------------------------------------------------------------
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
> --+--
>
>


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--


_________________________________________________________________
Is cricket your religion? Check out the cricket shop! http://www.msn.co.in/Shopping/CricketShop/ CDs, books ?n all things cricket!



<Prev in Thread] Current Thread [Next in Thread>