|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








