[xsl] Problem Translating 'escaped' HTML tags to real HTML

Subject: [xsl] Problem Translating 'escaped' HTML tags to real HTML
From: "Davies, Paul (FNB)" <DaviesPa@xxxxxxxxx>
Date: Thu, 3 Oct 2002 13:14:54 +0100

I need to translate an XML doc to HTML. The XML contains HTML tags in the
format &lt;br&gt; This needs to be translated such that it is seen as a line
brake tag by the browser.

I have tried the following search-replace template:

<xsl:template name="BR">
  <xsl:param name="stringIn"/>
   <xsl:when test="contains($stringIn, '&lt;br&gt;')">
      <xsl:value-of select="substring-before($stringIn, '&lt;br&gt;')"/>
      <xsl:call-template name="BR">
          <xsl:with-param name="stringIn" select="substring-after($stringIn,
	<xsl:value-of select="$stringIn"/>

however the returned text does not contain the <br/> tags!!?? If I
substitute this text for non HTML (eg AAA) this IS inserted into the input

I have tried using an xsl:element tag: <xsl:element>br</xsl:element>. This
is ignored too.

I have also tried to use an xsl:text tag: <xsl:text><br></xsl:text> and
<xsl:text>[CDATA[<br>]]</xsl:text>. Both of these result in a SAX exception
stating the a br tag is not legal in this location. (I amusing Xalan-J2.4.0
and the example servlet 'SimpleXSLTServlet' to perform the translation.

Ideally I would like to simply translate all &lt; to < and all &gt; to > ,
so all the HTML tags in the XML get displayed properly.


Paul Davies

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread