- From: C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com>
- Date: Mon, 27 Apr 2009 09:47:04 -0600
- To: "Costello, Roger L." <costello@mitre.org>
- Cc: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>, "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
On 27 Apr 2009, at 08:18 , Costello, Roger L. wrote: > > Here's a simple schema that uses xs:assert to check that the value > of the <country> element matches one listed in an instance document > (countries.xml): > > --------------------------------------------------------------- > <?xml version="1.0"?> > <schema xmlns="http://www.w3.org/2001/XMLSchema" > elementFormDefault="qualified"> > > <element name="Example"> > <complexType> > <sequence> > <element name="country"> > <simpleType> > <restriction base="string"> > <assert test="$value = > doc('countries.xml')//country" /> > </restriction> > </simpleType> > </element> > </sequence> > </complexType> > </element> > > </schema> > --------------------------------------------------------------- > > > While running this example, I discovered these requirements: > > - the instance document referenced by xs:assert (countries.xml) > must have a schema, and > > - I have to import that schema. > > Why? Can you provide a little more information? Where did you discover these requirements? They don't look at first glance as if they were requirements imposed by the XSD 1.1 spec. Unless I am mistaken about the rules of XPath expression evaluation, the issue of whether documents retrieved using the doc() function must have a schema or not does not in fact arise in XSD 1.1. The Last Call draft of XSD 1.1 says that the 'available documents' property of the dynamic context for XPath evaluation on assertions is the empty set. That should mean, if I understand correctly, that the subexpression doc('countries.xml') returns the empty node sequence. Making the 'available documents' property be the empty set helps ensure (a) better interoperability between validators, and (b) the context-independence of schema-validity assessment of an element or attribute against a declaration or type definition. The context-independence of validation against a type is important to many users of XSD (although not, I suspect, to all). If you want to validate cross-document references in this way, you should certainly look at SML, which is designed precisely to allow validation across document boundaries; in SML, your constraint would be a straightforward keyref constraint requiring the value of the 'country' element to match one of the keys in 'country.xml'. > > Would someone please explain the rationale for these requirements? I'm happy to explain the rationale for various aspects of the design of XSD, as I understand the rationale. But as I said the requirements you identify don't seem to stem from XSD; if you can say a bit more about where they come from, perhaps someone with knowledge of the source can speak up. -- **************************************************************** * C. M. Sperberg-McQueen, Black Mesa Technologies LLC * http://www.blackmesatech.com * http://cmsmcq.com/mib * http://balisage.net ****************************************************************
Received on Monday, 27 April 2009 15:47:42 UTC