Re: [xsl] HTML character entity issue

Subject: Re: [xsl] HTML character entity issue
From: Michael Müller-Hillebrand <mmh@xxxxxxxxxxxxx>
Date: Tue, 23 Dec 2008 23:09:36 +0100

I haven't read the original post, but I guess it would be sufficient
to "repair" the XML during processing. Of course it is always better
to get correct XML in the first place. Also sometimes it is simpler to
preprocess such documents with a different tools to search and replace
all "&lt;br/&gt;" with "<br/>", but nevertheless it is possible with

"&lt;br/&gt;" is nothing special for XSL, just simple text. So any
"repair" must go into a template that processes text:

<xsl:template match="text()" priority="2">
  <xsl:call-template name="fix-br">
    <xsl:with-param name="text" select="."/>

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

This is recursive in case there is more than one "bad-br" in your
content. With XSLT 2.0 it could be written with a function and/or
regular expressions.


- Michael (who sometimes has to fix bad content as well)

Am 23.12.2008 um 20:25 schrieb Atul Shinh:

Hey thanks Michael and Vasu for replying back. My response got slow
on this.
Nothing out of this seems to be working.

I have tried the CDATA and disable-output-escaping="yes". I think I am
using it in wrong way. Can you elaborate how to use it? I give you
description of my files.

---------------------------part of index.xml--------------------------

<!-- what a story -->
<gruppe>Universal-T|rddmpfer VS 2000</gruppe>
<titel>Das krdftige Topmodell mit verkleidetem Haken</titel>
<content>My sampla text &lt;br/&gt;  DICTATOR-T|rddmpfer bremsen
zufallende T|ren progressiv, d.h. besonders sanft ab, ziehen sie leise
ins T|rschlo_ und halten sie sicher geschlossen.


-------------------- part of index.xsl --------------------------

 <fo:table-cell >
 <xsl:value-of select="content" disable-output-escaping="yes" />

<xsl:template match="br" >

     <xsl:text><![CDATA[<br />]]></xsl:text>

So I have given a view of my files.
so the "br" tag is actually &lt;br/&gt; in xml  and it is appearing as
<br / > in output
Michael i tried by your way also
Is there any namespace that is neccessary for all this to work ?

Thanks and regards Atul

-- _______________________________________________________________ Michael M|ller-Hillebrand: Dokumentations-Technologie Adobe Certified Expert, FrameMaker Lvsungen und Training, FrameScript, XML/XSL, Unicode Blog: - Tel. +49 (9131) 28747

Current Thread