If you use an XSLT 2.0 processor I would simply use
<xsl:value-of select="foo, bar, baz" seperator=", "/> instead of all the
separate value-ofs.
Or you need to use
<xsl:value-of select="foo"/>
<xsl:text>' </xsl:text>
--
Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail
gesendet.
"Catherine Wilbur cwilbur@xxxxxxxxxxx"
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>schrieb:
How do I code the value-of select so all my output fields stay on the
same output line. Do not want to wrap all my value-of logic on one
line because then it is too hard to format my output fields.
Here is code and output. How do I fix the code so I have one field
per line but the output all stays on one line. I look thru each
fund_info item and print out a data line with specific fields.
XSL Code
<?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"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
xmlns:err="http://www.w3.org/2005/xqt-errors"
exclude-result-prefixes="xs xdt err fn">
<xsl:output method="text" indent="no"/>
<!-- OUSTANDING OUTPUT DATA ISSUES -->
<!-- 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" />, format
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" />,
derived from part of invoice/invoice_number -->
<!-- xsl:value-of select="../../../../../hardcode_Attachments" />,
derived from part of invoice/invoice_number -->
<xsl:template match="/">
<xsl:for-each
select="payment_data/invoice_list/invoice/invoice_line_list/invoice_line
/fund_info_list/fund_info/amount">
<xsl:value-of 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&quo
t; />,
<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" />
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Output displays as shown below
PO-305,
22,
USD,
ABE,
2014082450002181,
07/24/2014,
ACCOUNTINGDEPARTMENT,
1.0742,
20,
2014-2015,
18105.8820,
Leddy Library*
If I change the code above section to following
<xsl:template match="/">
<xsl:for-each
select="payment_data/invoice_list/invoice/invoice_line_list/invoice_line
/fund_info_list/fund_info/amount">
<xsl:value-of 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&quo
t; />, <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" />
<xsl:text>
</xsl:text>
</xsl:for-each>
Output then displays as shown below (this is how data should appear)
PO-305, 22, USD, ABE, 2014082450002181, 07/24/2014,
ACCOUNTINGDEPARTMENT, 1.0742, 20, 2014-2015, 18105.8820, Leddy
Library*
____________________________________________________________________
_
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)
cwilbur@xxxxxxxxxxx
www.uwindsor.ca/its
From: Catherine Wilbur/cwilbur/University of Windsor
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Date: 10/24/2014 04:51 PM
Subject: Code used to extract data from complex XML file - how do you
move fields value of select fields to separate lines
--------------------------------------------------------------------
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 stylesheet.
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 code
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
fields)
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*
XSLT Code
<?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"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
xmlns:err="http://www.w3.org/2005/xqt-errors"
exclude-result-prefixes="xs xdt err fn">
<xsl:output method="text" indent="no"/>
<!-- OUSTANDING OUTPUT DATA ISSUES -->
<!-- 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="/">
<xsl:text>
</xsl:text>
<xsl:for-each
select="payment_data/invoice_list/invoice/invoice_line_list/invoice_line
/fund_info_list/fund_info/amount">
<xsl:value-of 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&quo
t; />, <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" />
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
____________________________________________________________________
_
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)
cwilbur@xxxxxxxxxxx
www.uwindsor.ca/its
XSL-List info and archiveEasyUnsubscribe (by email)
XSL-List info and archiveEasyUnsubscribe (by email)
|