I am actually very new to J2EE and XML. Just wanted to check if http://www.topxml.com/xsltStylesheets/xslt_non_XML.asp would help me. If this will help me, How to invoke this XSL using the input text file to get the XML back? I mean to say which Java api will do it for me. Will JDOM can help me with this?
Thanks Roseanne for clearing this out. I was thinking in that direction looking at the an example on http://www.topxml.com/xsltStylesheets/xslt_non_XML.asp Please have a look and let me know if they are using some customize api for the same.
1) Download the source 2) Take a look at the file FixedLangthTextToXML,xml 3) You should know the trick it is using immediately, and you should know what I said above is true.
here is the trick:
They used an entity to put the non-xml-text into the <data></data> tag to make it XML first. Of course, you can do the same.
To tell you the truth, I don't like such trick...
Roseanne Zhang
Ranch Hand
Joined: Nov 14, 2000
Posts: 1953
posted
0
You can use JavaScript/Perl/Ruby or whatever to do the work in a more flexible way instead to coarce xsl to do something it is not supposed to do.
Rahul Bhattacharjee
Ranch Hand
Joined: Nov 29, 2005
Posts: 2300
posted
0
Originally posted by Karan Jain: Hi, I am not able to write the code to pass text file object (or string) and xsl in an API to give me back a XML.
As Roseanne Zhang mentioned its not possible.I have also mentioned this in my first post.
Why do not you try Apache's Velocity ?
First you have to parse the text file and pick up the values that you require to construct the XML and put those in some java bean instance.
Write a velocity template file to reflect the structure of the final XML file.
Now use velocity engine to generate the XML with the bean as input to that.
Karan Jain
Ranch Hand
Joined: May 30, 2007
Posts: 82
posted
0
Thanks Roseanne and Rahul for your valuable inputs. Sorry i didn't realize the trick.
Thanks and regards, Karan
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Creating XML from fixed length text file using XSL