[Home] [By Thread] [By Date] [Recent Entries]
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:
Thanks, Spencer
|

Cart



