Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Creating dynamic xml using xsd

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic