开发者

Converting RSSTV XML with XSLT

I am trying to transform RSSTV XML using XSLT. The problem I am having is that I need the XML to look like this: <?xml version="1.0"?><rss xmlns:tv="http://www.rss-tv.org/rss/tv1.0" version="2.0"><channel>

However, I am unable to create the rss element with 开发者_JS百科this attribute. I tried using <xsl:attribute> but failed to achieve it.


Just write:

<rss xmlns:tv="http://www.rss-tv.org/rss/tv1.0" version="2.0">
  <channel/>
</rss>

xmlns:tv="http://www.rss-tv.org/rss/tv1.0" isn't an attribute -- it is a namespace definition and defines a namespace node belonging to the rss element.


I don't really understand what your problem is :

Here are two ways to do it.

1) Assuming namespace is hardcoded in your xslt.

<xsl:template match="/">
            <rss xmlns:tv="http://www.rss-tv.org/rss/tv1.0" version="2.0"></rss>
</xsl:template>

2) Assuming you get the namespace from some other parameter :

<xsl:template match="/">
        <xsl:variable name="namespace">http://www.rss-tv.org/rss/tv1.0</xsl:variable>
        <rss xmlns:tv="{$namespace}"/>
</xsl:template>

Create an element with your desired result.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