-2
我的XML是:如何打印父節點的文本和前兩個孩子
<content>
<p>The <organization>Committee on Civil Liberties</organization> calls on the <organization>Committee on Foreign Affairs</organization>, as the committee responsible:
<mod>
<quotedStructure>
<recital id="_900411">
<num>A.</num>
<p>Whereas the progressive development ...</p>
</recital>
<recital id="_900412">
<num>B.</num>
<p>Whereas Article ...</p>
</recital>
<recital id="_900413">
<num>C.</num>
<p>Whereas, while Member States ...</p>
</recital>
</quotedStructure>
</mod>
</p>
我的預期成果是:
委員會對公民自由的呼籲外交委員會,作爲委員會負責人:
A.儘管逐步發展....
B.雖然第...
C.然而,雖然成員國...
我的XSLT是:
<xsl:template match="content/p">
<xsl:value-of select="text()"/>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="content//recital">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="content//recital/num">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="content//recital/p">
<xsl:value-of select="." />
</xsl:template>
我的電流輸出是:
作爲委員會負責人的電話:
A.而逐步發展......
B.雖然第...
C.然而,雖然成員國...
注:我很想念裏面的文字<organization>
父節點<p>
節點的子節點。 請讓我知道XPath和XSLT以獲得預期的輸出。
請出示至少冷杉嘗試。並添加您所需的輸出 - 而不是圖像。 –
您是否可以顯示一個完整的XSLT來演示問題,因爲子節點「組織」實際上將由XSLT的默認模板代替。 (例如,請參閱http://xsltransform.net/gWvjQgg)。謝謝! –
您的XML格式不正確。如果您希望得到答案,請糾正。 – zx485