Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

highlighting keywords using XSL

Status
Not open for further replies.

lowbk

Technical User
Nov 26, 2001
162
SG
i've a xml that looks like the below

<doc>
<header>
<keyword>
<word>hello</word>
<word>hi</word>
</header>
<section>
...
</section>
</doc>

without the <keyword> node, my existing XSL stylesheet can display the <doc>. but now i want to display it such that such each keyword will be underlined.

any suggestion from anyone, or is that any reference i can refer to?

i only know how to use
<xsl:variable name='theword' select='/doc/header/keyword/word'/>
but that is only for one keyword.
 
<xsl:template match=&quot;*/keyword/word&quot;>
<u>
<xsl:value-of select=&quot;.&quot;/>
</u>
</xsl:template>

This matches any combo of /keyword/word and puts HTML underline tags around the data.

Another way to do this is with CSS, which I prefer. That way you can change the CSS stylesheet without having to send the XML documents through the XSL stylesheet again.
 
mulligh, thanks for the suggestion but how do i invoke the template?

currently, to invoke a template i'm using

<xsl:template match=&quot;/&quot;>
<xsl:apply-templates select=&quot;/doc/section&quot;/>
</xsl:template>

<xsl:template match=&quot;section&quot;>
<table>
......
</table>
</xsl:template>


how do i invoke the call within the section template?
 
mulligh, i'm still unable to to perform the underlining of keywords in XSL.
is it possible to elaborate how it can be done or is there any sample code or website which i can refer to?

thanx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top