xsl-list
[Top] [All Lists]

Re: preceding/following character?

2005-06-20 05:55:47

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



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--