Subject: Re: [xsl] Markup a paragraph of text based on keywords From: David Carlisle <davidc@xxxxxxxxx> Date: Fri, 25 Aug 2006 14:36:45 +0100 |
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>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Markup a paragraph of text ba, andrew welch | Thread | Re: [xsl] Markup a paragraph of tex, andrew welch |
[xsl] Markup a paragraph of text ba, andrew welch | Date | Re: RE: [xsl] xslt performance issu, krzysztof |
Month |