Re: [xslt] handling of < in CDATA sections



On 2005-02-22 12:40:56 +0100, Roel Vanhout wrote:
> Vincent Lefevre wrote:
> >This is not cheating, this is exactly what you want to do: create
> >a processing-instruction, right?
> 
> Well I want to create a php tag, and php tags just happen to look
> like processing instructions, so that's why I'd consider it
> cheating. But you're right, it depends on how you look at it :)

They don't just look like. They exactly *are* processing instructions.

> I think it has something to do with the fact that the output format
> is html; if I try to change the <root> element in your example to
> <html>, I get the following output:
> 
> C:\>xsltproc pitext.xsl pitest.xml
> <html><?php
>         $var = 0;
>     ></html>

Yes, ditto here. To get the XML behavior, one needs

<xsl:output method="xml"/>

xsltproc probably defaults to html output when the root element of
the output is "html". I don't know what SGML PI's look like, so I
don't know if this is a bug or not. You can still specify the ending
"?" in your stylesheet, as Daniel said.

> >BTW, this is much cleaner than the solution based on escaping
> >(proposed by Daniel), IMHO. Disabling escaping is evil.
> 
> Well at this point I'm just trying to get a working solution, that's
> all :) Thanks anyway for guiding me on the way to Enlightenment ;)

The advantage of avoiding output escaping is that the stylesheet
is more maintainable and there is more guarantee that the output
is well-formed.

-- 
Vincent Lefèvre <vincent vinc17 org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]