Subject: Re: replacing text in output
From: "andrew welch" <andrew.j.welch@xxxxxxxxx>
Date: Thu, 16 Mar 2006 10:34:12 +0000
|
On 3/16/06, garry@xxxxxxxxxxxxxxxxxxx <garry@xxxxxxxxxxxxxxxxxxx> wrote:
> The following template generates sql. However, there may or may not be
> commas at the end of each statement and this is throwing my database
> adapter off.
> ie. this may occur which throws an error - ,attribute,)
> I need to eliminate these trailing commas in the output. So far I am
> trying to use the replace() function but have had no luck. Is there an
> easy way to alter the output after the transform.
Nice stylesheet you have there.....
Replace:
<xsl:for-each select="CTfile/CTFpupilData/Pupil">
insert into studentdetails(
<xsl:if test="UPN"> upn,</xsl:if>
<xsl:if test="Surname"> surname ,</xsl:if>
<xsl:if test="Forename"> forename , </xsl:if>
[lots more of the same]
With templates:
<xsl:template match="...">
<xsl:text>insert into studentdetails( </xsl:text>
<xsl:for-each select="CTfile/CTFpupilData/Pupil/*">
<xsl:apply-templates select="."/>
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="UPN"> upn </xsl:template>
<xsl:template match="Surname"> surname </xsl:template>
<xsl:template match="Forename"> forename </xsl:template>
Hopefully you get the idea.
cheers
andrew
|