xsl-list
[Top] [All Lists]

Re: [xsl] Variations in XML to CSV

2011-04-21 09:41:00
Hi,

Its hard to say when you don't provide an output sample. I guess order
is important etc.

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

On Thu, Apr 21, 2011 at 4:30 PM, Bridger Dyson-Smith
<bdysonsmith(_at_)gmail(_dot_)com> wrote:
Hi all,
thanks for taking a moment to read.

I'm trying to generate a CSV file from XML that looks something like this:

<root>
 <metadata>
   <title>Alpha</title>
   <subject>Sinister</subject>
   <creator>Beta</creator>
   <subject>Gamma</subject>
   <subject>Delta</subject>
   <subject>Epsilon</subject>
   <date>2011-04-19</date>
 </metadata>
 <metadata>
   <title>Zeta</title>
   <creator>Eta</creator>
   <creator>Theta</creator>
   <contributor>Dexter</contributor>
   <contributor>Iota</contributor>
   <subject>Kappa</subject>
   <subject>Lambda</subject>
   <date>2011-04-19</date>
 </metadata>
</root>

I'm at a complete loss. I've been reading (and rereading) examples
from the XSLT Cookbook, but I haven't been able to make the examples
jive with what I'm looking at on my screen. Is this even possible? If
so, would someone mind giving me a push in the right direction?

I've been able to generate a dummy XML file that has a complete set of
all the elements:
<root>
 <metadata>
   <title>Value</title>
   <subject>Value</subject>
  <creator>Value</creator>
  <creator>Value</creator>
  <contributor>Value</contributor>
  <subject>Value</subject>
  <subject>Value</subject>
  <subject>Value</subject>
  <date>Value</date>
 </metadata>
</root>
If I use this to generate a row of column names, I think I can map the
variable elements to their respective columns provided I can get that
aforementioned push. Maybe it needs to be a kick...

Thanks again for reading.
Cheers,
Bridger

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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