W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2009

RE: [XML Schema 1.1] Using doc() in xs:assert ... the referenced document needs a schema?

From: Michael Kay <mike@saxonica.com>
Date: Mon, 27 Apr 2009 15:41:23 +0100
To: "'Costello, Roger L.'" <costello@mitre.org>, <xmlschema-dev@w3.org>
Message-ID: <1ECA00825FA74620A792A1F7B75D20AC@Sealion>

I suspect your comments are based on the Saxon-SA 9.1 implementation, rather
than on the W3C specification in its current state.

The current draft of XSD 1.1 says that the set of available documents is
empty, which is another way of saying that you can't usefully use the doc()
function in an assertion.

If you're using Saxon, then you might find that it doesn't work that way, at
least in 9.1: but it's likely to change to align with the specification.

It's a shame perhaps that the WG decided not to open the door to
cross-document validation by this mechanism. I did actually try to get it
working in Saxon, perhaps in the hope that a working implementation would
help to sway the WG, but I hit difficulties in the implementation and
decided to stick to the spec for the time being. Anything that works in 9.1
in this area is by accident rather than design - it's not tested, and
certainly has some potential difficulties (for example, the document is
likely to be parsed from disk each time the assertion is evaluated.

If you do want to experiment with cross-document assertions in Saxon, you
can probably do it using Java extension functions.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: xmlschema-dev-request@w3.org 
> [mailto:xmlschema-dev-request@w3.org] On Behalf Of Costello, Roger L.
> Sent: 27 April 2009 15:18
> To: 'xmlschema-dev@w3.org'
> Subject: [XML Schema 1.1] Using doc() in xs:assert ... the 
> referenced document needs a schema?
> 
> 
> Hi Folks,
> 
> 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?
> 
> These requirements don't seem reasonable to me. 
> 
> I should be able to reference any instance document (under my 
> control or otherwise) and use it as a data source.
> 
> These requirements mean:
> 
>    - I can't reference instance documents that don't have a schema
> 
>    - I can't reference instance documents that uses some other
>      schema language, such as DTD or RELAX NG.
> 
>    - Everything is tightly coupled: the schema, the referenced 
>      instance document and its schema. I can't easily switch to 
>      another instance document and use it as a data source.
> 
> 
> Would someone please explain the rationale for these requirements?
> 
> /Roger
Received on Monday, 27 April 2009 14:42:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:11 GMT