我有一個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