Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Creating XML from schema? Creating XML from schema?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
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
