我正在尝试使用分隔符“|”将 xml 转换为本机平面文件格式。我坚持要获得最后一个先例复杂类型。我需要在 TotalRec 中分配这个计数值。
这是我的 XSLT:-
<xsl:stylesheet version="1.0"
xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
xmlns:ns1="http://TargetNamespace.com/WriteGSIASNFile"
xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/file/WMStoATG/WMSShipmentConfirmation/ReadWMSShipmentConfirmationFile"
xmlns:pc="http://xmlns.oracle.com/pcbpel/"
xmlns:imp1="http://www.manh.com/ILSNET/Interface"
xmlns:bpm="http://xmlns.oracle.com/bpmn20/extensions"
xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:ora="http://schemas.oracle.com/xpath/extension"
xmlns:socket="http://www.oracle.com/XSL/Transform/java/oracle.tip.adapter.socket.ProtocolTranslator"
xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction"
xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
xmlns:dvm="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"
xmlns:ns0="http://xmlns.oracle.com/pcbpel/adapter/file/WMStoRMS/WMSShipmentConfirmation/WriteGSIASNFile"
xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/"
xmlns:med="http://schemas.oracle.com/mediator/xpath"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
xmlns:xdk="http://schemas.oracle.com/bpel/extension/xpath/function/xdk"
xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
exclude-result-prefixes="xsi xsl tns pc imp1 plt wsdl jca xsd ns1 ns0 xp20 bpws bpel bpm ora socket mhdr oraext dvm hwf med ids xdk xref ldap">
<xsl:template match="/">
<xsl:variable name="RecordCount"
select="count(/imp1:WMWROOT/imp1:WMWDATA/imp1:WMFWUpload/imp1:Shipments/imp1:Shipment/imp1:Containers/imp1:ShippingContainer/imp1:NestedContainers/imp1:ShippingContainer/imp1:ContainerDetails/imp1:ContainerDetail)"/>
<ns1:ASN-Feed>
<xsl:for-each select="/imp1:WMWROOT/imp1:WMWDATA/imp1:WMFWUpload/imp1:Shipments/imp1:Shipment">
<xsl:if test='((/imp1:WMWROOT/imp1:WMWDATA/imp1:WMFWUpload/imp1:Shipments/imp1:Shipment/imp1:OrderType = "Refill") or (/imp1:WMWROOT/imp1:WMWDATA/imp1:WMFWUpload/imp1:Shipments/imp1:Shipment/imp1:OrderType = "Store Order")) and ((/imp1:WMWROOT/imp1:WMWDATA/imp1:WMFWUpload/imp1:Shipments/imp1:Shipment/imp1:Warehouse = "8001") and (/imp1:WMWROOT/imp1:WMWDATA/imp1:WMFWUpload/imp1:Shipments/imp1:Shipment/imp1:Details/imp1:ShipmentDetail[1]/imp1:UserDef3 != ""))'>
<xsl:variable name="BolNumAlpha" select="imp1:BolNumAlpha"/>
<xsl:for-each select="imp1:Containers/imp1:ShippingContainer">
<xsl:for-each select="imp1:NestedContainers/imp1:ShippingContainer">
<xsl:variable name="ContainerId" select="imp1:ContainerId"/>
<xsl:for-each select="imp1:ContainerDetails/imp1:ContainerDetail">
<xsl:variable name="ErpOrderContLevel" select="imp1:ErpOrder"/>
<xsl:variable name="ErpOrderLineNumContLevel"
select="imp1:ErpOrderLineNum"/>
<xsl:variable name="Position" select="position()"/>
<ns1:Header>
<ns1:StoreNum>
<xsl:text disable-output-escaping="no">763</xsl:text>
</ns1:StoreNum>
<ns1:ReceivingType>
<xsl:text disable-output-escaping="no">A</xsl:text>
</ns1:ReceivingType>
<ns1:PartnerShipmentNum>
<xsl:text disable-output-escaping="no"></xsl:text>
</ns1:PartnerShipmentNum>
<ns1:OrderDate>
<xsl:text disable-output-escaping="no"></xsl:text>
</ns1:OrderDate>
<ns1:ShipmentReceiptDate>
<xsl:value-of select='xp20:format-dateTime(xp20:current-date(),"[Y01]-[M01]-[D01]")'/>
</ns1:ShipmentReceiptDate>
<ns1:ShipperName>
<xsl:text disable-output-escaping="no">001 GARAGE MONTREAL</xsl:text>
</ns1:ShipperName>
<xsl:for-each select="../../../../../../imp1:Details/imp1:ShipmentDetail">
<xsl:variable name="ErpOrderDetailLevel"
select="imp1:ErpOrder"/>
<xsl:variable name="ErpOrderLineNumDetailLevel"
select="imp1:ErpOrderLineNum"/>
<xsl:variable name="ItemSKU" select="imp1:SKU/imp1:Item"/>
<xsl:if test="($ErpOrderDetailLevel = $ErpOrderContLevel) and ($ErpOrderLineNumDetailLevel = $ErpOrderLineNumContLevel)">
<ns1:PartnerItemNum>
<xsl:value-of select="$ItemSKU"/>
</ns1:PartnerItemNum>
</xsl:if>
</xsl:for-each>
<xsl:choose>
<xsl:when test="imp1:Quantity">
<ns1:QuantityShipped>
<xsl:value-of select="number(imp1:Quantity)"/>
</ns1:QuantityShipped>
</xsl:when>
<xsl:otherwise>
<ns1:QuantityShipped>
<xsl:value-of select="imp1:Quantity"/>
</ns1:QuantityShipped>
</xsl:otherwise>
</xsl:choose>
<ns1:ItemCost>
<xsl:text disable-output-escaping="no"></xsl:text>
</ns1:ItemCost>
<ns1:ShippingComments>
<xsl:text disable-output-escaping="no"></xsl:text>
</ns1:ShippingComments>
<ns1:TrailerNumber>
<xsl:text disable-output-escaping="no"></xsl:text>
</ns1:TrailerNumber>
<xsl:choose>
<xsl:when test="string-length($Position) > 1.0">
<ns1:CartonId>
<xsl:value-of select="concat(substring($ContainerId,3.0),$Position)"/>
</ns1:CartonId>
</xsl:when>
<xsl:otherwise>
<ns1:CartonId>
<xsl:value-of select='concat(substring($ContainerId,3.0),concat("0",position()))'/>
</ns1:CartonId>
</xsl:otherwise>
</xsl:choose>
<ns1:ASNNumber>
<xsl:value-of select="../../../../../../imp1:BolNumAlpha"/>
</ns1:ASNNumber>
<ns1:CreateDateTime>
<xsl:value-of select='xp20:format-dateTime(xp20:current-dateTime(),"[Y0001]-[M01]-[D01]-[H01].[m01].[s01]")'/>
</ns1:CreateDateTime>
<ns1:Warehouse>
<xsl:text disable-output-escaping="no">235</xsl:text>
</ns1:Warehouse>
</ns1:Header>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
<ns1:Trailer>
<ns1:RecordId>
<xsl:text disable-output-escaping="no">TRAILER</xsl:text>
</ns1:RecordId>
<ns1:TotalRec>
<xsl:value-of select="$RecordCount + 1.0"/>
</ns1:TotalRec>
<ns1:BatchId>
<xsl:value-of select="/imp1:WMWROOT/imp1:WMWDATA/imp1:WMFWUpload/imp1:Shipments/imp1:Shipment[1]/imp1:ShippingLoadNum"/>
</ns1:BatchId>
</ns1:Trailer>
</ns1:ASN-Feed>
</xsl:template>
</xsl:stylesheet>
这是 XML:-
<WMWROOT xmlns="http://www.manh.com/ILSNET/Interface">
<WMWDATA>
<WMFWUpload xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Date>2013-03-18T16:42:50.0398834-04:00</Date>
<GroupIndex>1</GroupIndex>
<Id>e229d320-0c30-4e97-a01f-d4d1ef779303</Id>
<NumGroups>1</NumGroups>
<NumRecs>2</NumRecs>
<Shipments>
<Shipment>
<BolNumAlpha>08264940000006126</BolNumAlpha>
<Carrier>
<Condition>Shipped</Condition>
</Carrier>
<Customer>
<Company>Garage</Company>
<Customer>30000</Customer>
<CustomerCategories/>
<ShipTo>30000</ShipTo>
</Customer>
<ErpOrder>3000013661</ErpOrder>
<OrderType>Refill</OrderType>
<Warehouse>8051</Warehouse>
<Details>
<ShipmentDetail>
<UserDef1>Y</UserDef1>
<UserDef3>30000</UserDef3>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>1.00000</ErpOrderLineNum>
<SKU>
<Item>3085142</Item>
</SKU>
</ShipmentDetail>
<ShipmentDetail>
<UserDef1>Y</UserDef1>
<UserDef3>30000</UserDef3>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>2.00000</ErpOrderLineNum>
<SKU>
<Item>3085142</Item>
</SKU>
</ShipmentDetail>
<ShipmentDetail>
<UserDef1>Y</UserDef1>
<UserDef3>30000</UserDef3>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>3.00000</ErpOrderLineNum>
<SKU>
<Item>3085142</Item>
</SKU>
</ShipmentDetail>
<ShipmentDetail>
<UserDef1>Y</UserDef1>
<UserDef3>30000</UserDef3>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>4.00000</ErpOrderLineNum>
<SKU>
<Item>3085142</Item>
</SKU>
</ShipmentDetail>
<ShipmentDetail>
<UserDef1>Y</UserDef1>
<UserDef3>30000</UserDef3>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>5.00000</ErpOrderLineNum>
<SKU>
<Item>3085142</Item>
</SKU>
</ShipmentDetail>
<ShipmentDetail>
<UserDef1>Y</UserDef1>
<UserDef3>30000</UserDef3>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>6.00000</ErpOrderLineNum>
<SKU>
<Item>3085142</Item>
</SKU>
</ShipmentDetail>
<ShipmentDetail>
<UserDef1>Y</UserDef1>
<UserDef3>30000</UserDef3>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>7.00000</ErpOrderLineNum>
<SKU>
<Item>3085142</Item>
</SKU>
</ShipmentDetail>
<ShipmentDetail>
<UserDef1>Y</UserDef1>
<UserDef3>30000</UserDef3>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>8.00000</ErpOrderLineNum>
<SKU>
<Item>3085142</Item>
</SKU>
</ShipmentDetail>
<ShipmentDetail>
<UserDef1>Y</UserDef1>
<UserDef3>30000</UserDef3>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>9.00000</ErpOrderLineNum>
<SKU>
<Item>3085142</Item>
</SKU>
</ShipmentDetail>
</Details>
<Containers>
<ShippingContainer>
<ContainerID>0000000000000000000</ContainerID>
<ContainerType>
<Type>PALLET</Type>
</ContainerType>
<NestedContainers>
<ShippingContainer>
<ContainerId>00008264940000019935</ContainerId>
<ContainerDetails>
<ContainerDetail>
<BundleId>0</BundleId>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>1.00000</ErpOrderLineNum>
<Quantity>1.00000</Quantity>
<QuantityUm>Each</QuantityUm>
</ContainerDetail>
<ContainerDetail>
<BundleId>0</BundleId>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>1.00000</ErpOrderLineNum>
<Quantity>2.00000</Quantity>
<QuantityUm>Each</QuantityUm>
</ContainerDetail>
<ContainerDetail>
<BundleId>0</BundleId>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>1.00000</ErpOrderLineNum>
<Quantity>3.00000</Quantity>
<QuantityUm>Each</QuantityUm>
</ContainerDetail>
<ContainerDetail>
<BundleId>0</BundleId>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>1.00000</ErpOrderLineNum>
<Quantity>4.00000</Quantity>
<QuantityUm>Each</QuantityUm>
</ContainerDetail>
<ContainerDetail>
<BundleId>0</BundleId>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>1.00000</ErpOrderLineNum>
<Quantity>5.00000</Quantity>
<QuantityUm>Each</QuantityUm>
</ContainerDetail>
<ContainerDetail>
<BundleId>0</BundleId>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>6.00000</ErpOrderLineNum>
<Quantity>6.00000</Quantity>
<QuantityUm>Each</QuantityUm>
</ContainerDetail>
<ContainerDetail>
<BundleId>0</BundleId>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>7.00000</ErpOrderLineNum>
<Quantity>6.00000</Quantity>
<QuantityUm>Each</QuantityUm>
</ContainerDetail>
<ContainerDetail>
<BundleId>0</BundleId>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>8.00000</ErpOrderLineNum>
<Quantity>6.00000</Quantity>
<QuantityUm>Each</QuantityUm>
</ContainerDetail>
<ContainerDetail>
<BundleId>0</BundleId>
<ErpOrder>3000013661</ErpOrder>
<ErpOrderLineNum>9.00000</ErpOrderLineNum>
<Quantity>6.00000</Quantity>
<QuantityUm>Each</QuantityUm>
</ContainerDetail>
</ContainerDetails>
<ContainerType>
<ProcessStamp>fe4e12f2-ac06-4786-b1ff-509c82792d45</ProcessStamp>
<UserStamp>sboisvert</UserStamp>
<Class>Carton(s)</Class>
<Desc>Carton</Desc>
<DimensionUm>IN</DimensionUm>
<Height>20.00000</Height>
<Length>20.00000</Length>
<MaxWeight>70.00000</MaxWeight>
<Type>Carton</Type>
<UseAsDefault>Y</UseAsDefault>
<Volume>8000.00000</Volume>
<Weight>0.50000</Weight>
<WeightUm>LB</WeightUm>
<WeightTolerance>1.00000</WeightTolerance>
<Width>20.00000</Width>
</ContainerType>
<GroupNum>0</GroupNum>
<GroupPosition>0</GroupPosition>
<InternalContainerNum>1008185</InternalContainerNum>
<InternalShipmentNum>1009736</InternalShipmentNum>
<ManifestId/>
<ManifestState/>
<Msn>0</Msn>
<Status>900</Status>
<StatusFailed>N</StatusFailed>
<TotalAccCharge>0.00000</TotalAccCharge>
<TotalFreightCharge>0.00000</TotalFreightCharge>
<TotalFreightDiscount>0.00000</TotalFreightDiscount>
<TotalQuantity>71.00000</TotalQuantity>
<TotalValue>0.00000</TotalValue>
<TotalWeight>36.10000</TotalWeight>
<TreeUnit>1008185</TreeUnit>
<WeightUm>KG</WeightUm>
</ShippingContainer>
</NestedContainers>
</ShippingContainer>
</Containers>
</Shipment>
</Shipments>
</WMFWUpload>
</WMWDATA>
</WMWROOT>
我喜欢获取 Header 的计数(可以在 xslt 中看到)并且必须分配给 TotalRec。
我想使用相同的 xslt 获得计数,因为我使用另一个 xslt 然后我的整个设计必须改变。
所以有人可以给我解决方案或逻辑。
样本输出 <
ns1:ASN-Feed><ns1:Header><ns1:StoreNum>763</ns1:StoreNum>
<ns1:ReceivingType>A</ns1:ReceivingType><ns1:PartnerShipmentNum/><ns1:OrderDate/> <ns1:ShipmentReceiptDate>13-03-21</ns1:ShipmentReceiptDate><ns1:ShipperName>001 GARAGE MONTREAL</ns1:ShipperName><ns1:PartnerItemNum>3088853</ns1:PartnerItemNum> <ns1:QuantityShipped>1</ns1:QuantityShipped><ns1:ItemCost/><ns1:ShippingComments/>
<ns1:TrailerNumber/><ns1:CartonId>00826494000001913301</ns1:CartonId> <ns1:ASNNumber>08264940000006140</ns1:ASNNumber> <ns1:CreateDateTime>2013-03-21-09.50.38</ns1:CreateDateTime><ns1:Warehouse>235</ns1:Warehouse>
</ns1:Header><ns1:Trailer><ns1:RecordId>TRAILER</ns1:RecordId><ns1:TotalRec>1</ns1:TotalRec>
<ns1:BatchId>1002012</ns1:BatchId></ns1:Trailer></ns1:ASN-Feed>
请注意,此示例与提供的 XML 无关
问候。