W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > October to December 2000

re: xml schema question

From: Marc de Graauw <marc@marcdegraauw.com>
Date: Tue, 3 Oct 2000 16:52:55 +0200
Message-ID: <01C02D5A.76E1F400.marc@marcdegraauw.com>
To: "'www-xml-schema-comments@w3.org'" <www-xml-schema-comments@w3.org>
Schema Part 1 says: "We have not so far seen any need to reconstruct the 
XML 1.0 notion of root."

There have been several questions on this subject, however I do not fully 
understand the reasons why Schema does not support the restriction of 
allowable root elements within an instance. It seems to me a Schema could 
very well function as a kind of digital "contract" between parties which 
exchange documents. For instance, a company po.com could issue a Schema 
po.xsd, effectively saying to its customers: "If you send us a purchase 
order which is schema valid with respect to po.xsd, then that will be a 
purchase order which we can process". Of course, po.com would not want to 
receive the purchase order Helena Cavanagh describes:

<?xml version="1.0"?>
<comment>Is this possible?</comment>

The Schema author could prohibit this by making "comment" a non-global 
element. However, there could be other design reasons to make "comment" a 
global element: the Schema author might want to have "comment" available 
for use in content models throughout po.xsd. Let's suppose the Schema 
author wants to keep "comment" global.

Henry Thompson writes in response to Helena:

> With respect to root/document element, XML 1.0 doesn't give you this
> facility (in DTDs) -- XML Schema does, in that chapter 7 describes how
> to invoke schema validation specifying the starting element
> declaration to use.

In that case, a customer of po.com could make an instance order.xml as 
above, validate it with "comment" as starting element, and send it to 
po.com, where it would be validated with "purchaseOrder" as starting 
element and fail because there is no "purchaseOrder" element (with a simple 
example like po.xsd in the Primer this would not happen, in the real world 
it certainly would). As far as I can see, the only way for po.com to avoid 
this mistake would be to write a companion document for po.xsd which 
describes which elements are acceptable as root (or to make "purchaseOrder" 
the only global element declaration, which is undesirable for reasons 
stated above).

It seems to me it would be preferable if the Schema author could restrict 
the use of global elements as root, for instance by writing something like:

<xsd:element name="comment" type="xsd:string" nonroot="True"/>

saying that "comment" does not constitute one of the possible root 
elements. The absence of the nonroot attribute would indicate that the 
global element is acceptable as root (like all global elements are in the 
current spec). Of course it is not a desirable feature to restrict possible 
roots to only one in every Schema. It is true that XML 1.0 and DTD don't 
support this either, but that in itself does not seem a sufficient reason 
why Schema doesn't.

Am I missing something? Are there other ways to achieve what I want? Or is 
Schema not intended to be used in the way I suggest po.com uses it?

Thanks for your response,

Marc

Marc de Graauw IT
Orteliuskade 44-2
1057 AH  Amsterdam
tel:	+31 20 6123 281
mob:	+31 6 53 146724
fax: 	+31 20 6123 964
Received on Tuesday, 3 October 2000 10:51:11 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 18:12:48 GMT