您能告诉我如何在XSLT中应用for-loop吗?XSLT:如何申请循环?
这是我的live code at xsltransform.net。
XML:
<?xml version="1.0" encoding="UTF-8"?>
<body>
<h1>A new version of xsltransform.net is released!</h1>
<p>We have added the following new features:</p>
<ul>
<li>A new XSLT engine is added: Saxon 9.5 EE, with a license (thank you Michael Kay!)</li>
<li>XSLT 3.0 support when using the new Saxon 9.5 EE engine!</li>
<li>Preview your result as HTML when doctype is set to HTML (see this example)</li>
<li>Preview your result as PDF when doctype is set to XML and your document starts with root element of XSL-FO. Apache FOP is used to generate the PDF</li>
<li>Added some links to useful XSLT sites</li>
</ul>
</body>
我的XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="test" select="'ss'"/>
<xsl:variable name="inline-array">
<Item>A</Item>
<Item>B</Item>
<Item>C</Item>
</xsl:variable>
<xsl:param name="array" select="document('')/*/xsl:variable[@name='inline-array']/*"/>
<xsl:template match="/">
<xsl:for-each select="$inline-array">
<h1><xsl:value-of select="."/></h1>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
预期输出
<h1>A</h1>
<h1>B</h1>
<h1>C</h1>
样式表声明1.0版本,但你用XSLT 2.0处理器测试它。 **它在XSLT 1.0 **中不起作用:http://xsltransform.net/gWEamLL/5 ---更不用说单个的'就足够了。 –