Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: "C. M. Sperberg-McQueen" <cmsmcq@-------------.--->
To: "Costello, Roger L." <costello@-----.--->
Date: 4/27/2009 3:47:00 AM
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
****************************************************************





From costello@m... Mon Apr 27 16:04:33 2009
Received: from maggie.w3.org ([193.51.208.68])
	by frink.w3.org with esmtp 


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent