This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Including a document containing static HTML


Another approach to this problem is to wrapper the external
HTML document with XML, and in that XML treat the entire HTML
block as a one character data field. You use the CDATA wrapper
to denote this.  Then use the disable-output-escaping option
in the "calling" XSL to display that "HTML Body field" properly.

Here's a sample.  Go from this external doc:

<html><head><title>foo</title></head>
<body><p>some malformed html<br>is here.</body>
</html>

to this external doc:

<?xml>
<root>
<htmlbody>
<! [CDATA[

<html><head><title>foo</title></head>
<body><p>some malformed html<br>is here.</body>
</html>

]]>
</htmlbody>
</root>


In your calling XSL you would want something like this:

<xsl:value-of select="document(...)/htmlbody"
disable-output-escaping="yes" />

I think this is where you were headed.  The key is that the
external doc has to be parsable as XML, so the CDATA wrapper is
required on that external file.


Date: Tue, 17 Oct 2000 11:58:45 +0100
From: Kay Michael <Michael.Kay@icl.com>
Subject: RE: Including a document containing static HTML

> First: How to include the file?  Imagine the xml is of the form
>
> <user_info_node file_name="XXX"/>
>
> I have tried the following without success (no error given -
> just nothing included in the output html):
>
> <xsl:value-of select="document(@file_name)"
> disable-output-escaping="yes"/>

The file retrieved by the document() function must be XML. If the file
cannot be retrieved or parsed, it's an error: the XSLT processor may either
report the error, or return an empty node-set.

> How have other people dealt with this type of problem?

Write an extension function which returns the entire HTML content as a
string. Then write

<xsl:value-of select="my:HtmlDocument('filename')"
disable-output-escaping="yes"/>

Alternatively, generate HTML output that contains a server-side-include.

Mike Kay



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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]