wood burning stoves*
The moose likes XML and Related Technologies and the fly likes Dynamic creation of xml document from xml schema Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Dynamic creation of xml document from xml schema" Watch "Dynamic creation of xml document from xml schema" New topic
Author

Dynamic creation of xml document from xml schema

Krzysztof Miarecki
Greenhorn

Joined: Nov 26, 2009
Posts: 6
How to dynamically create a valid xml document from xml schema? I mean - xml schema is unknown at compile time, lets assume that we put file path or url of xml schema at runtime, and application creates valid xml document with some default values...
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12758
    
    5
Basically that is impossible because a Schema defines what structure is legal but does not completely define a document.

Just think how many possible documents can be created fitting a single schema.

Bill

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I have never understood why anybody would want to do that. But I see this question a lot, so there must be some reason for it. However the people who ask the question never bother to explain why they need it so I am still baffled.

Anyway pretty much all of the XML editing tools on the market have that as a feature, I believe. I suppose they must be getting the same demand from their customers. Check them out. Google keywords: xml editor.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9915
    
158

Right, some of the code generation tools (like IDEs) do this - they create a skeleton xml file from the xsd. And like any other auto-generated code, this too needs further manual edits to make the xml practically useful for any application specifics. But outside code generation, I don't see where auto generation of xml from a schema might be applicable.

[My Blog] [JavaRanch Journal]
 
 
subject: Dynamic creation of xml document from xml schema
 
Similar Threads
How to Convert XSD into XML
how to find schema of an xml from dom program at run time
SAXParser not calling characters()
Wiered Exceptions while Validating XML
elements sequence in web.xml