Re: [xsl] mystery #3: rendering embedded HTML

Subject: Re: [xsl] mystery #3: rendering embedded HTML
From: Gary Lawrence Murphy <garym@xxxxxxxxxx>
Date: 13 Apr 2002 17:13:36 -0400
>>>>> "J" == Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> writes:

    J> ... If you think that disable-output-escaping only works if
    J> your HTML has been escaped with CDATA sections, you're
    J> mistaken.

What I found was the other way around.  When disable-output-escaping
is _off_ and I try "<br>", I get "&lt;br&gt;" ... but the reverse is
not true.

    J> When you have an XML document like:

    J> <envelope>&lt;p&gt;My mal-formed HTML
    J> escaped.&lt;br&gt;</envelope>

    J> The XSLT processor views this as a tree like this:

    J> envelope +- text: "<p>My mal-formed HTML escaped.<br>"

Hmmm ... this is not what I see with either xalan or xt.  I get the
entities spelled out in full, exactly as entered.

    J> If this isn't working for you, please post a sample of your XML
    J> and the relevant part of your XSLT stylesheet and we'll see
    J> what we can do.

Sure thing, and thanks for looking at this; it's been driving me nuts
for a long time.  Here's a bit of sample data:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sports-content SYSTEM "dtds/sportsml-core.dtd">
<?cocoon-format type="text/xml"?>
<sports-content id="icehockey/NHL/82900/preview">
  <sports-metadata date-time=" April 12, 2002, at 10:52 AM ET " language="en-US" fixture-key="event-preview" fixture-source="iptc.org" fixture-name="Event Preview">
    <sports-title>Recap: Phoenix vs. Minnesota</sports-title>
  </sports-metadata>
  <sports-event>
    <event-metadata event-key="82900" site-key="" site-name="" site-source="iptc.org" event-status="pre-event" />
    <highlight class="snbody">

 (Sports  Network) - The Phoenix Coyotes hope to wrap up a playoff spot tonight

&lt;P&gt;
 when they welcome the Minnesota Wild to America West Arena.
 
&lt;P&gt;
 With  91 points, the Coyotes are eighth in the Western Conference -- one ahead
 of  the Edmonton  Oilers and one behind the Vancouver Canucks. Should they top
 the  Wild this  evening and  the  Oilers fall  in regulation  to Calgary,  the
 Coyotes would end their one-year playoff drought.
 

    </highlight>
  </sports-event>
</sports-content>


================================================================
and the simplest possible XSL

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0" >
<xsl:template match="/">

<h3><xsl:value-of select="sports-content/sports-metadata/sports-title"/></h3>

<xsl:value-of select="sports-content/sports-event/highlight"/>

</xsl:template>
</xsl:stylesheet>

================================================================ it
does not matter if doe is set on or off in the value-of, the output
result is identical, the browser sees a single block of text with
literal "<P>" strings in it instead of paragraph breaks.

-- 
Gary Lawrence Murphy <garym@xxxxxxxxxxx> TeleDynamics Communications Inc
Business Innovations Through Open Source Systems: http://www.teledyn.com
"Computers are useless.  They can only give you answers."(Pablo Picasso)


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


Current Thread