Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Highlight words? Highlight words?To: NULL Date: 5/2/2006 5:41:00 PM Dear all, I am trying to search and highlight words in XML content displayed as HTML using XSLT. I have got the search bit using javascript and dom, and am at the moment successfully putting <font> tags around matches when I'm writing the results out, by grabbing document.body using dom. However Firefox doesn't like it and it is a known bug: https://bugzilla.mozilla.org/show_bug.cgi?id=325835 I gather that I cannot wait for Firefox to get its act right, so I am wondering if there might be an XSLT way to do similar? Pretty much I have the search terms fed into a javascript function that does the XSL transformation and displays the HTML with the matched keywords highlighted using <font color...>. The HTML is generated by XSLT on the fly and Firefox won't find document.body this way, if you save the result of the XSLT to a file hten load it back in Firefox will see its document.body, however a bug exists there it cannot be done at this moment... What I'm asking is then, I need a way to give the XSLT the keywords to match and it'd find them and put <font> tags around each of them when displaying them. I currently have : <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="UTF-8" omit-xml-declaration="no" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" /> <xsl:attribute-set name="imgAttrs"> <xsl:attribute name="src">page/<xsl:value-of select="@Href"/></xsl:attribute> </xsl:attribute-set> <xsl:template match="/"> <html> <head> <link rel="stylesheet" href="style/template.css" type="text/css" /> </head> <body id="mainBody" style="margin:25px;"> <xsl:for-each select="//hl1"> <h3> <xsl:copy-of select="."/> </h3> </xsl:for-each> <xsl:for-each select="//body.content/block"> <p> <xsl:copy-of select="."/> </p> </xsl:for-each> <xsl:for-each select="//ContentItem[substring(@Href, string-length(@Href) - 3) = '.jpg']"> <p> <xsl:element name="img" use-attribute-sets="imgAttrs"/> </p> </xsl:for-each> <xsl:for-each match="classes"> <B><xsl:copy-of select="." /></B> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet> As you can see I'm showing things in a specific order, what I need is for each of these for-each results to be matched against the keywords so any matches will be transformed into as highlighted. I'm no expert in XSLT, I know just enough to get by, so if anyone could give me some code samples that'd be greatly appreciated... on the other hand if anyone knows a way round the Firefox bug please also let me know ... Many thanks! Julius | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
