Hi,
Within the following code, There are 2 'OrderLines' which are calculated at the foot of the code in the 'OrderControlTotals/TotalNumberOfLines' element. I need to perform a calculation on the repeated lines that begin 'Quantity QuantityType="Order Quantity" QuantityUOM' to be output in the element 'TotalQuantity' (Shown as 'XXXX'). The current XSLT is displayed after the XML.
[u]XML</u>
Code:
<QQQOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://QQQ.com/QQQXML/Schemas/v3_0_1/QQQOrd.xsd" OrderType="Standalone Order" DocumentType="New">
<F4FDocumentHeader>
<SchemaVersion>3</SchemaVersion>
<SchemaStatus>Approved</SchemaStatus>
<DocumentCreated DateTimeType="Document Created">20070315 09:32</DocumentCreated>
<DocumentTrackingId>56709</DocumentTrackingId>
<DocumentRevisionNumber>1</DocumentRevisionNumber>
<SourcePartnerID>AT</SourcePartnerID>
<SourceDivisionID>KA</SourceDivisionID>
<DestinationPartnerID>ASATST</DestinationPartnerID>
</F4FDocumentHeader>
<OrderHeader>
....
</OrderHeader>
<TransportDetails>
....
</TransportDetails>
<OrderLine LineNumber="1">
<LineReference ReferenceType="Contract Number" AssignedBy="Buyer">0006509602/01</LineReference>
<LineReference ReferenceType="Contract Number" AssignedBy="Supplier">ppersupref</LineReference>
<ProductReference ReferenceType="Assigned By Buyer">496500</ProductReference>
<ProductDescription Type="Defined by Buyer">REGULATOR 1</ProductDescription>
<ProductValues>
<Quantity QuantityType="Order Quantity" QuantityUOM="Unit">1000</Quantity>
<UnitPrice PriceUOM="Unit">0.59</UnitPrice>
</ProductValues>
</OrderLine>
<OrderLine LineNumber="2">
<LineReference ReferenceType="Contract Number" AssignedBy="Buyer">0006509602/01</LineReference>
<LineReference ReferenceType="Contract Number" AssignedBy="Supplier">ppersupref</LineReference>
<ProductReference ReferenceType="Assigned By Buyer">496700</ProductReference>
<ProductDescription Type="Defined by Buyer">REGULATOR 2</ProductDescription>
<ProductValues>
<Quantity QuantityType="Order Quantity" QuantityUOM="Unit">500</Quantity>
<UnitPrice PriceUOM="Unit">0.59</UnitPrice>
</ProductValues>
</OrderLine>
<OrderControlTotals>
<TotalNumberOfLines>2</TotalNumberOfLines>
<TotalQuantity>XXXX</TotalQuantity>
</OrderControlTotals>
</QQQOrder>
[u]XSLT</u>
Code:
<xsl:template name="OrderLine">
<xsl:for-each select="../OrderLine[@LineNumber]">
<OrderLine LineNumber="{position()}">
<xsl:element name="ProductValues">
<Quantity ReferenceType="QuantityType" AssignedBy="Order Quantity">
<xsl:choose>
<xsl:when test="ProductReference[@ReferenceType]='496500'">
<xsl:value-of select="(ProductValues/Quantity[@QuantityType='Order Quantity']) div 100"/>
</xsl:when>
<xsl:when test="ProductReference[@ReferenceType]='496700'">
<xsl:value-of select="(ProductValues/Quantity[@QuantityType='Order Quantity']) div 50"/>
</xsl:when>
....
etc.
....
<xsl:otherwise>
<xsl:value-of select="'UNKNOWN'"/>
</xsl:otherwise>
</xsl:choose>
</Quantity>
</xsl:element>
</OrderLine>
</xsl:for-each>
</xsl:template>
So, the line that I need to 'accumulate' (running total) are the results of
Code:
<xsl:value-of select="(ProductValues/Quantity[@QuantityType='Order Quantity']) div XX"/>
Where, 'XX' is specific to the 'ProductReference'. In the XML example above, they are (1000 / 100) and (500 / 50).
(10 + 10 = 20).
Therefore, 'TotalQuantity' should = 20
How do I perform this?
Thanks in advance,
Neal
A Northern Soul