1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Generate XML from XSD in Java

Discussion in 'Programming & Webmastering' started by Bjorn_Of_Iceland, Dec 6, 2010.

  1. Bjorn_Of_Iceland

    Bjorn_Of_Iceland

    Joined:
    Jan 2, 2008
    Messages:
    3,177 (1.31/day)
    Thanks Received:
    375
    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.
    Last edited: Dec 6, 2010
  2. W1zzard

    W1zzard Administrator Staff Member

    Joined:
    May 14, 2004
    Messages:
    14,745 (3.93/day)
    Thanks Received:
    11,462
    xsd is the schema, xml contains the data conforming to that schema. how can you generate xml from xsd without data ?
  3. Bjorn_Of_Iceland

    Bjorn_Of_Iceland

    Joined:
    Jan 2, 2008
    Messages:
    3,177 (1.31/day)
    Thanks Received:
    375
    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.
    Last edited: Dec 6, 2010
  4. Jimmy6

    Jimmy6

    Joined:
    Nov 12, 2013
    Messages:
    74 (0.26/day)
    Thanks Received:
    2
    In VS2010 if you load an XML file into the editor, click the XML menu >> Create Schema.
  5. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    13,415 (6.27/day)
    Thanks Received:
    3,394
    Location:
    IA, USA
    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.
    Last edited: Jan 11, 2014
    Crunching for Team TPU

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page