开发者

XSLT stylesheet modification to get some tags that are gone after the transformation

I transform some RSS XML feeds using XSLT. Basically there are two types I edit :

1. <rss><channel>some tags about the RSS<item></item></channel></rss>
2. <feed>some tags about the RSS<entry></entry></feed>

using this stylesheet. (It gets some files from a paths.xml file)

<xsl:stylesheet version="1.0" xmlns:f="http://www.w3.org/2005/Atom" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/*">
    <NEWrss>
        <xsl:for-each select="file">
            <xsl:apply-templates 
                select="document(.)/*//channel | document(.)/f:feed/f:entry">
                开发者_如何学Python<xsl:with-param name="file" select="."/>
            </xsl:apply-templates>
        </xsl:for-each>
    </NEWrss>
</xsl:template>

On the first RSS I get correctly the output with the tags between <channel> and first <item>. Those are some tags that contain info about the blog, like the title.

However, on the second, those tags (title of the blog... found between the <feed> and first <entry>) are gone after the transformation. The tags in appeared correctly.

My question is how can I get those tags too ?

A sample Feed like the 2nd structure is http://feeds.feedburner.com/EFENPRESS-

Thank you.


I think what you're saying is you don't see the text preceding the f:feed element. That's because your select statement doesn't include it - it only selects f:feed/f:entry and channel elements. Maybe you should try processing f:feed instead of f:feed/f:entry? or f:feed/node(), which will select both f:feed/text() and f:feed()/f:entry.


Looks like a namespace issue. You're using a namespace prefix "f" to access the feed and entry elements, but it's not apparent that those elements are really in that namespace. (And actually, the entry element is empty, so accessing that will not render any content)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