私はXmlファイルを持っています:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<child>
<gc>gc1Value</gc>
</child>
<child>child2Value</child>
<child>
<gc>gc2Value</gc>
<gc>gc3Value</gc>
<gc>
<ggc>ggcValue</ggc>
<ggc>ggcValue</ggc>
</gc>
</child>
</root>
およびXsltファイル:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<root>
<xsl:for-each select="root/child">
<xsl:if test=".!=''">
<value>
<xsl:value-of select="."/>
</value>
</xsl:if>
<xsl:for-each select="root/child/gc">
<xsl:if test=".!=''">
<value>
<xsl:value-of select="."/>
</value>
</xsl:if>
<xsl:for-each select="root/child/gc/ggc">
<xsl:if test=".!=''">
<value>
<xsl:value-of select="."/>
</value>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
私はこの種の結果を見ることを期待しています:
<root>
<value>gc1Value</value>
<value>child2Value</value>
<value>gc2Value</value>
<value>gc3Value</value>
<value>ggcValue</value>
<value>ggcValue</value>
</root>
しかし、私はこの結果を得ています:
<?xml version="1.0" encoding="utf-8"?>
<root>
<value>
gc1Value
</value>
<value>child2Value</value>
<value>
gc2Value
gc3Value
ggcValue
ggcValue
</value>
</root>
.
selectに使用すると、現在のノードの値のみが選択されると思いましたが、子からも値を取得しているようです。代わりに何をすべきですか?