CyberStore Documentation
SORTOI

See the example of SORTOI code below:

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" />
    <xsl:param name="WarehouseList" />
    <!--Comma Seperated list of warehouses to use. Should come for operator profile -->
    <xsl:param name="CustRequestDate" />
    <xsl:param name="OrderDate" />
    <xsl:param name="RequestedShipDate" />
    <xsl:param name="InvoiceDateEntered" />
    <xsl:param name="InvoiceTerms" />
    <xsl:param name="FreightCost" />
    <xsl:param name="FreightValue" />
    <xsl:param name="Discount1" />
    <xsl:param name="Discount2" />
    <xsl:param name="Discount3" />
    <xsl:param name="AlternateReference" />
    <xsl:param name="UseStockDescSupplied" />
    <xsl:param name="MiscTax" />
    <xsl:param name="OrderStatus" />
    <xsl:param name="TypeOfOrder" />
    <xsl:param name="OrderType" />
    <xsl:param name="MultiShipCode" />
    <xsl:param name="OrderMethod" />

    <!--
Main Loop Builds Order Header and Calls Stock Lines, FreightLines and Misc Lines
-->
    <xsl:template match="/">
        <SalesOrders xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="SORTOI.XSD">
            <Orders>
                <OrderHeader>
                    <AlternateReference>
                        <xsl:value-of select="normalize-space($AlternateReference)" />
                    </AlternateReference>
                    <RequestedShipDate>
                        <xsl:value-of select="$RequestedShipDate" />
                    </RequestedShipDate>
                    <CustomerPoNumber>
                        <xsl:variable name="POValue" select="normalize-space(/SalesOrder/OrderHeader/PO)" />
                        <xsl:if test="$POValue =''">
                            WEB<xsl:value-of select="/SalesOrder/OrderHeader/OrderHeader_ID" />
                        </xsl:if>
                        <xsl:if test="$POValue !=' '">
                            <xsl:value-of select="$POValue" />
                        </xsl:if>
                    </CustomerPoNumber>
                    <OrderActionType>A</OrderActionType>
                    <!-- Use e.net defaults
                        <Supplier>A</Supplier> 
                    -->
                    <Customer>
                        <xsl:value-of select="/SalesOrder/OrderHeader/CustomerNumber" />
                    </Customer>
                    <OrderDate>
                        <xsl:value-of select="$OrderDate" />
                    </OrderDate>
                    <ShippingInstrs>
                        <xsl:value-of select="/SalesOrder/OrderHeader/ShippingMethodName" />
                    </ShippingInstrs>
                    <ShippingInstrsCode>
                        <xsl:value-of select="/SalesOrder/OrderHeader/ShippingInstructionCode" />
                    </ShippingInstrsCode>
                    <CustomerName>
                        <xsl:value-of select="/SalesOrder/OrderHeader/Name" />
                    </CustomerName>
                    <xsl:if test="$MultiShipCode=''">
                        <ShipAddress1>
                            <xsl:value-of select="/SalesOrder/OrderHeader/Address1" />
                        </ShipAddress1>
                        <ShipAddress2>
                            <xsl:value-of select="/SalesOrder/OrderHeader/Address2" />
                        </ShipAddress2>
                        <ShipAddress3>
                            <xsl:value-of select="/SalesOrder/OrderHeader/Address3" />
                        </ShipAddress3>
                        <ShipAddress4>
                            <xsl:value-of select="/SalesOrder/OrderHeader/Address4" />
                        </ShipAddress4>
                        <ShipAddress5>
                            <xsl:value-of select="/SalesOrder/OrderHeader/Address5" />
                        </ShipAddress5>
                        <ShipPostalCode>
                            <xsl:value-of select="/SalesOrder/OrderHeader/Zip" />
                        </ShipPostalCode>
                    </xsl:if>
                    <xsl:if test="$MultiShipCode!=''">
                        <ShipAddress1 />
                        <ShipAddress2 />
                        <ShipAddress3 />
                        <ShipAddress4 />
                        <ShipAddress5 />
                        <ShipPostalCode />
                        <MultiShipCode>
                            <xsl:value-of select="$MultiShipCode" />
                        </MultiShipCode>
                    </xsl:if>
                    <Email>
                        <xsl:value-of select="/SalesOrder/OrderHeader/Email" />
                    </Email>
                    <OrderDiscPercent1>
                        <xsl:value-of select="$Discount1" />
                    </OrderDiscPercent1>
                    <OrderDiscPercent2>
                        <xsl:value-of select="$Discount2" />
                    </OrderDiscPercent2>
                    <OrderDiscPercent3>
                        <xsl:value-of select="$Discount3" />
                    </OrderDiscPercent3>
                    <Warehouse>
                        <xsl:value-of select="$WarehouseList" />
                    </Warehouse>
                    <SpecialInstrs>
                        <xsl:value-of select="/SalesOrder/OrderHeader/SpecialInstructions" />
                    </SpecialInstrs>
                    <Area>
                        <xsl:value-of select="/SalesOrder/OrderHeader/TaxArea" />
                    </Area>
                    <State>
                        <xsl:value-of select="/SalesOrder/OrderHeader/TaxState" />
                    </State>
                    <CountyZip>
                        <xsl:value-of select="/SalesOrder/OrderHeader/TaxCountyZip" />
                    </CountyZip>
                    <City>
                        <xsl:value-of select="/SalesOrder/OrderHeader/TaxCity" />
                    </City>
                    <InvoiceTerms>
                        <xsl:value-of select="$InvoiceTerms" />
                    </InvoiceTerms>
                    <OrderComments>
                        <xsl:value-of select="/SalesOrder/OrderHeader/Comments" />
                    </OrderComments>
                    <OrderStatus>
                        <xsl:value-of select="$OrderStatus" />
                    </OrderStatus>
                    <TypeOfOrder>
                        <xsl:value-of select="$TypeOfOrder" />
                    </TypeOfOrder>
                    <OrderType>
                        <xsl:value-of select="$OrderType" />
                    </OrderType>
                </OrderHeader>
                <OrderDetails>
                    <!-- get Line Items -->
                    <xsl:call-template name="detail">
                        <xsl:with-param name="i" select="0" />
                    </xsl:call-template>
                    <!-- get Shipping, Provide it the current line item-->
                    <xsl:call-template name="Freight">
                        <xsl:with-param name="LnNum" select="count(//OrderDetails)" />
                        <xsl:with-param name="FreightValue" select="/SalesOrder/OrderHeader/ShippingCost" />
                    </xsl:call-template>
                    <!-- get GiftcertificateValue, Provide it the current line item-->
                    <xsl:variable name="GiftcertificateValue" select="/SalesOrder/OrderHeader/GiftCertificateValue" />
                    <xsl:variable name="GiftCertificateNumber" select="/SalesOrder/OrderHeader/GiftCertificateNumber" />
                    <xsl:variable name="GiftCertificateDescription" select="/SalesOrder/OrderHeader/GiftCertificateDescription" />
                    <xsl:if test="$GiftcertificateValue!='0.00000'">
                        <xsl:call-template name="MisItems">
                            <xsl:with-param name="LnNum" select="count(//OrderDetails)+1" />
                            <xsl:with-param name="Misvalue" select="$GiftcertificateValue" />
                            <xsl:with-param name="MisDesc" select="concat('WEB PROMO: ',$GiftCertificateNumber)" />
                            <xsl:with-param name="MiscCost" select="0" />
                            <xsl:with-param name="MiscProdClass" select="'_OTH'" />
                        </xsl:call-template>
                    </xsl:if>
                </OrderDetails>
            </Orders>
        </SalesOrders>
    </xsl:template>
    <!--
