私はXSLTとXPathにはかなり新しく、この問題でしばらくの間壁に頭を打っています。XSLが期待以上に出力されています
<reply>
<multi-results>
<multi-item>
<name>node1</name>
<information>
<block>
<slot>A</slot>
<state>Online</state>
<colour>purple</colour>
</block>
<block>
<slot>B</slot>
<state>Online</state>
<colour>yellow</colour>
</block>
<block>
<slot>C</slot>
<state>Online</state>
<colour>red</colour>
</block>
<block>
<slot>D</slot>
<state>Online</state>
<colour>blue</colour>
</block>
</information>
</multi-item>
</multi-results>
<address>
<label>this is an arbitrary bit of text included for this example</label>
</address>
</reply>
は、ファイルごとに「ブロック」のエントリの可変数があります。
は、私は、次のXMLを持っています。
私が "CSV" データたい、と私は、次のXSLを使用しています:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="*/text()[normalize-space()]">
<xsl:value-of select="normalize-space()"/>
</xsl:template>
<xsl:template match="*/text()[not(normalize-space())]" />
<xsl:template match="block">
<xsl:value-of select="slot"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="state"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="colour"/>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>
出力:
node1A|Online|purple
B|Online|yellow
C|Online|red
D|Online|blue
this is an arbitrary bit of text included for this example
ただし、出力は "名前" との両方を含んでいます「ラベル」...
私は明示的にXSLにするために求めているものだけをしたい:
A|Online|purple
B|Online|yellow
C|Online|red
D|Online|blue
なぜか分かりません。誰か説明してもらえますか?
また、複数の「名前」要素があり、それぞれに独自の数の「ブロック」要素があります。テンプレート:あなたの最初のxslから価値の:事前
これははるかにクリーンなソリューションです。ちなみに、私はあなたの本でXSLTを学んだ、ありがとう! – bravit
この提案に感謝します。私はあなたの助けに感謝します! – wawawawa