W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2005

RE: Creating library schemas which only expose a single document element

From: <noah_mendelsohn@us.ibm.com>
Date: Mon, 23 May 2005 08:47:26 -0400
To: "Michael Kay" <mike@saxonica.com>
Cc: "'Fraser Crichton'" <fraser.crichton@solnetsolutions.co.nz>, xmlschema-dev@w3.org
Message-ID: <OF2622F0EB.09D14185-ON8525700A.00462CA1-8525700A.00468DF5@lotus.com>

I agree with Michael on this.  Another factor, which may or may not be of 
interest in your case, is that in principle you can do validations of 
portions of your documents, presuming they are described by global element 
descriptions.  Indeed, one of the reasons the schema WG did not call out a 
separate marking for root elements, is that we would have had to invent a 
second processing model to ignore it in the case where you really only 
wanted to validate part of a document.  Why would you want to do that?  As 
examples:  you might want to validate only the body of a soap message, or 
you might in an editor want to revalidate only the portions recently 
changed.  One thing to watch in doing such things are identity constraints 
and ID/IDREF, which are enforced within the scope of the current 

Anyway, for all that local element declarations are syntactically 
convenient and occasionally the right thing semantically, it's globals 
that tend to be more robust for many purposes.  Globals also are the 
constructs that roughly mimic DTD declarations.

FWIW:  the schema WG is also aware that there are some good uses for 
designating document roots in a schema document, and we were discussing 
the pros and cons as recently as last week's face-to-face meeting.

Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142

"Michael Kay" <mike@saxonica.com>
Sent by: xmlschema-dev-request@w3.org
05/23/05 04:17 AM

        To:     "'Fraser Crichton'" <fraser.crichton@solnetsolutions.co.nz>, 
        cc:     (bcc: Noah Mendelsohn/Cambridge/IBM)
        Subject:        RE: Creating library schemas which only expose a single document element

When you eventually come to write schema-aware queries or stylesheets, 
you'll find that it's a good idea to make most of your elements global.
I would be inclined not to distort the schema design for this purpose. 
Find some other way of checking that the top-level element in the instance 
document is the one you want it to be.
Michael Kay

From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org] On Behalf Of Fraser Crichton
Sent: 23 May 2005 03:17
To: xmlschema-dev@w3.org
Subject: Creating library schemas which only expose a single document element

This kind of a follow up to something I posted to XML-DEV -Validating against the correct root element using library schemas http://lists.xml.org/archives/xml-dev/200505/msg00263.html (BTW thanks, Michael and Henry, for getting back to me).
If I'm creating a set of library schemas where I want to enforce that 
particular document / message schemas are valid and that no fragments of 
documents are valid  it seems I have two approaches  - 

1) I adopt a strict venetian blind approach i.e. there are no global 
element declarations in my library schemas and only a Russian doll 
approach in my message / document schemas to enforce that there is only 
one valid root element (however that way I can't create any reusable 
elements just reusable types).

2) I use xsd:group to hide my global elements but get reuse from them by 
referencing the groups.

I have a some questions -

Would the xsd:group approach just be a dirty hack? 

Is there any reason why OASIS have not adopted xsd:group (sorry to keep 
banging on about OASIS but the New Zealand government are looking at a 
number of their standards ;-) )?



Attention: This email may contain information intended for the sole use of 
the original recipient. Please respect this when sharing or disclosing 
this email's contents with any third party. If you believe you have 
received this email in error, please delete it and notify the sender or 
postmaster@solnetsolutions.co.nz as soon as possible. The content of this 
email does not necessarily reflect the views of SolNet Solutions Ltd. 
Received on Monday, 23 May 2005 12:47:35 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:08 UTC