<author>
所以我试图根据父元素中有多少元素打印略有不同的文本。给我带来麻烦的代码是when xsl代码
<?xml version="1.0" standalone="no" ?>
<?xml-stylesheet publisher="text/xsl" href="books3.xsl"?>
<books>
<book>
<title type="fiction">HG</title>
<author>Test</author>
<publisher>Junk</publisher>
<year>2001</year>
<price>29</price>
</book>
<book>
<title type="fiction">HP</title>
<author>Test1</author>
<author>Test1</author>
<publisher>Junk1</publisher>
<year>2002</year>
<price>29</price>
</book>
<book>
<title type="fiction">HG</title>
<author>Test</author>
<publisher>Junk</publisher>
<year>2001</year>
<price>40</price>
</book>
</books>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" version="4.0" />
<xsl:template match="/">
<div>
<xsl:for-each select="//book[price < 30]">
<span id="title"><xsl:value-of select="title"/></span>
<xsl:choose>
<xsl:when test="count(//author) > 1">
<span id="author"><xsl:value-of select="author"/> et al</span>
</xsl:when>
<xsl:when test="count(//author) = 1 ">
<span id="author"><xsl:value-of select="author"/></span>
</xsl:when>
</xsl:choose>
<span id="price"><xsl:value-of select="price"/></span>
</xsl:for-each>
</div>
</xsl:template>
</xsl:stylesheet>