[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Variations in XML to CSV

Subject: Re: Variations in XML to CSV
From: Brandon Ibach <brandon.ibach@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 21 Apr 2011 13:53:12 -0400
Re:  Variations in XML to CSV
As Michael pointed out, your next step should probably be to formalize
your input and output samples into a set of requirements.  It's a step
that probably isn't done often enough in software development and can
be particularly valuable when you're uncertain about where to begin in
the coding process.  Getting it all down in writing, in detail, can
often clarify what needs to be done.

Based on your samples, you might have requirements like:

1. The transform's output shall be plain text.
2. The transform's first output shall be the string
followed by a newline character.
3. For each "metadata" element in the input, the transform shall
output a series of 10 fields, with each field followed by a comma
except the last, which shall be followed by a newline character.
4. The first field shall consist of the content of a "title" element
in the "metadata" element, if one exists, otherwise nothing.
5. The second field shall consist of the content of the first
"subject" element that does not follow a "creator" or "contributor"
element in the "metadata" element, if one exists, otherwise nothing.

...and so on.  Note that requirement 5 was written under the
assumption that a subject preceding the creator and contributor list
is special and different from those that follow later.

Written in enough detail, these can be translated quite readily into
code.  For instance, see how this requirement lines up with the
following, which might appear inside a template for the "metadata"

<xsl:variable name="subject1"
select="subject[not(preceding-sibling::*[self::creator |

-Brandon :)

On Thu, Apr 21, 2011 at 10:53 AM, Bridger Dyson-Smith
<bdysonsmith@xxxxxxxxx> wrote:
> Hi Michel,
> thanks for the reply!
>> Its hard to say when you don't provide an output sample. I guess order
>> is important etc.
> I'm sorry that I can't provide an output sample - I don't know how to
> generate one, but it might look something like this:
> Alpha,Sinister,Beta,,,,Gamma,Delta,Epsilon,2011-04-19
> Zeta,,Eta,Theta,Dexter,Iota,Kappa,Lambda,,2011-04-19
>> Maybe you need to take several steps. Like determine how mayn subject
>> elements you have max etc. Then maybe sort your input so all same
>> named elements are consecutive. And then generate as many as you have
>> for each element padding with empty items when you have run through.
>> Michel
> Thank you for the suggestions - I'll look into regenerating the XML so
> it's sorted & has blank elements where necessary.
> Bridger

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.