[xslt] Re: Re: Transforming RSS (")



On Tue, 13 Dec 2005 10:06:00 -0700, Andrew Shafer wrote:

> [...]
> After the 
> rss = xmlParseMemory(msg->response.body, msg->response.length);
> 
> The xml tree appears the same as the source file.  The problem occurs in
> the following situation:
> 
> <description><![CDATA[&quot;One says definitely, the other says maybe.
> At this point, the Nets will take whatever they can
> get. . .&quot; ]]></description>
>

Ah, but that explains it all: the CDATA signals to the parser that the 
following characters (up to ']]>') are to be treated as _literals_.

> After a the stylesheet is applied, the &quot; are turned into
> &amp;quot;.  Some of the CDATA has " which come out ok in the eventual
> html.    
>

Which is correct: the '&' character in a literal "&qout;" has to be
escaped.  This is (one of) the reason(s) why having kind-of-escaped HTML
in an XML feed is really a bad idea [see for example:
http://www.xml.com/pub/a/2003/08/20/embedded.html]

CDATA is an unfortunate leftover from SGML where it served as a
convenience for authors who entered text manually.

> All the template do is grab the <title>,<link> and <description> then
> throw the values into an html <table>.
> 
>> So, where's the problem?
> 
> Does that make it more clear?

Yes, it does (exactly as i feared :). As a possible workaround 
have a look at the cdata-section-elements attribute of the xslt:output
tag.

 HTH Ralf Mattes 
> Cheers,
> 
> Andrew




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