EditiX DTD Tutorial
v1.0
Validating an XML document requires a schema. This schema is a kind of
grammar
used by the XML parser defining the way your XML document is organized.
There's several schemas for XML, the oldest one is the DTD. We
will
generate a DTD for our document, thus adding completion helper and
checking
our final document.
For more information about a DTD, please look at the W3C site : http://www.w3c.org
We suppose for this tutorial, we have an XML document containing a list
of persons.
This document looks like :
<personnel>
<person id="Alex">
...
</person>
<person id="Mike">
...
</person>
</personnel>
Step 1 : Generate a DTD
We load our XML document
We generate our DTD using the following action :
This action has opened a new document. We save it in the same directory
than
our initial XML document calling it 'personal.dtd'
Step 2 : Assign a DTD to our XML document
We select our XML document. Then we use the same previous menu
"DTD/Schema"
invoking the first action "Assign DTD to document..."
The root node containing the main document element. This field is
automatically
filled, we select our previous DTD document 'personnal.dtd'.
EditiX has added the DTD header "<!DOCTYPE...".
Step 3 : Test for completion and validation
We can now validate our document each time we change it with the
following
toolbar action
.
Now each time we insert the '<' caracter, a popup will propose us
available
tags depending on our location.
For remark : The assign action, insert an absolute path, it is often
better to have a relative path like <!DOCTYPE ... "personal.dtd">
or
an URL from an HTTP server to share a DTD between several documents.