This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating dynamic xml using xsd

 
Poonam Thawani
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Robert Hayes
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic