my dog learned polymorphism
The moose likes Java in General and the fly likes java - xslt creating csv file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "java - xslt creating csv file" Watch "java - xslt creating csv file" New topic
Author

java - xslt creating csv file

Carl Jenkins
Ranch Hand

Joined: Feb 19, 2006
Posts: 39
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!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16487
    
    2

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

Joined: Feb 19, 2006
Posts: 39
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

Joined: Feb 19, 2006
Posts: 39
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java - xslt creating csv file
 
Similar Threads
Poor Naming Conventions
Triggering event
JSTL Drop Down
Passing JSF values in a JavaScript on load function
Mediatortype javaprog requiring solution