This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 13187 - map in xquery/xpath
Summary: map in xquery/xpath
Status: RESOLVED DUPLICATE of bug 11493
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Requirements for Future Versions (show other bugs)
Version: Working drafts
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Jim Melton
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-09 19:05 UTC by Jim Fuller
Modified: 2011-07-21 23:48 UTC (History)
2 users (show)

See Also:


Attachments

Description Jim Fuller 2011-07-09 19:05:51 UTC
I could not find a place where to register my desire for map:map in xquery/xpath so I entered here ... apologies if this is a dupe, etc.

I have been using Saxon and MarkLogic implementation of map:map for the past few months and am convinced of its usefulness.

some adhoc usage scenarios;

controller: keeping routing in memory makes things zippy, and a very common map for me nowadays is one where the keys are uri's and values whatever I need (think url rewriting) or even functions to be passed ala HOX (higher order xquery) 


memoize: maps makes it easy to provide inline func caching ala

https://gist.github.com/954816

working with json: maps make life a bit easier in this respect

there are more ....
Comment 1 David Lee 2011-07-21 22:48:17 UTC
XQuery and/or XPath need either a map or a nested sequence.
An extremely common use case is to load a coded value map which is used across a complex xquery program.   Today you need to put this into an XML object and use xpath hoping it is optimized.   By providing either a map or a nested sequence then processors have the necessary hints to optimize the access.

These are actually subtly 2 separate use cases.


Maps:   provide a guaranteed (or at least implied) efficient mapping of key->value pair for xquery processors.   Example: mapping codes to values. (say ICD9 codes to descriptions.  So instead of of using   collection("IDC9")/value[@code eq 'value']  you could preload the map so you could use map:map( $icd9 , 'value' ).

Agreed this is primarily a hint to optimizers.  In theory any implementation should be able to index arbitrary XML as maps.  But in practice it is very difficult and rarely done.


As for sub-sequences.  This is a similar but not identical problem.

Maps *could* be implemented as sub-sequences such as 

(  "key" , ( "value1" , "value2" , "value3" ) ,
   "key2" ,( "value1" , "value2" , "value3" ) )


but this requires a major change in xquery semantics which would be not backwards compatible.   I feel that sub-sequences should have been implemented from the start (aka Lisp) but as they were initially flattened into single level sequences it may be a hard step to implement them without backwards comparability problems.


A Map as a top level object would solve most sub-sequence use cases without backwards compatibility problems.
Comment 2 Michael Kay 2011-07-21 23:48:39 UTC

*** This bug has been marked as a duplicate of bug 11493 ***