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

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 

Received on Tuesday, 12 May 2009 12:30:18 UTC