Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Creating XML from schema?

From: "A. W. Dunstan" <no@----.------>
To: NULL
Date: 7/7/2008 11:27:00 AM

I've got a schema file (four, actually - one includes the other three) and
am trying to create a 'sample' XML file from it.

I tried reading the .xsd files myself but the four of them combined add up
to more than 4000 lines - more than enough to put me to sleep.

I also tried some Java:

  SchemaFactory sf =
    SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  Schema schema = sf.newSchema(new File("/path/to/main/schema/file.xsd"));
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  dbf.setSchema(schema);
  dbf.setNamespaceAware(true);
  dbf.setValidating(true);
  dbf.setXIncludeAware(true);
  DocumentBuilder db = dbf.newDocumentBuilder();
  Document d = db.newDocument();

which compiles & runs without incident when run from the directory with the
schema files, but produces an empty Document (zero child nodes).

I'm working on getting a sample XML document from the folks I got the schema
from, but that might take a while.

I've looked around in NetBeans and IntelliJ but haven't seen anything that
looks like it'll do what I want.  They can both _validate_ an existing XML
file, but that's what I'm trying to create.

Is there a way to do this?

I realize it might not be possible - some of the nodes might be 'choose
exactly one of A or B', or 'if you have X you must also have Y but if not
then you must have Z' and I'd then need some way of saying which option(s)
to go with.

I really don't care what values the text/numeric fields have; empty (or
zero) would be fine - I can stuff 'realistic' data in afterward, once I've
got the structure of the document spelled out.

thanks!

-- 
Al Dunstan, Software Engineer
OptiMetrics, Inc.
3115 Professional Drive
Ann Arbor, MI  48104-5131


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent