我有一个XSL,我得到6个变量的值。 6个变量有一个整数值,比如3,4等。我需要检查所有6个变量是否具有相同的值。我如何在XSL中实现这一点? 我的XML是:如何检查多个变量在XSL中是否具有相同的值?
<records>
<A>
<Value> test </Value>
<Value> test </Value>
<Value> test </Value>
</A>
<B>
<Value> test </Value>
</B>
<C>
<Value> test </Value>
<Value> test </Value>
</C>
<D>
<Value> test </Value>
</D>
<E>
<Value> test </Value>
<Value> test </Value>
</E>
<F>
<Value> test </Value>
</F>
</records>
我的XSL是这样的:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
<xsl:variable
name="noOfANodes"
select="count(/records/A/*)">
</xsl:variable>
<xsl:variable
name="noOfBNodes"
select="count(/records/B/*)">
</xsl:variable>
<xsl:variable
name="noOfCNodes"
select="count(/records/C/*)">
</xsl:variable>
<xsl:variable
name="noOfDNodes"
select="count(/records/D/*)">
</xsl:variable>
<xsl:variable
name="noOfENodes"
select="count(/records/E/*)">
</xsl:variable>
<xsl:variable
name="noOfFNodes"
select="count(/records/F/*)">
</xsl:variable>
<xsl:template match="/">
<xsl:choose>
<!-- The following is obv wrong. -->
<xsl:when test="$noOfANodes=$noOfBNodes=$noOfCNodes=$noOfDNodes">
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
XSLT 2是XSLT的一个单独的版本?我如何使用它? – Chandeep
@Chandeep你必须有一个XSLT2处理器。撒克逊是最广泛使用的开源软件之一。否则,只需要在样式表上设置版本(您已将版本设置为2.0)并理解两个版本之间的差异即可。 XSLT2增加了一些功能,并且有一些功能的工作方式不同。 – Matthew
谢谢!这有帮助 – Chandeep