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