Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 16th, 2012, 01:37 PM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 119
Thanks: 25
Thanked 3 Times in 3 Posts
Default XSLT to csv help

Hi All, I hope someone can help me with this. Using XSLT 1.0 I need to return a csv file. These are two basic examples below:

Code:
<feed>
   <item>
      <field1>value</field1>
      <field2>value</field2>
   </item>
   <item>
      <field1>value></field1>
      <field1a>value</field1a>
      <field2>value</field2>
   </item>
</feed>
needs to return

field1,field1a,field2
value,,value
value,value,value

There is a another consideration we need to accommodate, and that's repeating elements

Code:
<feed>
    <item>
        <field1>value</field1>
        <field2>
            <item>
                <field21>value1</field21>
                <field22>value1</field22>
            </item>
            <item>
                <field21>value2</field21>
                <field22>value2</field22>
            </item>
        </field2>
    </item>
</feed>
needs to return

field1, field2.field21,field2.field22
value,value1,value1
value,value2,value2

I have been trying to write the XSLT for a few hours but no luck.
Can anybody help me?


Regards,

John.

Last edited by JohnBampton; February 16th, 2012 at 01:39 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
XML To CSV with XSLT and Java pcroadkill XSLT 3 February 8th, 2012 11:55 AM
Handle Null or Blank values using xslt in csv data mums XSLT 1 April 3rd, 2008 07:30 PM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM
Problem applying simple XSLT to XML to create CSV gregclark XSLT 2 August 25th, 2005 07:30 AM
XSLT and CSV jjonesatuk XSLT 3 September 10th, 2003 05:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.