xsl-list
[Top] [All Lists]

Re: [xsl] HTML character entity issue

2008-12-25 12:44:34
Please read about passing parameters to named templates. From what you report and show it seems you misunderstood that concept. And that is a problem.

Maybe you can first verify that my example works as intended, and then continue. This will help you spot any problems. I use the XSLT playground feature of Kernow (kernowforsaxon at SF.net) for experiments like this.

Merry Christmas,

- Michael



Am 24.12.2008 um 07:22 schrieb Atul Shinh:

Hi,

I tried using the method suggested by you but getting the same old error.

---------------------------

XSLCmd :WARNING: Error Level : 2
XSLCmd :WARNING: Error Code  : 11782 (2E06)
XSLCmd :WARNING: Unexpected element: 'br' after 'fo:#text' in 'fo:block'.
XSLCmd :WARNING: Line 219, Col 505, /tmp/xif02ee5_7e077883.xml

-------------------------

1  <xsl:template name="fix-br">
2   <xsl:param name="text" select="''"/>
In the 2nd line above I am using "/katalog/produkt/content-tag"
for select property instead of ''.

I am calling the template "one" (below, step 1  ) which again calls
"fix-br" . Hope that is no problem.

1   <xsl:call-template name="one" />

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


Regards
Atul

On Wed, Dec 24, 2008 at 3:39 AM, Michael Müller-Hillebrand
<mmh(_at_)cap-studio(_dot_)de> wrote:
Atul,

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 XSL.

"&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:call-template>
</xsl:template>

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

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.

HTH,

- 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--------------------------

<katalog>
<produkt>
<!-- what a story -->
<gruppe>Universal-Türdämpfer VS 2000</gruppe>
<titel>Das kräftige Topmodell mit verkleidetem Haken</titel>
<content>My sampla text &lt;br/&gt;  DICTATOR-Türdämpfer bremsen
zufallende Türen progressiv, d.h. besonders sanft ab, ziehen sie leise
ins Türschloß und halten sie sicher geschlossen.

            </content>
</produkt>
</katalog>



--
_______________________________________________________________
Michael Müller-Hillebrand: Dokumentation Technology
Adobe Certified Expert, FrameMaker
Consulting and Training, FrameScript, XML/XSL, Unicode
Blog [de]: http://cap-studio.de/




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>