Re: [xsl] preceding/following character?

Subject: Re: [xsl] preceding/following character?
From: Bruce D'Arcus <bdarcus@xxxxxxxxx>
Date: Mon, 20 Jun 2005 08:55:47 -0400
On Jun 20, 2005, at 5:24 AM, David Carlisle wrote:

<xsl:template match="cite[not(following-sibling::node()[1][self::text()[starts- with(.,'.')]])]">
<xsl:apply-templates mode="clean" select="."/>
</xsl:template>


<xsl:template match="text()[preceding-sibling::node()[1][self::cite]][starts- with(.,'.')]">
<xsl:text>.</xsl:text>
<xsl:apply-templates select="preceding-sibling::cite[1]" mode="clean"/>
<xsl:copy-of select="substring(.,2)"/>
</xsl:template>

Cool; thanks! If I understand right, this has the advantage that it the separate templates makes it easier to use in the context of importing stylesheets.


$ saxon cite.xml cite.xsl
<?xml version="1.0" encoding="utf-8"?><div>
Some text and more text .[XXX1] Some <EM>more</EM> text. Some text
and more text .[XXX2]ffff[XXX3]

Some text and more text [XXX1]<EM>. Some more</EM> text. Some text
and more text .[XXX2]ffff[XXX3]
</div>

If I could just ask one more question: how conceptually would I then remove the preceding (now superfluous) space? Maybe use translate() to convert " ." to "."?


Bruce

Current Thread