[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSL Transformation Question

Subject: Re: XSL Transformation Question
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 20 Feb 2004 19:30:00 +0000
xsl transform rss
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.