2016数学竞赛文件:帮我看看这个xsl

来源:百度文库 编辑:高考问答 时间:2024/05/14 14:23:50
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="root">
that is
<xsl:value-of select="second"/>
</xsl:template>

<xsl:template match="root">
this is
<xsl:value-of select="first"/>
</xsl:template>
</xsl:stylesheet>
root是根元素 first和second是两个子元素 这样写为什么只能出现一个?

root的模板定义了2次,当然只有一个能显示了
改成下面的样子就可以了:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="root">
this is
<xsl:value-of select="first"/>
that is
<xsl:value-of select="second"/>
</xsl:template>
</xsl:stylesheet>