xslt数组中的计数值

xslt数组中的计数值,xslt,Xslt,我有以下XSLT 我想检查数组中某个元素的计数 示例:-这里我想检查数组中A的计数 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:map="http://www.w3.org/2005/xpath-functions/map"

我有以下XSLT

我想检查数组中某个元素的计数

示例:-这里我想检查数组中
A
的计数

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:map="http://www.w3.org/2005/xpath-functions/map"
    xmlns:array="http://www.w3.org/2005/xpath-functions/array" exclude-result-prefixes="#all"
    version="3.0">
    <xsl:output omit-xml-declaration="yes" indent="yes"/>
    <xsl:param name="input"/>
    
    <xsl:variable name="newline" select="'&#10;'"/>
    <xsl:template match="/" name="xsl:initial-template">
        <xsl:variable name="input-as-map" select="parse-json($input)" as="map(*)"/>
        <root>
            
            <!-- storing all the PERSONNUMBER present in the ibop -->
            <xsl:variable name="array" as="element()*">
               
                    <Item>A</Item>
                    <Item>A</Item>
                    <Item>A</Item>
                    <Item>b</Item>              
            </xsl:variable>
            <test>
                <xsl:value-of select="count($array/Item='A')"/>
            </test>            
        </root>
    </xsl:template>    
</xsl:stylesheet>

A.
A.
A.
B

任何建议都会有帮助……。

您可以这样做:

<xsl:variable name="array">
  <Item>A</Item>
  <Item>A</Item>
  <Item>A</Item>
  <Item>b</Item>              
</xsl:variable>
<test>
  <xsl:value-of select="count($array/Item[.='A'])"/>
</test>

A.
A.
A.
B

给定声明
您有一个元素节点序列,而不是数组。您需要
计数($array[.='A'])