これを変換しようとしています:
<list>
<entry>
<parentFeed>
<feedUrl>http://rss.nzherald.co.nz/rss/xml/nzhrsscid_000000001.xml</feedUrl>
<id>68</id>
</parentFeed>
<content>Schools will have to put up with problematic pay administered through Novopay for another eight weeks after the Government announced it would persist with the unstable system.Minister responsible for Novopay, Steven Joyce, delayed...</content>
<link>http://www.nzherald.co.nz/nz/news/article.cfm?c_id=1&objectid=10872300&ref=rss</link>
<title>Novopay: Govt sticks with unstable system</title>
<id>55776</id>
<published class="sql-timestamp">2013-03-19 03:38:55.0</published>
<timestamp>2013-03-19 07:31:16.358 UTC</timestamp>
</entry>
</list>
XSLTを使用して、これに:
Title, Link, Date
Novopay: Govt sticks with unstable system, http://www.nzherald.co.nz/nz/news/article.cfm?c_id=1&objectid=10872300&ref=rss, 2013-03-19 03:38:55.0
しかし、文書の先頭にある空白行を取り除くことはできません。私のスタイルシートは次のとおりです。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:csv="csv:csv"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/list"> <xsl:for-each select="entry">
Title, Link, Date
<xsl:value-of select="title"/>, <xsl:value-of select="link"/>, <xsl:value-of select="published"/>
</xsl:for-each></xsl:template>
</xsl:stylesheet>
ここ<xsl:text>
</xsl:text>
で提案されているように、最後の改行を取り除いたので、それをファイルの先頭に移動しようとしましたが、その時点でノーオペレーションになりました。ここでの解決策は、実際には空白行を追加します ( ascii manpageによると、16 進コードは改行用であるため、これは理にかなっています)。
回避策として、Java を使用して CSV 出力を生成しています。
ただし、XSLT は XML を他のさまざまな形式に変換するように設計されているため、はるかに高速になると思います。同様の XSLT は、HTML、RSS、および ATOM フィードを完全に生成します。