Sunday, 8 February 2015

Apply XSLT Mapping to the output variable



I am having an issue with the apply xslt activity. I am using Castiron Studio 7.1.


The XSLT I wrote is producing the desired results. I verified in xml spy, and using the test function the apply xslt activity provides. But the mapping is not giving me the desired results. To break it down I will provide a sample of the source xml, the xslt, the xml produced by the xslt, the xsd the xml variable is based off of, and the xml that shows up in the To Orchestration (output) section when I run the orchestration. Any help is greatly appreciated.



<!-- begin snippet: Input XML -->

<Retail_Purchase__c xmlns="urn:sobject.partner.soap.sforce.com" xmlns:xsi="http://ift.tt/ra1lAU"><Id>a1gL0000000M973IAC</Id><Coupon_Code__c xsi:nil="true"/><Purchase_Amount__c xsi:nil="true"/><Discount_Received__c>10.0</Discount_Received__c><Name_of_Shopper__c>Mr. Mq05jan Test</Name_of_Shopper__c><Number_of_Units__c>5.0</Number_of_Units__c><Original_Channel__c>LBY</Original_Channel__c><Payment_Type__c>Amex</Payment_Type__c><Primary_Channel__c>MoMA Lobby</Primary_Channel__c><Name>999999999</Name><SalesTax__c>13.99</SalesTax__c><SystemModstamp>2015-02-05T12:27:10.000Z</SystemModstamp><Transaction_Amount__c>159.3</Transaction_Amount__c><Purchase_Date__c>2015-02-05</Purchase_Date__c><Purchase_Location__c>MoMA Lobby</Purchase_Location__c><Transaction_Number__c>9.99999999E8</Transaction_Number__c><Transaction_Type__c>Purchase</Transaction_Type__c><TransactionAmount_InclusiveTax__c>173.29</TransactionAmount_InclusiveTax__c><Account__r><Name>Rohit Patil Household</Name></Account__r><Retail_Product_Departments__r><Retail_Product_Department__c><Item_SKU__c>986</Item_SKU__c><Invoice_No__c>9.99999999E8</Invoice_No__c><Number_of_Items__c>3.0</Number_of_Items__c><Purchase_Amount__c>51.3</Purchase_Amount__c><Retail_Department__c>MoMA Publications</Retail_Department__c><Retail_Division__c>1 - MoMA Books</Retail_Division__c><Name>MoMA Highlights - Spanish</Name><Retail_Purchase__c>a1gL0000000M973IAC</Retail_Purchase__c></Retail_Product_Department__c><Retail_Product_Department__c><Item_SKU__c>915</Item_SKU__c><Invoice_No__c>9.99999999E8</Invoice_No__c><Number_of_Items__c>2.0</Number_of_Items__c><Purchase_Amount__c>108.0</Purchase_Amount__c><Retail_Department__c>Recent Exhibition Catalogues</Retail_Department__c><Retail_Division__c>1 - MoMA Books</Retail_Division__c><Name>Henri Matisse: The Cut-Outs Exhibition Catalogue (Hardcover)</Name><Retail_Purchase__c>a1gL0000000M973IAC</Retail_Purchase__c></Retail_Product_Department__c></Retail_Product_Departments__r></Retail_Purchase__c>

<!-- end snippet Input XML-->

