开发者

Can not transform correctly using XSLT

I tried to use a XSLT transformation (below) to a RSS with this type with no result. Why is that ?

<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?>

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:gd="http://schemas.google.com/g/2005" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CUACQXg6fyp7ImA9WhdUFUo.&quot;">

and the structure of it is

<feed>
tags tags tags like <title></title>
<entry开发者_如何学运维><published></published><title></title><content></content>....</entry>
</feed>

XSLT

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:include href="identity.xsl"/>

<xsl:template match="node() | @*">
  <xsl:copy>
    <xsl:apply-templates select="node() | @*" />
  </xsl:copy>
</xsl:template>

<xsl:template match="entry"/>

</xsl:stylesheet>


Your stylesheet is constructed for the default XML namespace (xmlns=""). An RSS feed has the Atom (xmlns="http://www.w3.org/2005/Atom") namespace defined and possibly others if you have nested XML content.

To 'match' anything in that namespace, you need to define it in your stylesheet also. You probably want to define Atom with a prefix like: xmlns:a="http://www.w3.org/2005/Atom". Then your match would become

<xsl:template match="a:entry"/>

Also, the above matches entry but you're not doing anything with it. You probably want it to print out a transformed value when you get an entry but the above is just excluding it from the result.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