OrderDetails Loop Builds Order Detail, tracking its Line #
-->
    <xsl:template match="//OrderDetails" name="detail">
        <xsl:for-each select="//OrderDetails">
            <xsl:variable name ="UnitPrice" select="UnitPrice"  />
            <xsl:variable name ="LinePrice" select="LinePrice"  />
            <xsl:variable name ="item_description" select="item_description"  />
            <xsl:variable name ="CustomerPrice" select="CustomerPrice"  />
            <xsl:variable name ="DiscountPrice" select="DiscountPrice"  />
            <xsl:variable name ="NotTaxable" select="NotTaxable"  />
            <xsl:variable name ="ItemType" select="ItemType" />
            <xsl:if test="$ItemType='A' or $ItemType='B' or $ItemType='C'  or $ItemType='P'">
                <StockLine>
                    <CustomerPoLine>
                        <xsl:value-of select="LineNumber" />
                    </CustomerPoLine>
                    <LineActionType>A</LineActionType>
                    <StockCode>
                        <xsl:value-of select="StockCode" />
                    </StockCode>
                    <xsl:if test="ItemWarehouse!=''">
                        <Warehouse>
                            <xsl:value-of select="ItemWarehouse"/>
                        </Warehouse>
                    </xsl:if>
                    <xsl:variable name="description" select="$UseStockDescSupplied" />
                    <xsl:if   test="$description!=''">
                        <StockDescription>
                            <xsl:value-of select="substring($item_description, 1,30)" />
                        </StockDescription>
                    </xsl:if>
                    <OrderQty>
                        <xsl:value-of select="Quantity" />
                    </OrderQty>
                    <OrderUom>
                        <xsl:value-of select="Unit" />
                    </OrderUom>
                    <xsl:if test="$NotTaxable = 'false'">
                        <StockNotTaxable></StockNotTaxable>
                    </xsl:if>
                    <xsl:if test="$NotTaxable = 'true'">
                        <StockNotTaxable>Y</StockNotTaxable>
                    </xsl:if>
                    <Price>
                        <xsl:value-of select="$LinePrice" />
                    </Price>
                    <PriceUom>
                        <xsl:value-of select="Unit" />
                    </PriceUom>
                    <xsl:variable name="StockCode" select="StockCode"></xsl:variable>
                    <LineDiscPercent1>
                        <xsl:value-of select="//SalesOrder/Discounts[@StockCode=$StockCode]/DiscountPct1" />
                    </LineDiscPercent1>
                    <LineDiscPercent2>
                        <xsl:value-of select="//SalesOrder/Discounts[@StockCode=$StockCode]/DiscountPct2" />
                    </LineDiscPercent2>
                    <LineDiscPercent3>
                        <xsl:value-of select="//SalesOrder/Discounts[@StockCode=$StockCode]/DiscountPct3" />
                    </LineDiscPercent3>
                    <xsl:variable name="GSTTax" select="//SalesOrder/Discounts[@StockCode=$StockCode]/GSTTaxCode" />
                    <xsl:if   test="GSTTax!=''">
                        <StockFstCode>
                            <xsl:value-of select="//SalesOrder/Discounts[@StockCode=$StockCode]/GSTTaxCode" />
                        </StockFstCode>
                    </xsl:if>
                </StockLine>
            </xsl:if>
            <xsl:if test="$ItemType='M'">
                <MiscChargeLine>
                    <CustomerPoLine>
                        <xsl:value-of select="LineNumber" />
                    </CustomerPoLine>
                    <LineActionType>A</LineActionType>
                    <MiscChargeValue>
                        <xsl:value-of select="format-number($LinePrice,'#.##')"     />
                    </MiscChargeValue>
                    <MiscChargeCost>
                        
                    </MiscChargeCost>
                    <MiscQuantity>1</MiscQuantity>
                    <MiscProductClass>_OTH</MiscProductClass>
                        <!-- <xsl:value-of select="_OTH" />
                    </MiscProductClass> -->
                    <MiscDescription>
                        <xsl:value-of select="substring($item_description, 1,30)" />
                    </MiscDescription>
                    <MiscNotTaxable>
                        <xsl:value-of select="$MiscTax" />
                    </MiscNotTaxable>
                </MiscChargeLine>
            </xsl:if>
            <xsl:if test="$ItemType='O'">
                <CommentLine>
                    <CustomerPoLine>
                        <xsl:value-of select="LineNumber"/>
                    </CustomerPoLine>
                    <LineActionType>A</LineActionType>
                    <Comment>
                        <xsl:value-of select="substring($item_description, 1,30)" />
                    </Comment>
                    <AttachedLineNumber>1</AttachedLineNumber>
                    <CommentType/>
                </CommentLine>
            </xsl:if>
        </xsl:for-each>
    </xsl:template>
    <!--
