473,395 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Creating XML from schema?

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_SCH EMA_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
Jul 7 '08 #1
3 2445
A. W. Dunstan wrote:
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:
I don't know of a Java solution.
Here is an article about doing it with the .NET framework:
http://msdn.microsoft.com/en-us/library/aa302296.aspx
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 7 '08 #2
Found one! Eclipse did a decent job of it. Create a Java project, add the
Schema files to the project, right click on the main schema file & select
Generate->XML.

It gives text fields a value equal to the name of the element itself:

<SpecialNotation attrib="A">SpecialNotation</SpecialNotation>

even though many of them have additional restrictions placed on them -
min/max length, allowed characters (all caps & limited punctuation in this
case), select-from-enumerated-list, etc.

But it gave me a decent structure to start out with; I can fill in valid
values with an editor.
--
Al Dunstan, Software Engineer
OptiMetrics, Inc.
3115 Professional Drive
Ann Arbor, MI 48104-5131
Jul 7 '08 #3
On Jul 7, 11:26 am, "A. W. Dunstan" <n...@spam.thankswrote:
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_SCH EMA_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
I don’t know if this is what you want but Eclipse does this very
nicely.

J Leonard

Jul 7 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Brett Selleck | last post by:
We have an issue where the JAXB generated classes are creating an interface which references itself. The Schema is valid, and I have not seen this ran into before. The code is below. What is...
0
by: Fendi Baba | last post by:
Hi everyone I am new in this so please bear with me. I am trying to create a schema for a Quotation document. I created the creating the forms using Microsoft Infopath. I am creating my own...
0
by: Jeremy Summers | last post by:
Has anyone run into problems creating typed datasets from complex schemas? I am attempting to create a Typed Dataset in Visual Studio .Net from a .xsd schema file for a industry standard web...
1
by: Chris Kennedy | last post by:
How do create a dataset from scratch based on an XML schema. This will not be filled by a dataadapter. It will be a dataset which I add rows to and then save as an XML file. All the example depend...
0
by: Ganesh | last post by:
Can someone tell me how do i go about creating an xml schema for a web service that i need to develop. Basically what the web service does is reads the input schema and displays a list of forms...
3
by: Kiran | last post by:
Hi, I want to back up my data in some table in SQL server and import it back using Bulk Load of SQL server 2K. I can use the following code to backup the data in XML ...
3
by: Sindarian | last post by:
I have a Schema from the folk that shows how they want the data received. I have my own database that has that data, but in a different way (they use 33 freaking tables to store what I do in 1)....
0
by: jackfrancy | last post by:
Hi , When I tried to create web reference (Proxy Class) from WSDL.EXE or Visual Studio 2003 web Reference Tool Following error has occurred . “The error message from each known type may help...
3
by: %NAME% | last post by:
Suppose I am an admin of a database instance. Now I need to specify that user A has the right to create tables in his own schema, but not anywhere else. In order to let user A create tables, i...
0
by: mk189 | last post by:
Hi, I am trying to create XML schema of custom markup language, enriched by XHTML. In simplified version, the XML documet could look like that: <a:alarm-manual xmlns:a="alarm-manual"...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.