On 8/25/06, David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
probably not terribly efficient but
$ saxon8 words1.xml wordlist.xsl
<?xml version="1.0" encoding="UTF-8"?><p>words <a>apple</a> words <a>juice,
orange</a> words apple</p>
David
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="p">
<p>
<xsl:apply-templates select="doc('wordlist.xml')/list/word[1]">
<xsl:with-param name="p" select="."/>
</xsl:apply-templates>
</p>
</xsl:template>
<xsl:template match="word">
<xsl:param name="p"/>
<xsl:choose>
<xsl:when test="following-sibling::word">
<xsl:apply-templates select="following-sibling::word[1]">
<xsl:with-param name="p" select="replace($p,.,concat('[',.,']'))"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="x">
<xsl:analyze-string select="replace($p,.,concat('[',.,']'))"
regex="\[(.*?)\]">
<xsl:matching-substring>
<a><xsl:value-of select="regex-group(1)"/></a>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:variable>
<xsl:apply-templates select="$x/node()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="a[not(preceding-sibling::a=.)]">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
Thanks, David. From your answer I know I'm not missing out on any
tricks, so I'm happy.
--~------------------------------------------------------------------
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>
--~--