centos 7.4搭建lamp:帮我看看这个xsl

来源:百度文库 编辑:中科新闻网 时间:2024/05/14 19:03:38
<?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>