Subject: RE: [xsl] Replacing <break> tag when not followed by line feed ch aracter From: Cams Ismael <Ismael.Cams@xxxxxxxxxxxxxxx> Date: Thu, 5 Dec 2002 11:36:19 +0100 |
Hello Jarno, this works. Thanks ! Regards, Ismaël -----Original Message----- From: Jarno.Elovirta@xxxxxxxxx [mailto:Jarno.Elovirta@xxxxxxxxx] Sent: donderdag 5 december 2002 11:21 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Replacing <break> tag when not followed by line feed character Hi, > I have following xml file > <root> > <long>This is a very <break/> > very long text. > </long> > <root> > > What I want to do is replace every </break> tag and linefeed > by \n\, except > when the </break> tag is followed by a linefeed (as in the > example). Than I > only want one \n\ instead of 2. What I have no is a replace > function for the > linefeeds and a template match for the break tags. What I > like to do is in > the template match defining when this node is is followed by > a linefeed it > shouldn't be replaced by \n\. Is this somehow possible ? <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="long"> <xsl:apply-templates select="node()" mode="replace" /> </xsl:template> <xsl:template match="break" mode="replace"> <xsl:if test="not(following::node()[1][self::text() and starts-with(., '
')])">\n\</xsl:if> </xsl:template> <xsl:template match="text()" name="replace" mode="replace"> <xsl:param name="text" select="." /> <xsl:choose> <xsl:when test="contains($text, '
')"> <xsl:value-of select="substring-before($text, '
')" /> <xsl:text>\n\</xsl:text> <xsl:call-template name="replace"> <xsl:with-param name="text" select="substring-after($text, '
')" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text" /> </xsl:otherwise> </xsl:choose> </xsl:template> Or something in those lines, -- Jarno - Grendel: Human Saviour XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] sequential navigation pro, Michael Kay | Thread | [xsl] name of attributes like name(, Georges Schmitz |
RE: [xsl] using xsl:if to test the , Michael Kay | Date | RE: [xsl] Passing params to XSLT fr, Michael Kay |
Month |