0
環境: XSLT 1.0なぜXSLTでない変換された予想出力
期待出力:レベル1とレベル2の両方テキスト出力
:実際の出力レベル2エレメントためのみがテキスト・ノード
XSL
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/*">
<xsl:apply-templates select="/data/section1" />
</xsl:template>
<xsl:template match="level2">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
XML
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="SelectingAndMatching.xslt"?>
<data>
<section1>
<level1>hello world 1</level1>
<level2>unlocked achievement level 2</level2>
</section1>
<section2>
<product1></product1>
<product2></product2>
<product3></product3>
</section2>
</data>
section1はlevel1とlevel2の要素を持っていますが、私はlevel2がほしいと思うでしょう。 – Rod
したがって、おそらく私の選択は次のようになります: 'select ="/data/section1/level2 "' – Rod
はい、 'これを に変更することをお勧めします。もう1つの解決策は、 'level1'要素が出力を生成しないことを確認することです。 ' ' –