# Generate XML from XSD in Java



## Bjorn_Of_Iceland (Dec 6, 2010)

Hi,

I'd just want to know, if there is any library out there that has a method that generates an xml file from an xsd file automatically. 

I plan to do this instead of creating an xml through code via dom4j's DocumentHelper and addElement(), addElement() shenanigans.


----------



## W1zzard (Dec 6, 2010)

xsd is the schema, xml contains the data conforming to that schema. how can you generate xml from xsd without data ?


----------



## Bjorn_Of_Iceland (Dec 6, 2010)

kind of like the one eclipse do, or other xml based tools like XMLSpy etc.. it fills the element value first with whatever the element name is or whatever restriction it already has. 

I then plan to fill these with valid values up later down the path.. in this way, I wont recode the hard coded xml generation whenever there is a change in the structure.. just change the xsd schema with what the current format is.

In anycase, it looks like these apps that have auto generation looks like was made from the ground up.. just wanted to make sure if there was already an existing java library function before I make one myself.


----------



## Jimmy6 (Dec 11, 2013)

In VS2010 if you load an XML file into the editor, click the XML menu >> Create Schema.


----------



## FordGT90Concept (Dec 18, 2013)

Visual Studio insists on having an XSD for all XML files to enforce compliance (as well as provide some autocompletion functionality).  You should code XSD before creating subsequent XML files based on it.

You can grab Visual Studio Express for free (requires registration) if you want to use it for XML/XSD authoring.


Edit: My bad.  I use DTD not schema.


----------