<!-- begin snippet: XSLT -->
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR" xmlns:xsi="http://ift.tt/ra1lAU">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<Shipped_Order_Request>
<Invoice_Header>
<xsl:attribute name="OrderNumber"><xsl:value-of select="format-number(//*[local-name()='Retail_Purchase__c']/*[local-name()='Transaction_Number__c'],'#########')"/></xsl:attribute>
<Invoice_Payment_List>
<Invoice_Payments>
<xsl:attribute name="PaymentLineNo"><xsl:value-of select="1"/></xsl:attribute>
<xsl:attribute name="PaymentType"><xsl:value-of select="//*[local-name()='Retail_Purchase__c']/*[local-name()='Payment_Type__c']"/></xsl:attribute>
<xsl:attribute name="Amount"><xsl:value-of select="//*[local-name()='Retail_Purchase__c']/*[local-name()='Transaction_Amount__c']"/></xsl:attribute>
</Invoice_Payments>
</Invoice_Payment_List>
<Suborder_List>
<Suborder_Header>
<xsl:attribute name="ReferenceNumber"><xsl:value-of select="1990695008"/></xsl:attribute>
<xsl:attribute name="InvoiceNo"><xsl:value-of select="format-number(//*[local-name()='Retail_Purchase__c']/*[local-name()='Transaction_Number__c'],'#########')"/></xsl:attribute>
<xsl:attribute name="InvoiceSuffixNo"><xsl:value-of select="000"/></xsl:attribute>
<xsl:attribute name="InventoryLocationNo"><xsl:value-of select="512"/></xsl:attribute>
<xsl:attribute name="SellingLocationNo"><xsl:value-of select="512"/></xsl:attribute>
<xsl:attribute name="InvoiceDate"><xsl:value-of select="20150123"/></xsl:attribute>
<xsl:attribute name="InvoiceTime"/>
<xsl:attribute name="StaffCode"/>
<xsl:attribute name="MemberNumber"/>
<xsl:attribute name="EmployeeNumber"/>
<xsl:attribute name="TotalExtendedRetail">
<xsl:value-of select="0.0"/>

</xsl:attribute>
<xsl:attribute name="SalesTaxAmount">
<xsl:value-of select="0.0"/>

</xsl:attribute>
<xsl:attribute name="SalesTaxStateCode"/>
<xsl:attribute name="TotalShippingHandling"><xsl:value-of select="0.0"/></xsl:attribute>
<xsl:attribute name="TotalGiftWrapCharges"><xsl:value-of select="0.0"/></xsl:attribute>
<xsl:attribute name="TotalLineDiscount"><xsl:value-of select="0.0"/></xsl:attribute>
<xsl:attribute name="NetTotal"><xsl:value-of select="//*[local-name()='Retail_Purchase__c']/*[local-name()='Transaction_Amount__c']"/></xsl:attribute>
<xsl:attribute name="OtherChannelOrderNumber"><xsl:value-of select="concat('LBY-',substring-before(//*[local-name()='Retail_Purchase__c']/*[local-name()='Account__r']/*[local-name()='Name'],' '))"/></xsl:attribute>
<xsl:attribute name="SubOrderType"><xsl:value-of select="11"/></xsl:attribute>
<Suborder_ItemDetail_List>
<xsl:for-each select="//*[local-name()='Retail_Purchase__c']/*[local-name()='Retail_Product_Departments__r']/*[local-name()='Retail_Product_Department__c']">
<Suborder_ItemDetail>
<xsl:attribute name="InvoiceNo"><xsl:value-of select="format-number(./*[local-name()='Invoice_No__c'],'#########')"/></xsl:attribute>
<xsl:attribute name="InvoiceSuffixNo"><xsl:value-of select="000"/></xsl:attribute>
<xsl:attribute name="ItemLineNo">
<xsl:value-of select="0"/>
</xsl:attribute>
<xsl:attribute name="ItemNumber"><xsl:value-of select="./*[local-name()='Item_SKU__c']"/></xsl:attribute>
<xsl:attribute name="ItemDescription"/>
<xsl:attribute name="QuantityOrdered"><xsl:value-of select="substring-before(./*[local-name()='Number_of_Items__c'],'.')"/></xsl:attribute>
<xsl:attribute name="QuantityShipped"><xsl:value-of select="substring-before(./*[local-name()='Number_of_Items__c'],'.')"/></xsl:attribute>
<xsl:attribute name="ItemPrice"><xsl:value-of select="format-number((./*[local-name()='Purchase_Amount__c']) div ./*[local-name()='Number_of_Items__c'],'###,###,##.00')"/></xsl:attribute>

