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

Re: [XML Schema 1.1] I respectfully recommend these changes to <assert> and <alternative>

From: Mukul Gandhi <gandhi.mukul@gmail.com>
Date: Tue, 12 May 2009 18:36:59 +0530
Message-ID: <7870f82e0905120606s20dcec75qc688f8c548ee31a8@mail.gmail.com>
To: "Costello, Roger L." <costello@mitre.org>
Cc: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Hi Roger,
   I have following comments on XML Schema 1.1 assertions..

Please consider this Schema example, and some assertion definitions:

<xs:element name="books">
 <xs:complexType>
  <xs:sequence>
    <xs:element name="book" type="bookType" maxOccurs="unbounded" />
  </xs:sequence>
  <xs:attribute name="numbers" type="xs:int" />
  <xs:assert test="count(./book) gt 5" />
 </xs:complexType>
</xs:element>

<xs:compleType name="bookType">
  <xs:sequence>
   <xs:element name="title" type="xs:string" />
   <xs:element name="isbn" type="xs:string" />
   <xs:element name="price" type="xs:string" />
  </xs:sequence>
  <xs:assert test="ends-with(price, 'USD')" />
</xs:complexType>

XML Schema 1.1 assertions is the property of the 'Schema type'. The
assertion on 'books' says, we must have more than 5 'book' elements.

While the assertion on 'book' (actually on the type, 'bookType') says,
that the price string must have a suffix, 'USD'.

The first assertion operates on the tree rooted at, 'books'. While the
2nd assertion operates on the tree rooted at, 'book'. The 2nd
assertion would run on all instances of 'book'.

We could define suitable assertions, at anywhere in the hierarchy of
the Schema document.

My personal opinion is, I think, the current assertions spec looks
good and modular to me.


On Tue, May 12, 2009 at 5:59 PM, Costello, Roger L. <costello@mitre.org> wrote:
>
> Hi Folks,
>
> Having "lived" for a while with the new <assert> and <alternative> elements, I recommend the working group consider the following changes to them.
>
>
>
> BACKGROUND
>
> XML Schema 1.1 provides these two new elements:
>
>   <assert>
>
>   <alternative>
>
> Each of these elements uses an XPath expression:
>
>   <assert test="XPath">
>
>   <alternative test="XPath">
>
> But the XPath is constrained in what it can reference:
>
>   The XPath in <assert> can only reference
>   elements and attributes on the current
>   element plus descendants.
>
>   The XPath in <alternative> is even more
>   restrictive - it can only reference
>   attributes on the current element. It
>   cannot reference descendents.
>
>
>
> PHILOSOPHY (I DIGRESS)
>
> When I make a decision I typically take into account many factors, some of which are not local. For example, I decide whether or not to go to the beach based upon how I'm feeling (local factor), the weather (external factor) and the traffic conditions (again, an external factor).
>
> My point is that making an assertion based on the current element and its descendants (i.e. on local information) is not reflective of how decisions are made in the real world.
>
>
>
> PREDICTION (UNINTENDED CONSEQUENCES)
>
> Due to the limitation on what XPath can reference, I predict that schema developers will put all assertions on the document's root element. In fact, that is what I currently recommend to people:
>
>   Due to the limitation on what XPath
>   can reference, I recommend all assertions
>   be placed on the document's root element.
>
> Further, since XPath cannot use doc() to reference other sources of data, I predict that schema developers will embed that remote data into the current schema. Thus, rather than using doc() to reference an instance document that lists all the countries, developers will copy that list of countries and embed it into his/her current schema. The result? Rather than a highly distributed web of information and schemas, we end up with monolithic schemas.
>
>
>
> RECOMMENDATION
>
> I respectfully recommend the working group remove the restrictions on what XPath can reference in the <assert> and <alternative> elements. For the <assert> element I recommend the XPath be allowed to reference any part of the document (ancestors, cousins, siblings, descendents) as well as external documents using the doc() element. For the <alternative> element I recommend the XPath be allowed to reference any part of the document except descendents as well as external documents using the doc() element.
>
>
> Thank you for your time.
>
>
> /Roger
>



-- 
Regards,
Mukul Gandhi
Received on Tuesday, 12 May 2009 13:07:54 GMT

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