Re: [xsl] Displaying document( ) output within CDATA

Subject: Re: [xsl] Displaying document( ) output within CDATA
From: Adam Turoff <ziggy@xxxxxxxxx>
Date: Thu, 28 Jun 2001 14:39:51 -0400
On Wed, Jun 27, 2001 at 09:05:17PM -0700, Mark Miller wrote:
> Any suggestions on how to insert code from an external
> file into a CDATA section would be appreciated.

If you want to emit a <![CDATA[ ... ]]> section on output, you probably
want to look at <xsl:output cdata-section-elements=""/>.  This will make
the child text content of an element appear within a CDATA section.  You
can hack CDATA sections by hand to appear in the middle of a stream
of text nodes, but it involves hacking around the output escaping of < and >.

In your case, if you want to show examples as-is, as they are found
in an external XML file (or XML fragment), you probably want to use 
<xsl:copy-of select=document()"/>

Here's a stylesheet fragment that may help you get going.

<xsl:output method="xml" cdata-section-elements="example"/>

<xsl:template match="example">
<xsl:copy-of select="document(@href)"/>

That will select the document specified by <example href=""/> in your
source, and display it as <example><![CDATA[ ... ]]></example> in your

Hope this helps,


 XSL-List info and archive:

Current Thread