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



> > 
> > I am playing around with building an RSS reader.
> > 
> > I get the xml 
>  
> from where?

>From anywhere, but I first noticed the issue coming from
http://www.nba.com/rss/nba_rss.xml

> >and use xsl templates to create html.
> > 
> > A problem is people often put &quot; into the <description> tag, so at
> > the end of the day the result is &amp;quot;.
> > 
> > Is there a common/best way to fix this?

> Yes, your xml parser needs to deal with that :-)
> Can you provide us with a _real_ sample?

I'm using libsoup, libxml2 and libxslt.

Libsoup grabs the file and I do:

xsltStylesheetPtr cur = NULL;
xmlDocPtr res, rss;

rss = xmlParseMemory(msg->response.body, msg->response.length);

>From there,

params[nbparams] = NULL; 
xmlSubstituteEntitiesDefault(1);
xmlLoadExtDtdDefaultValue = 1;

cur = xsltParseStylesheetFile((const xmlChar *)"rss2html.xml");
 
res = xsltApplyStylesheet(cur, rss, params);


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>

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.    

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?

Cheers,

Andrew 



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