Quick XSLT full-text search and replace?
This is an open discussion with 3 replies, filed under XSLT.
Search
@designermonkey - Have you tried phoque’s search and replace utility? Does that fully meet your criteria?
In the past have used EXSLT’s str:replace
template to replace many search strings at once. The great thing is that you can define a node-set of search/replace patterns like this:
<xsl:variable name="replacements"> <replacement search="&">&amp;</replacement> <replacement search="CO2">CO<sub>2</sub></replacement> </xsl:variable>
And then just call the template, passing the replacements as a param:
<xsl:call-template name="str:_replace"> <xsl:with-param name="string" select="your-text-node"/> <xsl:with-param name="replacements" select="exsl:node-set($replacements)/replacement"/> </xsl:call-template>
Thanks guys, I’ll check them both out!
Create an account or sign in to comment.
Has anyone got a quick method (using XSLT) of doing a search and replace on a body of text to pick out keywords, specified in the XML source, and wrap them in an element?
I’ve read that sometimes, wrapping keywords in your body text with the tag marks them as keywords for search engines.
I have a list of keywords to wrap, being output from a Tag List, and I was wondering if anyone has already done similar before I go re-invent the wheel.
Cheers in advance…