[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Code used to extract data from complex XML file - how do you move fields value of select fields to separate lines

Subject: [xsl] Code used to extract data from complex XML file - how do you move fields value of select fields to separate lines
From: "Catherine Wilbur cwilbur@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 24 Oct 2014 20:52:11 -0000

About a week ago I posted information about a complex XML file I was 
trying to convert to CSV.  I have since come up with the following XML 
Have some questions about how to tweak this stylesheet.  Had to start at 
the recurring section then move upwards to build the CSV file.

O/S Issues
1)  Extracted all default fields from XML file using my XSLT code below.
2)  How can I put each value-of select on separate lines in my code so is 
easier to read - do not want my data to go to a different line.
3) How do you edit value-of select lines to make a value a date, numeric, 
zero filled. 
4)  How do I sort file after all records get written out to file in XSLT 
4)  Have to find a way to derive some of my fields that do not come 
directly from my XML file

        how do I hardcode a value
        how do a pull in a default value into a field such as current date 
in format yyyymmddhhmm or yyyymmdd
        how do I set up a field from different fields (ie. my batch date 
format is as follows YYYYMMDDHHMMXCUR where X is a value from another 
field and CUR is a value from another field 
        how do I look for a partial value in a text field from XML file to 
set up a derived field - need to look for a certain string in 
invoice_number to set up PaymentTerms

Here is my CSV output from XML File (was able to extract all default 
PO-305, 22, USD, ABE, 2014082450002181, 07/24/2014, ACCOUNTINGDEPARTMENT, 
1.0742, 20, 2014-2015,18105.8820,Leddy Library*
PO-305, 22, USD, ABE, 2014082450002181, 07/24/2014, ACCOUNTINGDEPARTMENT, 
1.0742, 2, 2014-2015,18105.8430,Leddy Library*

<?xml version="1.0" encoding="UTF-8" ?>

<!-- New document created with EditiX at Thu Oct 23 16:28:34 EDT 2014 -->

<xsl:stylesheet version="2.0" 
        exclude-result-prefixes="xs xdt err fn">

        <xsl:output method="text" indent="no"/>
        <!-- xsl:value-of select="../../../../../vendor_FinancialSys_Code" 
/>, need to check for zero or nil then use 99999 otherwise take the value 
        <!-- xsl:value-of select="../../../../../hardcode_RemarkString" 
/>, derived field --> 
        <!-- xsl:value-of select="../../../../../hardcode_GLDate" />, 
current date in format yyyymmdd --> 
        <!-- xsl:value-of select="../../../../../hardcode_BatchNo" />, 
seormat yyyymmddhhmmXCUR where X is value from Line Owner (L-Leddy, 
W-Law), CUR is from invoice_amount/currency, yyyymmddhhmm is current date 
        <!-- xsl:value-of select="../../../../../hardcode_PayTerms" />, 
erived from part of invoice/invoice_number --> 
        <xsl:template match="/">
select="../../../../../invoice_number" />, <xsl:value-of 
select="../../../../../invoice_amount/sum" />, <xsl:value-of 
select="../../../../../invoice_amount/currency" />, <xsl:value-of 
select="../../../../../vendor_code" />, <xsl:value-of 
select="../../../../../unique_identifier" />, <xsl:value-of 
select="../../../../../invoice_date" />, <xsl:value-of 
select="../../../../../payment_method" />, <xsl:value-of 
select="../../../../../invoice_exchange_rate_list/exchange_rate/rate" />, 
<xsl:value-of select="sum" />, <xsl:value-of select="../fiscal_period" 
/>,<xsl:value-of select="../external_id" />,<xsl:value-of 
select="../../../../invoice_line/po_line_info/po_line_owner" />

Catherine Wilbur  |  Senior Application Programmer  |  IT Services
401 Sunset Avenue, Windsor ON Canada  N9B 3P4
(T) 519.253.3000 Ext. 2745  |  (F) 519.973.7083  |  (E) 

Current Thread