File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes java program to Generate XML from XSD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "java program to Generate XML from XSD" Watch "java program to Generate XML from XSD" New topic
Author

java program to Generate XML from XSD

sai rama krishna
Ranch Hand

Joined: May 29, 2009
Posts: 242
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



[Thumbnail for xls1.JPG]


[Thumbnail for xml1.JPG]

sai rama krishna
Ranch Hand

Joined: May 29, 2009
Posts: 242
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

Joined: May 29, 2009
Posts: 242
Do i need to import any jars for this . please advise
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1760
    
    7

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.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
sai rama krishna
Ranch Hand

Joined: May 29, 2009
Posts: 242
>>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

Joined: Mar 10, 2008
Posts: 1760
    
    7

File > Save As.. > Save as type: XML spreadsheet
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7647
    
  19

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java program to Generate XML from XSD