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 Dynamic creation of xml document from xml schema Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply 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: 11689
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


Java Resources at www.wbrogden.com
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 12865

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
Saloon Keeper

Joined: Jul 20, 2005
Posts: 6561

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
 
MyEclipse, The Clear Choice