[xsl] Encapsulating and displaying html fragments

Subject: [xsl] Encapsulating and displaying html fragments
From: Shaun ONeil <shaun@xxxxxxxxxxx>
Date: Sat, 15 May 2004 05:31:12 -0400
Good morning List

I'm a complete beginner, but have tried Google, O'Reilly's "XSLT", the
list archives and dpawson's FAQ - so I hope I'm not treading wrong.

I've found much info on storing special characters / entities, but I
can't figure out how to render them in a document afterwards.

The test case I'm working with can be found (plaintext) at the end of
this mail.

What I'm trying to achieve is to render my xml documents as html, and
have these fragments displayed as part of the document - that is to say,
the markup within the fragments is markup in the rendered page - not
printed as html entities.

I'm not sure how best to word the difference between seeing the markup
on-screen, and rendered as part of the document, so I'll paste examples.

MSIE (6.0) and xsltproc are rendering as I'd hope, ie:

<!DOCTYPE html PUBLIC "-//W3C/DTD HTML 1.0 Strict//EN">
<html><body><p>A <acronym title="HyperText Markup
Language">HTML</acronym> fragment</p></body></html>

and Mozilla (1.7b) and Opera (7.11) are 'breaking', ie:

<!DOCTYPE html PUBLIC "-//W3C/DTD HTML 1.0 Strict//EN">
<html><body>&lt;p&gt;A &lt;acronym title="HyperText Markup
Language"&gt;HTML&lt;/acronym&gt; fragment&lt;/p&gt;</body></html>

So what I ask, is which behaviour is actually correct, and how do I work
around this issue?  My target platform is mozilla, making this a
show-stopper for me right now, so I would be very grateful for any
hints.

TIA,
  Shaun

testcase.xml:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="testcase.xsl"?>
<test>
  <fragment>&lt;p&gt;A &lt;acronym title="HyperText Markup
Language"&gt;HTML&lt;/acronym&gt; fragment&lt;/p&gt;</fragment>
</test>

testcase.xsl:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output
    method="html"
    encoding="utf-8"
    doctype-public="-//W3C/DTD HTML 1.0 Strict//EN"/>
  <xsl:template match="/">
    <html>
      <body>
        <xsl:value-of disable-output-escaping="yes"
select="test/fragment"/>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

Current Thread