Subject: Re: [xsl] Printing CDATA from feed as HTML From: "Darcy Parker" <darcyparker@xxxxxxxxx> Date: Thu, 12 Jun 2008 17:22:59 -0400 |
Hi Joelle, The problem is that the text inside the CDATA is parsed as character data. It has no structure to it according to the XML parser that is passing the information along to XSLT. The disable-output-escapting attribute you tried only applies to the output... Your interest is to have the CDATA parsed so that you can process it with XSLT. I would pre-process the XML and remove the CDATA so that the XML parser has an opportunity to parse the data inside. I think the reason the CDATA was inserted was for security... So you may want to investigate possible security issues when you strip out the CDATA. Darcy On Thu, Jun 12, 2008 at 5:08 PM, Joelle Tegwen <tegwe002@xxxxxxx> wrote: > Using xsl 1.0 with php 5.x > > I'm trying to consume an atom feed and I'd like to print out the full body > of the content. It's wrapped in a CDATA section so I'm having trouble > getting it to display correctly. The tags come out escaped despite adding > the disable-output-escaping. I've looked via google and not found an answer. > > Sites do this so it must be possible somehow. Right? Snippets below > Links to a manual to read are fine too. > > Thanks! > Joelle > > My XML snippet (Typical atom feed I'm guessing?) full feed at > http://blog.lib.umn.edu/huntx010/ici/atom.xml: > > <entry> > <title>(Further) Reflections on Green Living</title> > <link rel="alternate" type="text/html" > href="http://blog.lib.umn.edu/huntx010/ici/2008/06/further_reflections_on_green_l.html" > /> > <link rel="service.edit" type="application/atom+xml" > href="https://blog.lib.umn.edu/cgi-bin/mt-atom.cgi/weblog/blog_id=7828/entry_id=131252" > title="(Further) Reflections on Green Living" /> > <id>tag:blog.lib.umn.edu,2008:/huntx010/ici//7828.131252</id> > <published>2008-06-11T19:48:09Z</published> > <updated>2008-06-11T19:49:00Z</updated> > <summary>Summer is a great time for taking stock of your eco-life, and for > adding a little extra oomph to the good habits you already have. For > example, are there any "hard-copy" activities you could do online, > such as bill paying...</summary> > <author><name>Megan Dushin</name></author> > <category term="Tips from CEHD Insider" /> > <content type="html" xml:lang="en" > xml:base="http://blog.lib.umn.edu/huntx010/ici/"> > <![CDATA[<p>Summer is a great time for taking stock of your<br /> > eco-life, and for adding a little extra oomph to the good habits<br /> > you already have. For example, are there any "hard-copy"<br /> > activities you could do online, such as bill paying or travel<br /> > planning? Do you need multiple light sources in your office, or<br /> > would one do the job? Could you take mass transit to work two days<br /> > a week instead of just one? Take time to ask reflective questions<br /> > such as these--the Earth will thank you for it!</p>]]> > </content> > </entry> > > My xsl snippet: > > > <xsl:template match="atom:entry[position() = 1]"> > <h3> > <xsl:apply-templates select="atom:title"/> > <xsl:text> > </xsl:text> > <span class="feed_posted">Posted on: > <xsl:apply-templates select="atom:updated"/></span> > </h3> > <xsl:value-of disable-output-escapting="yes" > select="atom:content"/> > </xsl:template> > > It generates: > > <h3><a > href="http://blog.lib.umn.edu/huntx010/ici/2008/06/further_reflections_on_green_l.html">(Further) > Reflections on Green Living</a> > <span class="feed_posted">Posted on: 06/11/2008</span></h3> > <p>Summer is a great time for taking stock of your<br /> > eco-life, and for adding a little extra oomph to the good habits<br > /> > you already have. For example, are there any "hard-copy"<br /> > activities you could do online, such as bill paying or travel<br > /> > > planning? Do you need multiple light sources in your office, or<br > /> > would one do the job? Could you take mass transit to work two days<br > /> > a week instead of just one? Take time to ask reflective questions<br > /> > such as these--the Earth will thank you for it!</p> > > > I want (We'll I'd really like to strip out the <br /> tags, but I think I > can do that. The part I'm struggling with is the escaping): > > <h3><a > href="http://blog.lib.umn.edu/huntx010/ici/2008/06/further_reflections_on_green_l.html">(Further) > Reflections on Green Living</a> > <span class="feed_posted">Posted on: 06/11/2008</span></h3> > <p>Summer is a great time for taking stock of your<br /> > eco-life, and for adding a little extra oomph to the good habits<br /> > you already have. For example, are there any "hard-copy"<br /> > activities you could do online, such as bill paying or travel<br /> > planning? Do you need multiple light sources in your office, or<br /> > would one do the job? Could you take mass transit to work two days<br /> > a week instead of just one? Take time to ask reflective questions<br /> > such as these--the Earth will thank you for it!</p>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Printing CDATA from feed as H, Joelle Tegwen | Thread | Re: [xsl] Printing CDATA from feed , Darcy Parker |
[xsl] Printing CDATA from feed as H, Joelle Tegwen | Date | Re: [xsl] Printing CDATA from feed , Darcy Parker |
Month |