<xsl:attribute name="ItemTaxAmount">
<xsl:value-of select="0.0"/>
</xsl:attribute>
<xsl:attribute name="MemberAdjustment"/>
<xsl:attribute name="ShippingAdjustment">
<xsl:value-of select="0.0"/>
</xsl:attribute>
<xsl:attribute name="AllOtherAdjustments">
<xsl:value-of select="0.0"/>
</xsl:attribute>
<xsl:attribute name="ExtendedNetRetail">
<xsl:value-of select="0.0"/>
</xsl:attribute>
<xsl:attribute name="DeptHandlingCharges"><xsl:value-of select="0"/></xsl:attribute>
<xsl:attribute name="ReturnReasonCode"/>
<xsl:attribute name="InventoryFlag"><xsl:value-of select="0"/></xsl:attribute>
</Suborder_ItemDetail>
</xsl:for-each>
</Suborder_ItemDetail_List>
</Suborder_Header>
</Suborder_List>
</Invoice_Header>
</Shipped_Order_Request>
</xsl:template>
</xsl:stylesheet>

<!-- end snippet XSLT-->

<!-- begin snippet: XSD schema -->
<xs:schema xmlns:xs="http://ift.tt/tphNwY" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Shipped_Order_Request">
<xs:complexType>
<xs:sequence>
<xs:element name="Invoice_Header">
<xs:complexType>
<xs:sequence>
<xs:element name="Invoice_Payment_List">
<xs:complexType>
<xs:sequence>
<xs:element name="Invoice_Payments">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="PaymentLineNo" type="xs:int"/>
<xs:attribute name="PaymentType" type="xs:string"/>
<xs:attribute name="Amount" type="xs:float"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Suborder_List">
<xs:complexType>
<xs:sequence>
<xs:element name="Suborder_Header">
<xs:complexType>
<xs:sequence>
<xs:element name="Suborder_ItemDetail_List">
<xs:complexType>
<xs:sequence>
<xs:element name="Suborder_ItemDetail" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="InvoiceNo" type="xs:int" use="optional"/>
<xs:attribute name="InvoiceSuffixNo" type="xs:int" use="optional"/>
<xs:attribute name="ItemLineNo" type="xs:int" use="optional"/>
<xs:attribute name="ItemNumber" type="xs:int" use="optional"/>
<xs:attribute name="ItemDescription" type="xs:string" use="optional"/>
<xs:attribute name="QuantityOrdered" type="xs:int" use="optional"/>
<xs:attribute name="QuantityShipped" type="xs:int" use="optional"/>
<xs:attribute name="ItemPrice" type="xs:float" use="optional"/>
<xs:attribute name="ItemTaxAmount" type="xs:float" use="optional"/>
<xs:attribute name="MemberAdjustment" type="xs:string" use="optional"/>
<xs:attribute name="ShippingAdjustment" type="xs:float" use="optional"/>
<xs:attribute name="AllOtherAdjustments" type="xs:float" use="optional"/>
<xs:attribute name="ExtendedNetRetail" type="xs:float" use="optional"/>
<xs:attribute name="DeptHandlingCharges" type="xs:int" use="optional"/>
<xs:attribute name="ReturnReasonCode" type="xs:string" use="optional"/>
<xs:attribute name="InventoryFlag" type="xs:int" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="ReferenceNumber" type="xs:int" use="optional" />
<xs:attribute name="InvoiceNo" type="xs:int" use="optional"/>
<xs:attribute name="InvoiceSuffixNo" type="xs:int" use="optional"/>
<xs:attribute name="InventoryLocationNo" type="xs:string" use="optional"/>
<xs:attribute name="SellingLocationNo" type="xs:string" use="optional"/>
<xs:attribute name="InvoiceDate" type="xs:string" use="optional"/>
<xs:attribute name="InvoiceTime" type="xs:string" use="optional"/>
<xs:attribute name="StaffCode" type="xs:string" use="optional"/>
<xs:attribute name="MemberNumber" type="xs:string" use="optional"/>
<xs:attribute name="EmployeeNumber" type="xs:string" use="optional"/>
<xs:attribute name="TotalExtendedRetail" type="xs:float" use="optional"/>
<xs:attribute name="SalesTaxAmount" type="xs:float" use="optional"/>
<xs:attribute name="SalesTaxStateCode" type="xs:string" use="optional"/>
<xs:attribute name="TotalShippingHandling" type="xs:float" use="optional"/>
<xs:attribute name="TotalGiftWrapCharges" type="xs:float" use="optional"/>
<xs:attribute name="TotalLineDiscount" type="xs:float" use="optional"/>
<xs:attribute name="NetTotal" type="xs:float" use="optional"/>
<xs:attribute name="OtherChannelOrderNumber" type="xs:string" use="optional"/>
<xs:attribute name="SubOrderType" type="xs:int" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="OrderNumber" type="xs:int" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

