Re: [xsl] XSL Transformation Question

Subject: Re: [xsl] XSL Transformation Question
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 20 Feb 2004 19:30:00 +0000
Hi Eric,

> I have a rss feed I am trying to transform, but it will not read the
> img and a tags from within the description of each item. The rss
> feed can be found at

What a strange RSS feed. It uses a mix of the classic (and bad) design
wherein the HTML content of the <description> element is nested within
a CDATA section (effectively escaping the HTML tags), and unescaped
<a> and <img> elements. Weird.

Anyway, the problem is that in the template for <item> elements,
you're using the wrong path when trying to select the <img> and <a>
elements: the <img> and <a> elements are within the <description>
element, so you need to step through the <description> element to
reach them. Try:

<xsl:template match="item">
 			<div class="itemTitle">
      <a href="{link}" title="{title}">
        <xsl:value-of select="title" />
    <div class="itemDescription">
      <xsl:apply-templates select="description/img" />
      <xsl:apply-templates select="description/a" />
      <xsl:value-of select="description" />

By the way, you'll need to change the paths that you use within the
templates for the <img> and <a> elements as well -- you want to point
to the src and href *attributes*, not child elements, so you need
"@src" and "@href" rather than "src" and "href".



Jeni Tennison

 XSL-List info and archive:

Current Thread