[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: mystery #3: rendering embedded HTML

Subject: Re: mystery #3: rendering embedded HTML
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Sat, 13 Apr 2002 16:24:16 +0100
html disable using emb
Hi Gary,

> Isn't it odd that while there is a solution for embedding verbatim
> markup inside XML, there is apparently no solution for extracting
> it?

You can use disable-output-escaping in this situation. When you get
the value of the escaped HTML using xsl:value-of, add a
disable-output-escaping attribute with the value "yes" to the
instruction. For example, if you have this:

  <envelope>
    <![CDATA[
      <p>My mal-formed HTML.<br>
    ]]>
  </envelope>

then you can extract it with:
  
  <xsl:value-of select="envelope" disable-output-escaping="yes" />

and you'll get:

  <p>My mal-formed HTML.<br>

as the result, or at least you will in those processors that generate
a character output stream rather than a DOM tree.

If this HTML makes up the majority of your page, the other option is
to use the text output method rather than the XML output method:

<xsl:output method="text" />

and generate everything else in the page as a string as well. Then you
don't need to disable output escaping because there's no output
escaping to disable in the first place.

But the best solution is nevertheless to tidy up the HTML so that it's
well-formed. This would also give you more control over what users
entered -- you can insist that they enter well-formed XHTML and you
can validate that XHTML to make sure it's at the correct level (for
example that they don't enter an 'html' element when you're expecting
elements that are valid within a 'div').

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.