xsl-list
[Top] [All Lists]

Re: [xsl] Fw: How do I properly extract data from different sections of a complicated XML file - converting from XML to CSV

2014-10-21 17:38:09
Hi Catherine,

On Tue, Oct 21, 2014 at 11:38 AM, Catherine Wilbur 
cwilbur(_at_)uwindsor(_dot_)ca
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
Problem I have is that the XML is so complex to extract the small amount of
data that I need but this is file application generates.  I put all then
non-recurring data at the beginning and the recurring data at the end.  Want
to know how to do the following.

1) How do I put derived strings that do not necessarily come from am XML
field.  Can I set up derived fields where I have to manipulate the string to
generate the string?

Yes you certainly can, although in general this isn't going to be as
easy in XSLT 1.0 as it is in XSLT 2.0.

The specifics, of course, vary tremendously from case to case.

2)  How do I properly loop thru my Fund_Info section within each Invoice and
write out a new line each time I get a new Fund info line.

In your template handing "invoice" elements you are already emitting a
string for the element, consisting of values with ';' delimiters.

Simply end this line with an LF (<xsl:text>&#xA;</xsl:text> in your
template) to get the LF in your output.

3) Is this code going to properly extract the data I need from the XML file
into a CSV file.

Sure! More or less. Depends on what you mean by 'properly'.

XSLT can certainly extract data from XML and write CSV. It can also
map and manipulate values, although the pain you have to go to for the
manipulations will be greater or lesser depending on the complexity of
the case.

However, XSLT 1.0 was not designed to do much in the way of string
manipulations.

If you were to offer an example of one of the more complicated
derivations, we could say more.

Cheers, Wendell

-- 
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>