Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java program to Generate XML from XSD

 
sai rama krishna
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have the data printed on to my console from the XLS(I have filtered the empty cells, headings etc).

I have XSD as well.

How to make XML using XSD and populated data on console from XLS with my java application.

I am attaching the sample XLS.

I am also attaching how the XML looks like which supposed to prepared from the XSD.

Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
xls1.JPG
[Thumbnail for xls1.JPG]
xls file structure
xml1.JPG
[Thumbnail for xml1.JPG]
xml file structure
 
sai rama krishna
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.javacodegeeks.com/2011/02/jaxb-generate-xml-xsd.html

I saw above link has something similar.

I created Main.java in my eclipse at package generated.


But I do not see XSD getting passed into that program anywhere.

Also I am getting compilation errors as eclipse not ale to recognize

ObjectFactory

UserT

ItemT

ItemListT

ExpenseT

etc.


Where i have to copy xsd file to. Please advise
 
sai rama krishna
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do i need to import any jars for this . please advise
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You actually have an XSD that describes that XML structure? Wow.
Generating an XML document from an XSD can't yield a meaningful result, so you'd best forget about that.
If you save the Excel worksheet as an XML spreadsheet you could use XSLT to transform that XML document into an XML document that matches your XSD.
How to do that using Java you can read about here. You could then validate the resulting XML against your XSD. There's an example on how to do that in our FAQ.
 
sai rama krishna
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>>If you save the Excel worksheet as an XML spreadsheet you could use XSLT to transform that XML document into an XML document that matches your XSD.


I have excel worksheets with about 50 sheets in that for different cities. How do I make it as XML spread sheet to transform to XML document using XSLT. Please advise
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
File > Save As.. > Save as type: XML spreadsheet
 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sai rama krishna wrote:I have excel worksheets with about 50 sheets in that for different cities. How do I make it as XML spread sheet to transform to XML document using XSLT. Please advise

I thought Jelle did.

However, this smells of a "desktop app" that has mushroomed out of control. Why not just bite the bullet and translate it into a database application?

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic