Re: [xslt] handling of < in CDATA sections
- From: Daniel Veillard <veillard redhat com>
- To: The Gnome XSLT library mailing-list <xslt gnome org>
- Subject: Re: [xslt] handling of < in CDATA sections
- Date: Tue, 22 Feb 2005 05:14:50 -0500
On Tue, Feb 22, 2005 at 10:39:39AM +0100, Roel Vanhout wrote:
>
> Hello all,
>
> I've written an xsl stylesheet to serve as customization stylesheet for
> a docbook document. The goal is to insert some php code into the
> generated (html) documentation. For that to happen I need my stylesheet
> to output php tags, like this:
> <?php
> into the generated html. It's the < that is causing me troubles. My
> first try was to put it in a CDATA section, like this:
> <![CDATA[
> <?php
> ]]>
> and that worked for me, but it turned out that someone else, with a
> newer version of xsltproc, got a different output than I did: he got
> <?php
> (the < was escaped). So I upgraded my xsltproc to the latest version and
> then I got the same problem. Now, my questions are:
>
> 1.) Is this behaviour ok? Should a < in a CDATA section be escaped to <?
> 2.) What other options do I have to reach my goal? I've tried <xsl:text>
> but that (as I expected) didn't help.
>
> The bug report with the original stylesheet and the message that it
> didn't work can be found in the gnome bugzilla, see
> http://bugzilla.gnome.org/show_bug.cgi?id=168030. Thanks for any help in
> this.
CDATA does not exist in the XPAth data model. I.e. XSLT does not see
CDATA in any input or generated tree, only text nodes with the associated
text value. What you're trying to do is not possible in XSLT.
The only thing you can do:
- force some element content to be CDATA
http://www.w3.org/TR/xslt#section-XML-Output-Method
using cdata-section-elements
- disable escaping for some specific text nodes
http://www.w3.org/TR/xslt#disable-output-escaping
Daniel
--
Daniel Veillard | Red Hat Desktop team http://redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]