<!-- end snippet XSD schema -->

<!-- begin snippet: Expected output -->
<?xml version="1.0" encoding="UTF-8"?>
<Shipped_Order_Request xmlns:xsi="http://ift.tt/ra1lAU">
<Invoice_Header OrderNumber="999999999">
<Invoice_Payment_List>
<Invoice_Payments PaymentLineNo="1" PaymentType="Amex" Amount="159.3"/>
</Invoice_Payment_List>
<Suborder_List>
<Suborder_Header ReferenceNumber="1990695008" InvoiceNo="999999999" InvoiceSuffixNo="0"
InventoryLocationNo="512"
SellingLocationNo="512"
InvoiceDate="20150123"
InvoiceTime=""
StaffCode=""
MemberNumber=""
EmployeeNumber=""
TotalExtendedRetail="0"
SalesTaxAmount="0"
SalesTaxStateCode=""
TotalShippingHandling="0"
TotalGiftWrapCharges="0"
TotalLineDiscount="0"
NetTotal="159.3"
OtherChannelOrderNumber="LBY-Rohit"
SubOrderType="11">
<Suborder_ItemDetail_List>
<Suborder_ItemDetail InvoiceNo="999999999" InvoiceSuffixNo="0" ItemLineNo="0" ItemNumber="986"
ItemDescription=""
QuantityOrdered="3"
QuantityShipped="3"
ItemPrice="17.10"
ItemTaxAmount="0"
MemberAdjustment=""
ShippingAdjustment="0"
AllOtherAdjustments="0"
ExtendedNetRetail="0"
DeptHandlingCharges="0"
ReturnReasonCode=""
InventoryFlag="0"/>
<Suborder_ItemDetail InvoiceNo="999999999" InvoiceSuffixNo="0" ItemLineNo="0" ItemNumber="915"
ItemDescription=""
QuantityOrdered="2"
QuantityShipped="2"
ItemPrice="54.00"
ItemTaxAmount="0"
MemberAdjustment=""
ShippingAdjustment="0"
AllOtherAdjustments="0"
ExtendedNetRetail="0"
DeptHandlingCharges="0"
ReturnReasonCode=""
InventoryFlag="0"/>
</Suborder_ItemDetail_List>
</Suborder_Header>
</Suborder_List>
</Invoice_Header>
</Shipped_Order_Request>
<!-- end snippet Expected output -->


<!-- begin snippet: output after Applying XSLT -->
<?xml version="1.0"?>
<Shipped_Order_Request xmlns:xsi="http://ift.tt/ra1lAU"><Invoice_Header OrderNumber="NaN"><Invoice_Payment_List><Invoice_Payments PaymentLineNo="1" PaymentType="" Amount=""/></Invoice_Payment_List><Suborder_List><Suborder_Header ReferenceNumber="1990695008" InvoiceNo="NaN" InvoiceSuffixNo="0" InventoryLocationNo="512" SellingLocationNo="512" InvoiceDate="20150123" InvoiceTime="" StaffCode="" MemberNumber="" EmployeeNumber="" TotalExtendedRetail="0" SalesTaxAmount="0" SalesTaxStateCode="" TotalShippingHandling="0" TotalGiftWrapCharges="0" TotalLineDiscount="0" NetTotal="" OtherChannelOrderNumber="LBY-" SubOrderType="11"><Suborder_ItemDetail_List/></Suborder_Header></Suborder_List></Invoice_Header></Shipped_Order_Request>
<!-- end snippet output after Applying XSLT -->

No comments:

Post a Comment