Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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 Badass: Making Users Awesome this week in the Game Development 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

Dynamic creation of xml document from xml schema

Krzysztof Miarecki

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

Joined: Mar 22, 2000
Posts: 12910
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.


Paul Clapham

Joined: Oct 14, 2005
Posts: 19357

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

Joined: Jul 20, 2005
Posts: 10403

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]
I agree. Here's the link:
subject: Dynamic creation of xml document from xml schema