[xsl] Search and Replace to add HTML tags

Subject: [xsl] Search and Replace to add HTML tags
From: Sharon_Harris@xxxxxxxxxxxxxxxxxxxx
Date: Tue, 30 Jun 2009 13:30:23 -0400
I am trying to wrap specific text in a string within HTML tags. For
example, if a strings contains the word "Note:", then I want to enclose
this word within a set of bold tags (<b>Note:</b>). I do not have control
over the XML data source and cannot modify the structure/schema.

I have tried using the replace function to search for the specific text and
then replace it with a defined variable. The variable contains the text
wrapped within the HTML tags. Unfortunately, only the content within the
variable is getting pulled and the HTML tags are being ignored. Can anyone
tell me how to get the tags added as well during the search and replace?

XML excerpt:
   <ReleaseNote>Before: The application did this. Now: The application does
   this. Note: The application may also do this.</ReleaseNote>
   <ReleaseNote>Before: The application did not do this. Now: The
   application does this.</ReleaseNote>

XSLT excerpt:
   <xsl:variable name="NoteBold"><b>Note:</b></xsl:variable>
   <xsl:variable name="BeforeBold"><b>Before:</b></xsl:variable>
   <xsl:variable name="NowBold"><b>Now:</b></xsl:variable>

   <xsl:template match="text()">
      <xsl:value-of select="replace(replace(replace(.,'Note:',$NoteBold),
   'Before:',$BeforeBold), 'Now:', $NowBold)"/>

Thanks for your help!
Sharon Goldner Harris
Knowledge Management Evangelist
Ultimate Software Group

Confidentiality Note: This e-mail message and any attachments to it are
intended only for the named recipients and may contain legally privileged
and/or confidential information. If you are not one of the intended
recipients, do not duplicate or forward this e-mail message.

Current Thread