Когда я использую xpath, выберите в соответствии с xslt ниже
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns="urn:ROCK-BlueScope/ShipmentImportWS"
exclude-result-prefixes="ns">
<xsl:template match="/">
<ManifestSourceM>
<xsl:for-each select="ns:Shipment/ns:ShipmentInformation">
<DSManifest>
<ManifestNo>
<xsl:value-of select="ns:GeneralShipmentInformation/ns:ShipmentIdentificationNumber"></xsl:value-of>
</ManifestNo>
<ManifestDate>
<xsl:value-of select="ns:DateTimeReference/ns:Date"></xsl:value-of>
</ManifestDate>
<PrimeMover>
<xsl:value-of select="ns:EquipmentDetailsLoop/ns:EquipmentDetails[ns:EquipmentStructure/ns:DescriptionCode = 'TV'][1]/ns:EquipmentStructure/ns:EquipmentNumber"></xsl:value-of>
</PrimeMover>
<Fleet1>
<xsl:value-of select="ns:EquipmentDetailsLoop/ns:EquipmentDetails[ns:EquipmentStructure/ns:DescriptionCode = 'TL'][1]/ns:EquipmentStructure/ns:EquipmentNumber[1]"></xsl:value-of>
</Fleet1>
<Fleet2>
<xsl:value-of select="ns:EquipmentDetailsLoop/ns:EquipmentDetails[ns:EquipmentStructure/ns:DescriptionCode = 'TL'][2]/ns:EquipmentStructure/ns:EquipmentNumber[2]"></xsl:value-of>
</Fleet2>
<Fleet3>
<xsl:value-of select="ns:EquipmentDetailsLoop/ns:EquipmentDetails[ns:EquipmentStructure/ns:DescriptionCode = 'TL'][3]/ns:EquipmentStructure/ns:EquipmentNumber[3]"></xsl:value-of>
</Fleet3>
<Fleet4>
<xsl:value-of select="ns:EquipmentDetailsLoop/ns:EquipmentDetails[ns:EquipmentStructure/ns:DescriptionCode = 'TL'][4]/ns:EquipmentStructure/ns:EquipmentNumber[4]"></xsl:value-of>
</Fleet4>
<Fleet5>
<xsl:value-of select="ns:EquipmentDetailsLoop/ns:EquipmentDetails[ns:EquipmentStructure/ns:DescriptionCode = 'TL'][5]/ns:EquipmentStructure/ns:EquipmentNumber[5]"></xsl:value-of>
</Fleet5>
<RouteCode>
<xsl:value-of select="ns:GeneralShipmentInformation/ns:StandardCarrierAlphaCode"></xsl:value-of>
</RouteCode>
<Description><xsl:value-of select="string-join(('BlueScope Load:', ns:GeneralShipmentInformation/ns:ShipmentIdentificationNumber, ' On RunCode:', ns:GeneralShipmentInformation/ns:StandardCarrierAlphaCode), '')"></xsl:value-of>
</Description>
<Description2></Description2>
</DSManifest>
</xsl:for-each>
</ManifestSourceM>
</xsl:template>
</xsl:stylesheet>
И применить его к этому XML
<?xml version="1.0" encoding="UTF-8"?>
<ns:Shipment xmlns:ns="urn:ROCK-BlueScope/ShipmentImportWS">
<ns:ShipmentInformation Transaction="Actual">
<ns:GeneralShipmentInformation>
<ns:TransactionSetPurposeCode>00</ns:TransactionSetPurposeCode>
<ns:TransportationMethodTypeCode>L</ns:TransportationMethodTypeCode>
<ns:ShipmentMethodOfPayment>DE</ns:ShipmentMethodOfPayment>
<ns:ShipmentIdentificationNumber>178896</ns:ShipmentIdentificationNumber>
<ns:StandardCarrierAlphaCode>NUNCOL</ns:StandardCarrierAlphaCode>
</ns:GeneralShipmentInformation>
<ns:Priority>0</ns:Priority>
<ns:DateTimeReference SegmentId="StartTime">
<ns:Date>2010-12-09</ns:Date>
<ns:Time>07:00:00</ns:Time>
</ns:DateTimeReference>
<ns:Origin>
<ns:GeographicLocation>
<ns:LocationIdentifier>NUN</ns:LocationIdentifier>
</ns:GeographicLocation>
</ns:Origin>
<ns:Destination>
<ns:GeographicLocation>
<ns:LocationIdentifier>~COMPLETE STEEL ROOFING</ns:LocationIdentifier>
</ns:GeographicLocation>
</ns:Destination>
<ns:EquipmentDetailsLoop>
<ns:EquipmentDetails>
<ns:EquipmentStructure>
<ns:Initial/>
<ns:EquipmentNumber>Z26GW</ns:EquipmentNumber>
<ns:DescriptionCode>TV</ns:DescriptionCode>
</ns:EquipmentStructure>
</ns:EquipmentDetails>
</ns:EquipmentDetailsLoop>
<ns:EquipmentDetailsLoop>
<ns:EquipmentDetails>
<ns:EquipmentStructure>
<ns:Initial/>
<ns:EquipmentNumber>B16KY-5</ns:EquipmentNumber>
<ns:DescriptionCode>TL</ns:DescriptionCode>
</ns:EquipmentStructure>
</ns:EquipmentDetails>
</ns:EquipmentDetailsLoop>
<ns:EquipmentDetailsLoop>
<ns:EquipmentDetails>
<ns:EquipmentStructure>
<ns:Initial/>
<ns:EquipmentNumber>B16KY-4</ns:EquipmentNumber>
<ns:DescriptionCode>TL</ns:DescriptionCode>
</ns:EquipmentStructure>
</ns:EquipmentDetails>
</ns:EquipmentDetailsLoop>
<ns:EquipmentDetailsLoop>
<ns:EquipmentDetails>
<ns:EquipmentStructure>
<ns:Initial/>
<ns:EquipmentNumber>B16KY-2</ns:EquipmentNumber>
<ns:DescriptionCode>TL</ns:DescriptionCode>
</ns:EquipmentStructure>
</ns:EquipmentDetails>
</ns:EquipmentDetailsLoop>
<ns:EquipmentDetailsLoop>
<ns:EquipmentDetails>
<ns:EquipmentStructure>
<ns:Initial/>
<ns:EquipmentNumber>B16KY-3</ns:EquipmentNumber>
<ns:DescriptionCode>TL</ns:DescriptionCode>
</ns:EquipmentStructure>
</ns:EquipmentDetails>
</ns:EquipmentDetailsLoop>
<ns:EquipmentDetailsLoop>
<ns:EquipmentDetails>
<ns:EquipmentStructure>
<ns:Initial/>
<ns:EquipmentNumber>B16KY-1</ns:EquipmentNumber>
<ns:DescriptionCode>TL</ns:DescriptionCode>
</ns:EquipmentStructure>
</ns:EquipmentDetails>
</ns:EquipmentDetailsLoop>
</ns:ShipmentInformation>
</ns:Shipment>
Я понял это. Элемент Fleet1 содержит все вхождения.
<?xml version="1.0" encoding="UTF-8"?>
<ManifestSourceM>
<DSManifest>
<ManifestNo>178896</ManifestNo>
<ManifestDate>2010-12-09</ManifestDate>
<PrimeMover>Z26GW</PrimeMover>
<Fleet1>B16KY-5 B16KY-4 B16KY-2 B16KY-3 B16KY-1</Fleet1>
<Fleet2/>
<Fleet3/>
<Fleet4/>
<Fleet5/>
<RouteCode>NUNCOL</RouteCode>
<Description>BlueScope Load:178896 On RunCode:NUNCOL</Description>
<Description2/>
</DSManifest>
</ManifestSourceM>
Я даже пытался с каждой группой и выбирал ... когда это было специфично для каждого случая, но все же получил тот же результат.
Я не мог понять, как использовать это в методе выбора ... когда.
<xsl:number count="EquipmentDetailsLoop[normalize-space(EquipmentDetails/EquipmentStructure/DescriptionCode)='TL']" level="single"></xsl:number>