SequenceTyping matching of 'element QName'

The draft spec (2.4.2) says that to match a SequenceType
of form ("element" |  "attribute") ElemOrAttrType? when
ElemOrAttrType is a QName:

   The QName must be an element or attribute name that is
   found in the   in-scope schema definitions. The match is
   successful only if the given element or attribute has the
   required name and also conforms to the schema definition
   for the required name.

And Conformance section 2.5.2.1 Basic XQuery says:

   If any SequenceType contains an ElemOrAttrType, a Basic XQuery
   implementation raises a static error.

This is very unfortunate, since it is very useful to be able to
match a node against a specific element tag in a typeswitch.  I'd
go so far as to say that this guts most of the usefulness of
typeswitch.  The alternatives seem to be a lot more tedious and verbose.

It is especially unfortunate for me since the examples I use in
my article "Generating XML and HTML using XQuery" (available as
http://www.gnu.org/software/qexo/XQ-Gen-XML.html) now suddenly
because non-conforming without a matching Schema.

Please revisit this.

A suggestion, which has the advantage that it provides much of the
power of XSLT's template processing:  Add a pseudo-type for matching
against a PATTERN:
   "matching" PathExpr
I don't know if I'd go so far as to allow this everywheer that
SequenceType is currently allowed, but I'd certainly allow it in
the context of typeswitch:

typeswitch ($node)
   case matching meta/title return "saw title inside a meta-tag"
   case matching title[@id] return "saw a title with an 'id' attribute"
   case matching title return "saw title not in a meta-tag
   default return "saw some other tag"

Perhaps allow "match" as a synonym for "case "matching" to make it
less verbose:

typeswitch ($node)
   match meta/title return "saw title inside a meta-tag"
   match title[@id] return "saw a title with an 'id' attribute"
   match title return "saw title not in a meta-tag
   default return "saw some other tag"

With this feature XQuery can do most of what XSLT can do, and much
less verbosely.

Perhaps adding the full PathExpr may be a bit much for Basic XQuery 1.0,
but allowing 'matching NodeTest' may be a good start
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/

Received on Thursday, 17 October 2002 03:26:11 UTC