FreightLine for shipping called after line items
-->
    <xsl:template name="Freight">
        <xsl:param name="LnNum" />
        <xsl:variable name="ShippingCost" select="//ShippingCost" />
        <xsl:if   test="format-number($ShippingCost,'#.##')!='NaN'">
            <FreightLine>
                <CustomerPoLine>
                    <xsl:value-of select="$LnNum +1" />
                </CustomerPoLine>
                <LineActionType>A</LineActionType>
                <FreightValue>
                    <xsl:value-of select="format-number($ShippingCost,'#.##')" />
                </FreightValue>
                <FreightCost>
                    <xsl:value-of select="format-number($ShippingCost,'#.##')"     />
                </FreightCost>
            </FreightLine>
        </xsl:if>
    </xsl:template>
    <!--
Mis for shipping called after Line items and Freight duplicate calls for diffrent charges. 
LnNum 
-->
    <xsl:template name="MisItems">
        <xsl:param name="LnNum" />
        <xsl:param name="Misvalue" />
        <xsl:param name="MisDesc" />
        <xsl:param name="MiscCost" />
        <xsl:param name="MiscProdClass" />
        <MiscChargeLine>
            <CustomerPoLine>
                <xsl:value-of select="$LnNum +1" />
            </CustomerPoLine>
            <LineActionType>A</LineActionType>
            <MiscChargeValue>
                <xsl:value-of select="format-number($Misvalue,'#.##')"     />
            </MiscChargeValue>
            <MiscChargeCost>
                <xsl:value-of select="format-number($MiscCost,'#.##')"     />
            </MiscChargeCost>
            <MiscQuantity>1</MiscQuantity>
            <MiscProductClass>
                <xsl:value-of select="$MiscProdClass" />
            </MiscProductClass>
            <MiscDescription>
                <xsl:value-of select="$MisDesc" />
            </MiscDescription>
            <MiscNotTaxable>
                <xsl:value-of select="$MiscTax" />
            </MiscNotTaxable>
        </MiscChargeLine>
    </xsl:template>
</xsl:stylesheet>