Just a doubt...

Ronald Bourret rbourret at ito.tu-darmstadt.de
Thu Jan 7 09:39:35 GMT 1999


Cesar Bonavides M. wrote:

> To make it simple:
>   I already read the XML, XLink, XPointer and XSL stuff, but that thing
> about XML-data and XML-schemas really did confuse me.

Currently, the legal format of an XML file is defined in a DTD.  For 
example, the following DTD defines XML documents in which a Memo element 
contains one or more Paragraph elements and a Paragraph element contains 
parsed character data:

<!ELEMENT Memo (Paragraph+)>
<!ELEMENT Paragraph (#PCDATA)>

XML schema languages are an attempt to replace DTDs.  That is, they are XML 
languages used to defined other XML languages.  For example, the DTD shown 
above can be defined in XML-Data as:

<schema>
   <elementType id="Memo">
      <element type="#Paragraph" occurs="ONEORMORE"/>
   </elementType>
   <elementType id="Paragraph">
      <string/>
   </elementType>
</schema>

There are two main reasons to do this.  The first reason is that DTDs are 
restricted by the XML 1.0 requirement that XML be compatible with SGML. 
 Thus, DTDs cannot be extended in ways that are incompatible with SGML 
DTDs.  However, schema languages are not restricted and can therefore be 
extended in new ways, such as data typing of elements.

The second reason is more practical in nature.  Because many people write 
XML documents but few people write XML DTDs, many more tools and 
technologies are available for XML documents than for XML DTDs.  Because 
schema languages use XML document syntax, they can use the tools and 
technologies designed for XML documents.

As a simple example, suppose you are writing an XML editor and you want to 
use DTDs to control user input -- for example, if somebody is editing a 
memo that conforms to the above DTD, you want to be sure that the Memo 
element contains Paragraph elements but not other Memo elements.  Because 
most XML parsers do not return DTD information to the application, you 
would need to write your own DTD parser.  However, if your document schemas 
were defined using a schema language instead of DTDs, you could parse the 
schema documents using any available XML parser.

There are currently four proposed schema languages:

XML-Data:	http://www.w3.org/TR/1998/NOTE-XML-data
XSchema:	http://www.simonstl.com/xschema/spec/xscspecv6.htm
DCD:		http://www.w3.org/TR/NOTE-dcd
SOX:		http://www.w3.org/TR/NOTE-SOX/

All of these languages are very similar at a base level -- defining 
elements and attributes and so on. They differ to some extent in the degree 
to which they replace DTDs; for example, some can define entities and some 
can't.  They differ radically in the other capabilities they offer: 
XML-Data is the most ambitious and XSchema is the simplest.  Eventually, 
all of these languages will be replaced by one currently being defined by 
the W3C.

Since you are just starting out with XML, you might not need to worry about 
schema languages.  If you are still interested, I suggest starting with 
XSchema, as I think it is the simplest (disclaimer: I am one of the authors 
and admittedly biased).  A couple of other things to consider:
(a) XML-Data is (I believe) no longer being worked on, but is used by the 
Microsoft parser as a way to expose DTD information.
(b) You will probably want to convert any code you write to the W3C's 
schema language when it is published, so it might be safest to stick with 
the basics.

-- Ron Bourret


xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list