Thanks David. That does solve the duplicate problem, but also leaves
off the second cite element:
there was the obvious bug of course that I wrote following instead of
preceding, and also you need to proceed teh cite always not just in the
case that there is a .
so that would be
<xsl:template match="text()[preceding-sibling::node()[1][self::cite]]">
<xsl:choose>
<xsl:when test="substring(.,1,1) = '.'">
<xsl:text>.</xsl:text>
<xsl:apply-templates select="preceding-sibling::cite[1]" mode="clean"/>
<xsl:copy-of select="substring(.,2)"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="preceding-sibling::cite[1]" mode="clean"/>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
However that still isn't really right as picking up on the text node
following the only works if there is such a text node, it fails if the
cite node is the last child or if it's followed by something other than
text)
so...
<sect>
<p>Some text and more text <cite/>. Some <em>more</em> text. Some text
and more text <cite/>.ffff<cite/></p>
<p>Some text and more text <cite/><em>. Some more</em> text. Some text
and more text <cite/>.ffff<cite/></p>
</sect>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:bib="http://www.example.org" version="2.0"
exclude-result-prefixes="bib">
<xsl:template match="sect">
<div>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="em">
<EM>
<xsl:apply-templates/>
</EM>
</xsl:template>
<xsl:template match="cite" mode="clean">[XXX<xsl:number/>]</xsl:template>
<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>
</xsl:stylesheet>
$ 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>
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
--~------------------------------------------------------------------
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>
--~--