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(_at_)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
--~------------------------------------------------------------------
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>
--~--