";"を使用してカスタムXMLをCSVに変換したい。値区切り記号として使用します。カスタムXMLをCSVに変換するXSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8" />
<xsl:param name="delim" select="';'" />
<xsl:param name="quote" select="'"'" />
<xsl:param name="break" select="'
'" />
<xsl:template match="/">
<xsl:apply-templates select="root/operators/item" />
</xsl:template>
<xsl:template match="item">
<xsl:apply-templates />
<!--<xsl:if test="following-sibling::*">-->
<xsl:value-of select="concat($delim, $break)" />
<!--</xsl:if>-->
</xsl:template>
<xsl:template match="*">
<xsl:value-of select="normalize-space()" />
<xsl:if test="following-sibling::*">
<xsl:value-of select="$delim" />
</xsl:if>
</xsl:template>
<xsl:template match="text()" />
</xsl:stylesheet>
:次のXSLT変換を使用する(特にコードが彼の答え
...a version with configurable parameters that you can set programmaticallyに@Tomalakで書いて使用して、stackoverflowのスレッド
XML to CSV Using XSLTを使用して)私がこれまで管理してきた
<?xml version="1.0" encoding="utf-8"?>
<root>
<operators>
<item>
<lfbis>1234567</lfbis>
<name>Stefan Maier</name>
<company />
<street>Testweg 7</street>
<citycode>95131</citycode>
<city>Hof</city>
<controlbody>BIKO</controlbody>
<productdata>
<item>Rinder</item>
<item>9</item>
</productdata>
</item>
<item>
<lfbis>5671234</lfbis>
<name>Antom Mueller</name>
<company>Berghof</company>
<street>Testweg 8</street>
<citycode>95111</citycode>
<city>Bamberg</city>
<controlbody>BIKO</controlbody>
<productdata>
<item>Rinder</item>
<item>9</item>
</productdata>
</item>
</operators>
</root>
:ここに私のXMLです私が達成しようとしていることということで、今
1234567;Stefan Maier;;Testweg 7;95131;Hof;BIKO;Rinder 9;
5671234;Antom Mueller;Berghof;Testweg 8;95111;Bamberg;BIKO;Rinder 9;
:
は...と私はxsltprocのを使用して次の結果を取得しています品目の製品データ要素は、csv結果の値としても扱われます。だから私は ";"代わりに、このような私のCSVなど、 9 Rinder値の間とは次のようになります(スペース) "" で:
ここ1234567;Stefan Maier;;Testweg 7;95131;Hof;BIKO;Rinder;9;
5671234;Antom Mueller;Berghof;Testweg 8;95111;Bamberg;BIKO;Rinder;9;
他の人のコードを使用する場合は、書き込んだと言っているのではなく、少なくともクレジットカードにクレジットを入れてください。ここからあなたのXSLTコードはhttp://stackoverflow.com/a/365372/18771にあります。 – Tomalak
はい、申し訳ありませんが、私はもちろん、xlstスタイルシートを書くためにstackoverflowスレッドを使用しました。私はそのスレッドの人に、特に私の質問で彼を言及していないためのスタイルシートの作者には謝罪します。私は将来の投稿にもっと注意する。 –