<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>13187</bug_id>
          
          <creation_ts>2011-07-09 19:05:51 +0000</creation_ts>
          <short_desc>map in xquery/xpath</short_desc>
          <delta_ts>2011-07-21 23:48:39 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Requirements for Future Versions</component>
          <version>Working drafts</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>11493</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jim Fuller">jim.fuller</reporter>
          <assigned_to name="Jim Melton">jim.melton</assigned_to>
          <cc>dlee</cc>
    
    <cc>mike</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>50862</commentid>
    <comment_count>0</comment_count>
    <who name="Jim Fuller">jim.fuller</who>
    <bug_when>2011-07-09 19:05:51 +0000</bug_when>
    <thetext>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&apos;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 ....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51357</commentid>
    <comment_count>1</comment_count>
    <who name="David Lee">dlee</who>
    <bug_when>2011-07-21 22:48:17 +0000</bug_when>
    <thetext>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-&gt;value pair for xquery processors.   Example: mapping codes to values. (say ICD9 codes to descriptions.  So instead of of using   collection(&quot;IDC9&quot;)/value[@code eq &apos;value&apos;]  you could preload the map so you could use map:map( $icd9 , &apos;value&apos; ).

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 

(  &quot;key&quot; , ( &quot;value1&quot; , &quot;value2&quot; , &quot;value3&quot; ) ,
   &quot;key2&quot; ,( &quot;value1&quot; , &quot;value2&quot; , &quot;value3&quot; ) )


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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51362</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2011-07-21 23:48:39 +0000</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 11493 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>