Subject: Re: [xsl] Storing HTML in XML From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 6 Sep 2001 18:54:29 +0100 |
Hi Francisco, > I would like to know if it's possible to store html code inside xml > tags. Thus is, something like: > > <files> > <myfile number="1"> ... here goes the HTML code ... </myfile> > <myfile number="2"> ... here goes the HTML code ... </myfile> > <myfile number="3"> ... here goes the HTML code ... </myfile> > ... > </files> > > In a way that I can output that html code without processing it. The > output of the xsl should be the HTML inside <myfile> tags. The source document for a transformation must be well-formed XML. The best way of including HTML embedded within an XML document is to turn it into XHTML (using HTML Tidy if you need to automate it) and embed it in your XML document, preferably using the HTML namespace for the HTML elements in it. You can then do something like: <xsl:copy-of select="/files/myfile[1]/node()" /> to copy the XHTML within the first myfile element, and use xsl:output to set the output method to HTML so that it's output as HTML rather than XML. An alternative that I wouldn't recommend is to store the HTML as text, by wrapping it in a CDATA section and then outputting it (without processing it) using: <xsl:value-of select="/files/myfile[1]" disable-output-escaping="yes" /> The reason I wouldn't recommend this method is that disable-output-escaping might not be support by all XSLT processors and because if you find later on that you want to access specific information within the HTML, you'll be stuck. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Storing HTML in XML, Thomas B. Passin | Thread | Re: [xsl] Storing HTML in XML, Michael Symonds |
Re: [xsl] FOO vs FO, Wendell Piez | Date | [no subject], Pranav |
Month |