Hi,
I need to translate an XML doc to HTML. The XML contains HTML tags in the
format <br> 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:choose>
<xsl:when test="contains($stringIn, '<br>')">
<xsl:value-of select="substring-before($stringIn, '<br>')"/>
<br/>
<xsl:call-template name="BR">
<xsl:with-param name="stringIn" select="substring-after($stringIn,
'<br>')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$stringIn"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
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
string.
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 < to < and all > to > ,
so all the HTML tags in the XML get displayed properly.
cheers
Paul Davies
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list