xsl-list
[Top] [All Lists]

RE: Introducing a comma.

2003-11-18 12:46:07
I've got it now, that is to say, this template will put a comma after each 
instance of the <in> element except the last. That's not exactly how you stated 
the requirement, but it does exactly what your requirement expresses.

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output method="xml" indent="yes" encoding="UTF-8" />

  <xsl:template match="/signature">
    <signature>
      <xsl:apply-templates />
    </signature>
  </xsl:template>

  <xsl:template match="*">
    <xsl:copy-of select="." />
     <xsl:if test="name() = 'in' and following-sibling::*[name()= 
'in']">,</xsl:if>
  </xsl:template>

</xsl:stylesheet>
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     Ram <sram_30(_at_)yahoo(_dot_)com>
Sent:     Tue, 18 Nov 2003 09:09:31 -0800 (PST)
To:       XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  [xsl] Introducing a comma.

Hi,
Can anyone help me out in introducing a comma?
The xml source is:
<signature>signature <identifier>DNSQuery</identifier>
   <in>in<long>long</long><identifier>a</identifier></in>
   <in>in<string>string</string><identifier>b</identifier></in>
   <in>in<float>float</float><identifier>c</identifier></in>
</signature>

I've to introduce a comma between the first and second 'in',and between
the second and third 'in' but not after the third 'in'.

Thanks and regards,
Ram


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list