xsl-list
[Top] [All Lists]

RE: XSL Transformation Question

2004-02-20 13:43:15

Thanks Jeni, worked like a charm.

- Eric Fleming 

-----Original Message-----
From: Jeni Tennison [mailto:jeni(_at_)jenitennison(_dot_)com] 
Sent: Friday, February 20, 2004 2:30 PM
To: Eric Fleming
Cc: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] XSL Transformation Question

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 http://www.cssvault.com/gallery.xml.

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">
                <li>
                        <div class="itemTitle">
      <a href="{link}" title="{title}">
        <xsl:value-of select="title" />
      </a>
    </div>
    <div class="itemDescription">
      <xsl:apply-templates select="description/img" />
      <xsl:apply-templates select="description/a" />
      <xsl:value-of select="description" />
    </div>
  </li>
</xsl:template>

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".

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>