This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Creating dynamic xml using xsd Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Creating dynamic xml using xsd" Watch "Creating dynamic xml using xsd" New topic
Author

Creating dynamic xml using xsd

Poonam Thawani
Greenhorn

Joined: Oct 11, 2005
Posts: 13
I am trying to create a code for creating xml using an XSD and data any suggesstions which parser to use and is it possible to create using xsd
Clifton Craig
Ranch Hand

Joined: May 26, 2006
Posts: 103
Poonam,

That's a very confusing question. For one thing, parsers are used to read XML docs not create them. So if you already have an XML document then you would grab a parser and turn the document into either a DOM object model or SAX event method calls. You would traverse the DOM model or respond to the SAX events accordingly to do something with the data parsed from the document. Secondly an XSD is generally used to validate an XML document. They work like DTDs to make sure the XML contains the right tags in the right sequence and so forth. So an XSD and a parser will not typically help you create an XML document. Creating XML is rather easy depending what it is being built from. There are various 3rd party APIs to help build an object model in memory and stream it out somewhere. To be completely simple you could just write XML strings directly to some output. A little more complicated is something I did recently. I used the SAX interfaces in Java to represent an object as XML for a transform. The benefit there is not having to materialize (write out) the XML and parse it between the object conversion and transformation. It makes for more efficient processing.

I think you should start by considering what you want to represent as XML. Then ask what you want to do with that XML. For example, you could represent a CSV as XML for the purposes of displaying it in an HTML page as a table. You could, in a video game for example, record user key and mouse actions as XML and transform them into a chart. All different kinds of possibilities, I'm sure you know. Explain your purpose more and I'm sure someone here can guide you.


Holla at me...<br /><a href="http://codeforfun.wordpress.com" target="_blank" rel="nofollow">http://codeforfun.wordpress.com</a>
Robert Hayes
Ranch Hand

Joined: Oct 24, 2004
Posts: 116
What you are looking for (it sounds like) is an XML marshaller/unmarshaller.

Since I use XMLBeans for this type of thing, I'll point you here:

http://xmlbeans.apache.org/

Essentially you work with the Java object representation of the XSD and marshal it to an XML document...
 
jQuery in Action, 2nd edition
 
subject: Creating dynamic xml using xsd
 
Similar Threads
create xml from xsd using xstream
help in testing xml
Genrating xml from the given xsd
Generate XML using XSD and data in CSV
how to validate xml document with xml schema in netbean and how to create simpleType in Netbean