• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

java - xslt creating csv file

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I am trying to do is create a CSV file by using xslt. The problem I am running into is that the CSV file is formatted incorrectly.

Meaning what I see is something like:
thing1
,
thing2
,
think3

But, what I would like to see is:

thing1,thing2,thing3
thing1,thing2,thing3

I know it's not the XSLT becuase I have removed and text elements that might be creating that problem.
Plus just for testing sake I tried to concat() thing1 and the comma and when I view the CSV i still see the incorrect format.

If anyone could point me in the right direction I would be very appreciative!
 
Marshal
Posts: 27367
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whitespace in your XML document will be copied from input to output unless you prevent that from happening. Similarly, and more seriously, whitespace in your XSLT document will also be written to the output unless you prevent that. The solution is to use the <xsl:text> element.
 
Carl Jenkins
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The xml I am using is actually a combonation of several other xml files. So basically I have created a temp.xml file by taking the nodes from the other files and attaching them to the /root of my new document. I am not sure what you mean by removing white space here?

I was under the impression that <xsl:text> preserved whitespace. So I would use these elemetns to create line breaks after each processed row.
i.e thing1,thing2,thing3(text elements used here to create new row)

I am not sure what you are trying to tell me with regards to the text elements in xslt...

Thanks for your help!
 
Carl Jenkins
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just wanted to reply and say thanks for the suggestions. I finally fixed it(w/ your help)

The problem like you said was the xml source; once I removed any and all white space from the source xml all was good.

Thanks again.
 
When evil is afoot and you don't have any arms you gotta be hip and do the legwork, but always kick some ... tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic