[Bug 5630] Tuples and maps

http://www.w3.org/Bugs/Public/show_bug.cgi?id=5630

           Summary: Tuples and maps
           Product: XPath / XQuery / XSLT
           Version: Working drafts
          Platform: PC
               URL: http://www.nesterovsky-bros.com
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Data Model 1.1
        AssignedTo: alb.w3c@gmail.com
        ReportedBy: vladimir@nesterovsky-bros.com
         QAContact: public-qt-comments@w3.org


I suggest to introduce two types into xpath/xslt/xquery type system:
  opaque sequence (tuple), and
  associative array (map);

Tuples and maps should be considered as atomic values. In contrast to
sequences, sequence of tuples or maps is not transformed into signle sequence.

Tuples and maps need to be comparable. 
This way one can sort/group by several values at once.

Tuple shall store a sequence of items, or more specific types.
Tuple shall be constructed from a sequence.
Tuple shall allow to access contained sequence.
Possible examples of tuple declarations:
  tuple() - tuple containing a sequence of items;
  tuple(*) - the same;
  tuple(xs:int, node()) - pair containing int and node;
  tuple(xs:string+) - tuple containing non empty sequence of strings.

Map shell store a collection of pairs (key, value).
Map shall be constructed from a sequence of (key, value) pairs.
Map shall allow to get a contained sequence of (key, value) pairs.
Map shall allow to get a contained sequence of keys.
Map shall allow to get a contained sequence of values.
Map shall allow to get a sequence of values corresponding to a specified key.
Possible examples of tuple declarations:
  map() - map of items;
  map(xs:string, element()) - map of string (as key) to element() as a value.

To support tuples and maps library shall define functions:
  tuple($items as item()*) as tuple();
    Constructs a tuple from items.

  tuple-items($tuple as tuple()) as item()*
    Returns contained items for a specified tuple.

  tuple-item($tuple as tuple(), $index as xs:integer) as item()?
    Returns an items with a specified index for a specified tuple.

  map($items as item()*) as map();
    Constructs a tuple from (key, value) pairs of items.

  map-items($map as map()) as item()*;
    Returns (key, value) items, contained in a map.

  map-keys($map as map()) as item()*;
    Returns keys, contained in a map.

  map-values($map as map()) as item()*;
    Returns values, contained in a map.

  map-value($map as map(), $key as item()) as item()*;
    Returns values, contained in a map, and corresponding to a specified key.

Received on Monday, 7 April 2008 08:34:57 UTC