Subject: Re: [xsl] replacing text in output From: garry@xxxxxxxxxxxxxxxxxxx Date: Thu, 16 Mar 2006 12:12:55 -0000 (GMT) |
> 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. Fantastic, I tried the position() != last() thing but could not get the sequence right. This sorts it, thanks. regards garru
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] replacing text in output, andrew welch | Thread | [xsl] Porting own template language, Nils Kaiser |
RE: [xsl] Porting own template lang, Peter Flynn | Date | Re: [xsl] Porting own template lang, Nils Kaiser |
Month |