【发布时间】:2018-02-24 17:02:23
【问题描述】:
环境: XSLT 1.0
预期输出:只有第 2 级元素的文本节点
实际输出: level1 和 level2 文本输出
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>
【问题讨论】: