Chapter 4: Import and Export XML into Schemas
A very important feature of a good XML Schema editor is the
ability to import an instance document and create the schema
for you. Also, it can be handy to generate a sample Instance
Document from a schema. xmlDraft does both of these.
Importing an XML Document
xmlDraft allows the user to import any XML document and generate
a basic XML schema for you. For example, if you were to import the
following document:
This is the schema that would be generated:
The document is rather simple, a framework of the Instance document,
but enough to start working with. This is the bare minimum I would
expect from an XML Schema editor, and more is planned for xmlDraft.
Exporting a Sample XML Document
In addition to importing XML, there are times when it would be nice
to have a blank, sample XML document of a particular schema. For example,
when generating a Stylesheet, you typically work off of a "template",
meaning an XML document that doesn't really contain data, just the
nodes. If you have a Schema, then creating said sample document is
a nice feature indeed.
Fortunately, xmlDraft does this as well. Let's look at this Schema:
A rather simple schema representing a Book. Notice that there
is a globally referenced complexType. When we export it, we get the
following XML document:
Simple, yes, but now gives us a great starting point to work with. Very
handy as well when dealing with larger, more complex schemas.
|