Created
July 15, 2012 03:07
-
-
Save joshuacalloway/3114667 to your computer and use it in GitHub Desktop.
xsl example convert xml and child nodes to csv file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output method="text"/> | |
<xsl:template match="/"> | |
<xsl:apply-templates /> | |
</xsl:template> | |
<xsl:template match="Invoice"> | |
<xsl:for-each select="Item_List/Item"> | |
<xsl:apply-templates select="/Invoice/*[not(self::Item_List) and not(self::TouchLess)]" /> | |
<xsl:apply-templates select="/Invoice/TouchLess"/> | |
<xsl:for-each select="*"> | |
<xsl:value-of select="."/> | |
<xsl:if test="position() != last()"> | |
<xsl:value-of select="','"/> | |
</xsl:if> | |
</xsl:for-each> | |
<xsl:text>
</xsl:text> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template match="/Invoice/Item_List"/> | |
<xsl:template match="/Invoice/Item_List/Item"/> | |
<xsl:template match="TouchLess"> | |
<xsl:for-each select="*"> | |
<xsl:value-of select="."/> | |
<xsl:value-of select="','"/> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template match="*"> | |
<xsl:value-of select="."/> | |
<xsl:value-of select="','"/> | |
</xsl:template> | |
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="ISO-8859-1"?> | |
<Invoice> | |
<Duplicate_Check_Level>1</Duplicate_Check_Level> | |
<Invoice_Document_Type>2</Invoice_Document_Type> | |
<ScanDateTime>2012-06-19 15:17:43</ScanDateTime> | |
<BatchNumber>4</BatchNumber> | |
<Invoice_Amount>5</Invoice_Amount> | |
<Invoice_Amount_In_Local_Currency>6</Invoice_Amount_In_Local_Currency> | |
<Invoice_Net_Amount>7</Invoice_Net_Amount> | |
<Invoice_Net_Amount_In_Local_Currency>8</Invoice_Net_Amount_In_Local_Currency> | |
<Invoice_Tax_Amount>9</Invoice_Tax_Amount> | |
<Invoice_Currency>10</Invoice_Currency> | |
<Local_Currency>11</Local_Currency> | |
<Vendor_Name>12</Vendor_Name> | |
<Invoice_Sender_Address>13</Invoice_Sender_Address> | |
<Invoice_Due_Date>14</Invoice_Due_Date> | |
<Invoice_Date>15</Invoice_Date> | |
<Invoice_Number>16</Invoice_Number> | |
<Posting_Date>17</Posting_Date> | |
<Company_Code>18</Company_Code> | |
<Invoice_Description>19</Invoice_Description> | |
<Vendor_Number>20</Vendor_Number> | |
<Invoice_Approve_Mode>21</Invoice_Approve_Mode> | |
<Invoice_Order_Number>22</Invoice_Order_Number> | |
<Auto_Taxes>23</Auto_Taxes> | |
<Invoice_Payment_Block>24</Invoice_Payment_Block> | |
<Invoice_BusinessArea>25</Invoice_BusinessArea> | |
<Invoice_Assignment>26</Invoice_Assignment> | |
<Transaction_Kind>27</Transaction_Kind> | |
<Invoice_Baseline_Date>28</Invoice_Baseline_Date> | |
<Invoice_Payment_Terms>29</Invoice_Payment_Terms> | |
<Invoice_Payment_Method>30</Invoice_Payment_Method> | |
<Invoice_Header_Text>31</Invoice_Header_Text> | |
<Invoice_Reference_Number>32</Invoice_Reference_Number> | |
<Alternative_Payee_Number>33</Alternative_Payee_Number> | |
<Invoice_Default_Tax>34</Invoice_Default_Tax> | |
<Culture_Code>35</Culture_Code> | |
<Invoice_Delivery_Costs>36</Invoice_Delivery_Costs> | |
<TouchLess> | |
<TouchLessError>TA</TouchLessError> | |
<AllowTouchLess>TB</AllowTouchLess> | |
<AllowTouchLessBeforeValidation>TC</AllowTouchLessBeforeValidation> | |
<IgnoreWarnings>TD</IgnoreWarnings> | |
<IgnoreWarningsBeforeValidation>TE</IgnoreWarningsBeforeValidation> | |
<disableTouchlessUpdate>TF</disableTouchlessUpdate> | |
<disableTouchlessUpdateReason>TG</disableTouchlessUpdateReason> | |
</TouchLess> | |
<Item_List> | |
<Item> | |
<AccountAssignment>I1A</AccountAssignment> | |
<Reference_Doc_Item>I1B</Reference_Doc_Item> | |
<Item_Type>I1C</Item_Type> | |
<Unit>I1D</Unit> | |
<Po_Number>I1E</Po_Number> | |
<Po_Item>I1F</Po_Item> | |
<Tax_Jurisdiction>I1G</Tax_Jurisdiction> | |
<DebitCredit>I1H</DebitCredit> | |
<Assignment>I1I</Assignment> | |
<Order>I1J</Order> | |
<BusinessArea>I1K</BusinessArea> | |
<Amount>I1L</Amount> | |
<Cost_Center>I1M</Cost_Center> | |
<Currency>I1N</Currency> | |
<Tax_Code>I1O</Tax_Code> | |
<Account_Number>I1P</Account_Number> | |
<Quantity>I1Q</Quantity> | |
<Item_Number>I1R</Item_Number> | |
<Item_Description>I1S</Item_Description> | |
</Item> | |
<Item> | |
<AccountAssignment>I2A</AccountAssignment> | |
<Reference_Doc_Item>I2B</Reference_Doc_Item> | |
<Item_Type>I2C</Item_Type> | |
<Unit>I2D</Unit> | |
<Po_Number>I2E</Po_Number> | |
<Po_Item>I2F</Po_Item> | |
<Tax_Jurisdiction>I2G</Tax_Jurisdiction> | |
<DebitCredit>I2H</DebitCredit> | |
<Assignment>I2I</Assignment> | |
<Order>I2J</Order> | |
<BusinessArea>I2K</BusinessArea> | |
<Amount>I2L</Amount> | |
<Cost_Center>I2M</Cost_Center> | |
<Currency>I2N</Currency> | |
<Tax_Code>I2O</Tax_Code> | |
<Account_Number>I2P</Account_Number> | |
<Quantity>I2Q</Quantity> | |
<Item_Number>I2R</Item_Number> | |
<Item_Description>I2S</Item_Description> | |
</Item> | |
</Item_List> | |
<GL_Item_List>37</GL_Item_List> | |
<Mtl_Item_List>38</Mtl_Item_List> | |
</Invoice> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment