Subject: Re: [xsl] Counting the number of matches From: mozer <xmlizer@xxxxxxxxx> Date: Thu, 10 May 2007 00:16:22 +0200 |
Spencer, In 2-pass If you do the processing, put the result in a variable, by reprocessing that variable you can do that Xmlizer
Hi List,
Please don't yell at me too much ;) I know variables can't be incremented and kinda have a vague idea that xslt processors don't neccessarly process templates in order, but I'm still wondering if something like this is possible.
I'm using 2.0, and want to get reference to a "hit" within a documents text for later use:
XSLT Snippet
<xsl:param name="search" select="''"/>
<xsl:template match="*"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template>
<xsl:template match="text()[contains(., $search)]"> <xsl:analyze-string select="." regex="{$search}(s|ing){{0,1}}"> <xsl:matching-substring> <font color="blue"><a hit="<!-- Something Here -->"/><xsl:value-of select="."/></font> </xsl:matching-substring> <xsl:non-matching-substring><xsl:value-of select="."/></xsl:non-matching-substring> </xsl:analyze-string> </xsl:template>
If $search was "foo" is there a way to get the a@hit attribute to contain the pseudo-position() of that hit in the document, no matter which level or element "foo" appears in?
so with XML Snippet
<?xml version="1.0"?> <root> <text>This is foo</text> <element> <sub>This is another foo<br/> and yet more foo galore</sub> <element> </root>
could get:
<?xml version="1.0"?> <root> <text>This is <a hit="1">foo</a></text> <element> <sub>This is another <a hit="2">foo</a><br/> and yet more <a hit="3">foo</a> galore</sub> <element> </root>
Thanks,
Spencer
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Counting the number of matche, Spencer Tickner | Thread | Re: [xsl] Counting the number of ma, David Carlisle |
[xsl] Counting the number of matche, Spencer Tickner | Date | Re: [xsl] Counting the number of ma, David Carlisle |
Month |