0

我有以下有效载荷,我必须计算下的子元素数量<Document>。例如:

<Document>
  <Class>D</Class>`enter code here`
  <ClassDescription>Drawings</ClassDescription>
  <ClientDocumentNumber>12345</ClientDocumentNumber>
<Document>

计数将是 3。

有效载荷如下。检查此代码。

<?xml version="1.0" encoding="UTF-8"?>
<InputVariable>
    <part  name="payload">
        <ProjectMessage>
            <ConversationId>E53252F709653493E0401E0A13916A2E</ConversationId>
            <SourceApplicationId>Convero</SourceApplicationId>
            <Operation>INS DOC</Operation>
            <ModifiedByUserEmail>daviD.Woo@xyz.com</ModifiedByUserEmail>
            <Project>
                <Id>100020</Id>
                <DocumentList>
                    <Document>
                        <Class>D</Class>
                        <ClassDescription>Drawings</ClassDescription>
                        <ClientDocumentNumber>12345</ClientDocumentNumber>
                        <ClientRevisionNumber>2.0</ClientRevisionNumber>
                        <Discipline>141</Discipline>
                        <DisciplineDescription>ACN</DisciplineDescription>
                        <Facility>24</Facility>
                        <Number>100020-24-140-SKT-0002</Number>
                        <OSROriginator>086238</OSROriginator>
                        <Revision>2.0</Revision>
                        <RevisionDate>2013-02-11T00:00:00Z</RevisionDate>
                        <Status>A</Status>
                        <StatusDescription>Active</StatusDescription>
                        <SupplierDocumentNumber>523570.000</SupplierDocumentNumber>
                        <SupplierRevisionNumber>CCC</SupplierRevisionNumber>
                        <Title>Test for FileNet</Title>
                        <Type>NA</Type>
                        <TypeDescription>NA</TypeDescription>
                    </Document>
                </DocumentList>
            </Project>
        </ProjectMessage>
    </part>
</InputVariable>
4

1 回答 1

0
<xsl:template match="Document">
  <xsl:value-of select="count(*)"/>
</xsl:template>

是一个模板匹配Document元素并计算子元素。

于 2013-08-31T08:55:47.290 回答