необходимо подсчитать количество дочерних узлов и узла Grand Childs of Parent во всех дочерних уровнях для следующего XML.
Как найти, количество детей до <regPackagingHierarchyList>
с
узел как <recordId>
Я попробовал следующий код
<xsl:for-each select="LSRIMSData/agl_result/RegistrationPackaging/regPackagingHierarchyList/RegistrationPackagingHierarchy[recordId/text()!='']">
<xsl:value-of select="count(child::regParentPackagingHierarchy/RegistrationPackagingHierarchy/recordId/node())"></xsl:value-of>
</xsl:for-each>
Исходный XML:
<agConnectXML>
<SourceData>
<SKUIDOut noNamespaceSchemaLocation="file:///c:/Users/BODDUAV1/OneDrive%20-%20Novartis%20Pharma%20AG/Avanthi/NovaRIM/Documents/SHAPE/stockKeepingUnit.xsd" schemaVersion="1.0">
<SystemMessageHeader>
<CreationDateTime>2002-10-10T12:00:00-05:00</CreationDateTime>
<SenderID>sandoz</SenderID>
<BusinessSystemID>SHAPE-P34-SKU</BusinessSystemID>
<MessageID>678678-2389789-4893947-473946</MessageID>
</SystemMessageHeader>
<stockKeepingUnit>40</stockKeepingUnit>
<stockKeepingUnitStatus>Approved</stockKeepingUnitStatus>
<nationalTradeItemNumber>098098</nationalTradeItemNumber>
<registrationId>REG-00000026</registrationId>
<finishedDosageFormId>FDF-002</finishedDosageFormId>
<activeSusbstanceId>6437</activeSusbstanceId>
<tenant>sandoz</tenant>
</SKUIDOut>
</SourceData>
<LSRIMSData>
<agl_result>
<agl_service_headers>
<serviceId>CustgetRegPackDetails</serviceId>
<messageProducer>agidmp</messageProducer>
<internalVersion>12077</internalVersion>
<uuid>5670bf06-4f0a-4f0f-ab93-2d2ad99a7384</uuid>
<dateFormat>yyyy-MM-dd H:mm:ss</dateFormat>
<generatedTimeStamp>2019-04-04 20:02:09</generatedTimeStamp>
<user>system</user>
</agl_service_headers>
<agl_pagination_details>
<start>0</start>
<limit>10</limit>
<totalRecordsCount>1</totalRecordsCount>
</agl_pagination_details>
<RegistrationPackaging>
<productPackaging>
<ProductPackaging>
<packagingItemName>FDF-002</packagingItemName>
</ProductPackaging>
</productPackaging>
<regIncludedProduct>
<RegistrationIncludedProduct>
<recordId>43893</recordId>
<registration>
<Registration>
<dataState>C</dataState>
<recordId>43887</recordId>
<registrationUID>REG-00000026</registrationUID>
</Registration>
</registration>
</RegistrationIncludedProduct>
</regIncludedProduct>
<regPackagingHierarchyList>
<RegistrationPackagingHierarchy>
<recordId>43914</recordId>
<regParentPackagingHierarchy>
<RegistrationPackagingHierarchy>
<recordId>43912</recordId>
</RegistrationPackagingHierarchy>
</regParentPackagingHierarchy>
<regPkgHierarchyDataCarrierList></regPkgHierarchyDataCarrierList>
<regErpCodesList></regErpCodesList>
</RegistrationPackagingHierarchy>
<RegistrationPackagingHierarchy>
<recordId>43916</recordId>
<regParentPackagingHierarchy>
<RegistrationPackagingHierarchy>
<recordId>43914</recordId>
<regParentPackagingHierarchy>
<RegistrationPackagingHierarchy>
<recordId>43912</recordId>
<regParentPackagingHierarchy>
<RegistrationPackagingHierarchy>
<recordId>43916</recordId>
</RegistrationPackagingHierarchy>
</regParentPackagingHierarchy>
</RegistrationPackagingHierarchy>
</regParentPackagingHierarchy>
</RegistrationPackagingHierarchy>
</regParentPackagingHierarchy>
<regPkgHierarchyDataCarrierList></regPkgHierarchyDataCarrierList>
<regErpCodesList></regErpCodesList>
</RegistrationPackagingHierarchy>
</regPackagingHierarchyList>
</RegistrationPackaging>
</agl_result>
</LSRIMSData>
</agConnectXML>
Ожидаемый результат будет в следующем формате
Количество (regParentPackagingHierarchy / RegistrationPackagingHierarchy / RecordIds)
= 1 счетчик (regParentPackagingHierarchy / RegistrationPackagingHierarchy / RecordIds)
= 3