RE: [xsl] Mal-formed HTML within XML

Subject: RE: [xsl] Mal-formed HTML within XML
From: Maria Amuchastegui <mamuchastegui@xxxxxxxxxxx>
Date: Mon, 21 Feb 2005 08:22:03 -0500
It doesn't work in the sense that the <p> tag is displayed in the browser,
at least when I use MSXML4. I do think I have the option of using Saxon
though.

The <Html> tag is not the top-level tag, so I'm not sure I can add those
other attributes.

Maria

-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx] 
Sent: Sunday, February 20, 2005 6:14 PM
To: 'Maria Amuchastegui'; xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Mal-formed HTML within XML

You said before that the malformed HTML was in your source document, now you
seem to have it in your stylesheet.

But you can have it in either. Your example is not guaranteed to work on
every processor, because not all processors support disable-output-escaping
(and some support it only if you invoke the processor in certain ways). But
if I take your fragment and turn it into a complete stylesheet by writing:

<Html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:text disable-output-escaping="yes"> <![CDATA[ <p>This is the Summary
section.
]]>
</xsl:text>
</Html>

and then run it (against any source document) from the command line using
Saxon, the result is:

<Html>
   
   <p>This is the Summary section.
   
   
</Html>

(I do wish people wouldn't say simply "it didn't work". What actually
happened? Different results? Error message? If you say what happened, people
on this list can explain *why* it didn't work.)

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Maria Amuchastegui [mailto:mamuchastegui@xxxxxxxxxxx]
> Sent: 20 February 2005 22:58
> To: 'Michael Kay '; 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx '
> Subject: RE: [xsl] Mal-formed HTML within XML
> 
> How do I use disable-output-escaping in conjunction with CDATA?
> 
> I tried this but it didn't work:
> 
> <Html><xsl:text disable-output-escaping="yes"> <![CDATA[ <p>This is 
> the Summary section.
> ]]>
> </xsl:text>
> </Html>
> 
> Maria
> 
> -----Original Message-----
> From: Michael Kay
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Sent: 20/02/05 5:31 PM
> Subject: RE: [xsl] Mal-formed HTML within XML
> 
> > For historical reasons, I need to store mal-formed html within my 
> > xml data, and then output it as html, without the tags showing.
> 
> Two possible solutions:
> 
> (a) use the tidy utility to make the HTML well-formed
> 
> (b) use disable-output-escaping to serialize the CDATA content without 
> escaping the angle brackets.
> 
> Usual caveats about d-o-e apply, but this is the use case that 
> justifies its inclusion in the spec.
> 
> Michael Kay
> http://www.saxonica.com/
> 
> > 
> > <Content>
> > 	<Section ref="2">
> > 		<Name>Summary</Name>
> > 		<HTML><p>Hello world&nbsp;</HTML>
> > 	</Section>
> > <Content>
> > 
> > If I put the html inside CDATA tags, then the tags are displayed in 
> > the browser, but if I don't use CDATA then the xml is not 
> > well-formed.
> > 
> > Is there a way to do this?
> > 
> > Maria

Current Thread