Free-form query results and result-set iterators

Simon and I had a brief chat during the this morning's telcon about
free-form or unformatted-type query results. I don't know if you're going to
speak to your thesis at greater length, Simon, but I thought I'd address
very briefly what the term "free-form" means from the perspective of an
XQuery-like language like my own.

Both XsRQL and XQuery return results that are free-form or unformatted, but
I think we should define our terms a bit. The results are "unformatted" or
"free-format" or "free-form" in the sense that:

(1) the result set consists of a number of items of various types that are
known to the data model, and

(2) the client has the ability to pose the query in such a way as to choose,
in a somewhat ad-hoc fashion, both the type and sequence of occurrence of
each individual item in the result set (or more accurately but perhaps less
euphoniously, the result sequence).

In the case of XsRQL, item types can be:

(a) (some TBD subset of) any of the XML Schema Part II built-in datatypes
[1] (such as boolean, string, decimal, date, gYear, integer, etc.), as well
as

(b) one of several RDF-type items (node, predicate, subject, object, triple,
quad, etc). In the case of (a), items might be integers to provide counts
and other stats or strings to provide textual annotations and/or formatting
commands (newline, tab, etc). In the case of (b), items will be actual nodes
and predicates retrieved from the store as query matches.

Both XQuery and XsRQL results are *not* free-form in the sense that the
serialization of each individual XML Schema item is generally (always?)
prescribed by its canonical lexical representation [2]. Items in the RDFItem
space, however, might allow some implementation leeway: ie, the result item
might be a triple, but how exactly that triple is to be serialized might be
left to the implementation and/or end-user option.

In terms of API's and how to access free-form query results, the design I'm
most familiar with is an item-iterator-type approach that looks something
like the following:

while ( nextItem = resultSequence.getNextItem() != null )
{
     switch( nextItem.getType() )
     {
         case INTEGER :

                  int intValue = nextItem.getIntValue();
                  // serialize and print intValue

         case STRING :

                  String strValue = nextItem.getStringValue();
                  // print strValue

         case TRIPLE :

                 Triple triple = nextItem.getTripleValue();
                 // serialize and print the triple

         // etc. ...
      }
}

Howard

[1] http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#built-in-datatypes

[2]
http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#canonical-lexical-repres
entation

Received on Tuesday, 6 July 2004 17:24:59 UTC