Matthias Brantner has proposed merging lp:~zorba-coders/zorba/bug900677 into 
lp:zorba.

Requested reviews:
  Matthias Brantner (matthias-brantner)
  Markos Zaharioudakis (markos-za)
  William Candillon (wcandillon)
Related bugs:
  Bug #900677 in Zorba: "XQDDF access-keys($index) function"
  https://bugs.launchpad.net/zorba/+bug/900677

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug900677/+merge/116097

Added a keys() function to the index dml module. This fixes bug #900677.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug900677/+merge/116097
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-07-20 02:54:05 +0000
+++ ChangeLog	2012-07-20 23:52:30 +0000
@@ -17,6 +17,8 @@
     http://www.zorba-xquery.com/modules/store/data-structures/unordered-map module.
   * Added support for fragments to fn:path
   * Positional pagination support for collections
+  * Added a function to the http://www.zorba-xquery.com/modules/store/static/indexes/dml module which returns
+    the value of all keys contained in an index.
   * Incremental maintenance for general indexes.
 	
 Optimizations:

=== modified file 'doc/zorba/xqddf.dox'
--- doc/zorba/xqddf.dox	2012-07-12 17:29:55 +0000
+++ doc/zorba/xqddf.dox	2012-07-20 23:52:30 +0000
@@ -1984,6 +1984,27 @@
 </li>
 </ul>
 
+\subsection index_keys Retrieving Index Keys
+In addition to probing an index, the <tt>idml</tt> module also provides a function that allows listing all the keys contained in an index.
+
+\code
+  idml:keys($indexName as xs:QName) as item()*
+\endcode
+
+This function returns a sequence of element nodes.
+Each node in the sequence represents one key contained in the index and has the following structure:
+
+\code
+ <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";>
+   <attribute value="key_1"/>
+   ...
+   <attribute value="key_n"/>
+ </key>
+\endcode
+
+The order of the attribute elements reflects the order of the key specifications in the declaration of the index.
+Also, the types of the values of the attributes are the types of the keys as they are declared.
+If a value attribute is not present, this means that the value of the corresponding key in the index is the empty sequence.
 
 \subsection index_maintenance Index Maintenance
 

=== modified file 'modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq'
--- modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq	2012-07-12 17:29:55 +0000
+++ modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq	2012-07-20 23:52:30 +0000
@@ -268,3 +268,27 @@
  :)
 declare updating function idml:refresh-index($name as xs:QName) external;
 
+(:~
+ : The keys function returns a sequence of all keys contained in the
+ : index with the given name. Each element has the following structure:
+ :   <pre class="brush: xml;">
+ :   &lt;key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml"&gt;
+ :     &lt;attribute value="key1_value"/&gt;
+ :     &lt;attribute value="key2_value"/&gt;
+ :     &lt;attribute value="key3_value"/&gt;
+ :   &lt;/key&gt;
+ :   </pre>
+ :
+ : @param $name The QName of the index
+ : @return The result of the function is sequence of elements each representing
+ :         one key contained in the index.
+ : 
+ : Note that the order of the attribute elements reflects the order of
+ : the keys in the index specification. Also note that the values in
+ : these attributes have the type that is declared in the corresponding
+ : index specification. 
+ :
+ : @error zerr:ZDDY0021 if the index with name $name is not declared.
+ : @error zerr:ZDDY0023 if the index with name $name does not exist.
+ :)
+declare function idml:keys($name as xs:QName) as node()* external;

=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml	2012-07-17 13:37:41 +0000
+++ src/diagnostics/diagnostic_en.xml	2012-07-20 23:52:30 +0000
@@ -2254,7 +2254,7 @@
     </diagnostic>
 
     <diagnostic code="ZDST0035" name="INDEX_GENERAL_MULTIKEY">
-      <value>"$1": index general multikey</value>
+      <value>"$1": number of key expressions for general indexes is restricted to one expression</value>
     </diagnostic>
 
     <diagnostic code="ZDST0036" name="INDEX_DECL_IN_FOREIGN_MODULE">

=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp	2012-07-17 13:37:41 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp	2012-07-20 23:52:30 +0000
@@ -380,7 +380,7 @@
   { "ZDST0032", "\"$1\": index references context item" },
   { "ZDST0033", "\"$1\": index non-simple expression" },
   { "ZDST0034", "\"$1\": index can not do automatic maintenance" },
-  { "ZDST0035", "\"$1\": index general multikey" },
+  { "ZDST0035", "\"$1\": number of key expressions for general indexes is restricted one expression" },
   { "ZDST0036", "\"$1\": index declaration in foreign module" },
   { "ZDST0041", "\"$1\": integrity constraint already declared" },
   { "ZDST0044", "\"$1\": integrity constraint declaration not allowed in main module" },

=== modified file 'src/functions/library.cpp'
--- src/functions/library.cpp	2012-07-12 17:29:55 +0000
+++ src/functions/library.cpp	2012-07-20 23:52:30 +0000
@@ -41,6 +41,7 @@
 #include "functions/func_fnput.h"
 #include "functions/func_hoist.h"
 #include "functions/func_index_ddl.h"
+#include "functions/func_index_func.h"
 #include "functions/func_ic_ddl.h"
 #include "functions/func_maths.h"
 #include "functions/func_nodes.h"
@@ -122,6 +123,7 @@
   populate_context_errors_and_diagnostics(sctx);
   populate_context_fnput(sctx);
   populate_context_index_ddl(sctx);
+  populate_context_index_func(sctx);
   populate_context_ic_ddl(sctx);
   populate_context_json(sctx);
   populate_context_maths(sctx);

=== added file 'src/functions/pregenerated/func_index_func.cpp'
--- src/functions/pregenerated/func_index_func.cpp	1970-01-01 00:00:00 +0000
+++ src/functions/pregenerated/func_index_func.cpp	2012-07-20 23:52:30 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+// ******************************************
+// *                                        *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME           *
+// *                                        *
+// ******************************************
+
+
+#include "stdafx.h"
+#include "runtime/indexing/index_func.h"
+#include "functions/func_index_func.h"
+
+
+namespace zorba{
+
+
+
+PlanIter_t zorba_store_indexes_static_dml_keys::codegen(
+  CompilerCB*,
+  static_context* sctx,
+  const QueryLoc& loc,
+  std::vector<PlanIter_t>& argv,
+  expr& ann) const
+{
+  return new IndexKeysIterator(sctx, loc, argv);
+}
+
+void populate_context_index_func(static_context* sctx)
+{
+
+
+      {
+    DECL_WITH_KIND(sctx, zorba_store_indexes_static_dml_keys,
+        (createQName("http://www.zorba-xquery.com/modules/store/static/indexes/dml","","keys";), 
+        GENV_TYPESYSTEM.QNAME_TYPE_ONE, 
+        GENV_TYPESYSTEM.ANY_NODE_TYPE_STAR),
+        FunctionConsts::ZORBA_STORE_INDEXES_STATIC_DML_KEYS_1);
+
+  }
+
+}
+
+
+}
+
+
+

=== added file 'src/functions/pregenerated/func_index_func.h'
--- src/functions/pregenerated/func_index_func.h	1970-01-01 00:00:00 +0000
+++ src/functions/pregenerated/func_index_func.h	2012-07-20 23:52:30 +0000
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+// ******************************************
+// *                                        *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME           *
+// *                                        *
+// ******************************************
+
+
+#ifndef ZORBA_FUNCTIONS_INDEX_FUNC_H
+#define ZORBA_FUNCTIONS_INDEX_FUNC_H
+
+
+#include "common/shared_types.h"
+#include "functions/function_impl.h"
+
+
+namespace zorba {
+
+
+void populate_context_index_func(static_context* sctx);
+
+
+
+
+//zorba-store-indexes-static-dml:keys
+class zorba_store_indexes_static_dml_keys : public function
+{
+public:
+  zorba_store_indexes_static_dml_keys(const signature& sig, FunctionConsts::FunctionKind kind)
+    : 
+    function(sig, kind)
+  {
+
+  }
+
+  bool accessesDynCtx() const { return true; }
+
+  CODEGEN_DECL();
+};
+
+
+} //namespace zorba
+
+
+#endif
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */ 

=== modified file 'src/functions/pregenerated/function_enum.h'
--- src/functions/pregenerated/function_enum.h	2012-07-12 17:29:55 +0000
+++ src/functions/pregenerated/function_enum.h	2012-07-20 23:52:30 +0000
@@ -197,6 +197,7 @@
   ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_ACTIVATE_1,
   ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DDL_DEACTIVATE_1,
   ZORBA_STORE_INTEGRITY_CONSTRAINTS_STATIC_DML_CHECK_INTEGRITY_CONSTRAINT_1,
+  ZORBA_STORE_INDEXES_STATIC_DML_KEYS_1,
   FN_ZORBA_INTROSPECT_SCTX_STATICALLY_KNOWN_NAMESPACES_0,
   FN_ZORBA_INTROSPECT_SCTX_DEFAULT_FUNCTION_NAMESPACE_0,
   FN_ZORBA_INTROSPECT_SCTX_BASE_URI_0,

=== added file 'src/runtime/indexing/index_func_impl.cpp'
--- src/runtime/indexing/index_func_impl.cpp	1970-01-01 00:00:00 +0000
+++ src/runtime/indexing/index_func_impl.cpp	2012-07-20 23:52:30 +0000
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "stdafx.h"
+
+#include "diagnostics/assert.h"
+#include "diagnostics/xquery_diagnostics.h"
+
+#include "zorbatypes/URI.h"
+
+#include "system/globalenv.h"
+
+#include "runtime/indexing/index_func.h"
+#include "runtime/indexing/index_util.h"
+
+#include "context/namespace_context.h"
+#include "context/static_context.h"
+
+#include "store/api/item.h"
+#include "store/api/index.h"
+
+#include "compiler/xqddf/value_index.h"
+
+namespace zorba {
+
+/*******************************************************************************
+********************************************************************************/
+bool
+IndexKeysIterator::nextImpl(
+    store::Item_t& result,
+    PlanState& aPlanState) const
+{
+  store::Item_t    lQName;
+  IndexDecl_t      indexDecl;
+  store::Index*    lIndex;
+  store::IndexKey  lKey;
+
+  store::Item_t lKeyNodeName;
+  GENV_ITEMFACTORY->createQName(lKeyNodeName,
+      static_context::ZORBA_STORE_DYNAMIC_UNORDERED_MAP_FN_NS,
+      "", "key");
+
+  IndexKeysIteratorState* state;
+  DEFAULT_STACK_INIT(IndexKeysIteratorState, state, aPlanState);
+
+  consumeNext(lQName, theChildren[0].getp(), aPlanState);
+
+  if ((indexDecl = theSctx->lookup_index(lQName)) == NULL)
+  {
+    throw XQUERY_EXCEPTION(
+      zerr::ZDDY0021_INDEX_NOT_DECLARED,
+      ERROR_PARAMS( lQName->getStringValue() ),
+      ERROR_LOC( loc )
+    );
+  }
+
+  lIndex = GENV_STORE.getIndex(lQName);
+
+  if (!lIndex)
+  {
+    throw XQUERY_EXCEPTION(
+      zerr::ZDDY0023_INDEX_DOES_NOT_EXIST,
+      ERROR_PARAMS( lQName->getStringValue() ),
+      ERROR_LOC( loc )
+    );
+  }
+
+  state->theIter = lIndex->keys();
+
+  state->theIter->open();
+
+  // generate result elements of the form
+  // <key>
+  //   <attribute value="key1_value"/>
+  //   <attribute value="key2_value"/>
+  //   <attribute value="key3_value"/>
+  // </key>
+  while (state->theIter->next(lKey))
+  {
+    std::cout << "hallo " << lIndex->getSpecification().theIsGeneral << std::endl;
+    IndexUtil::createIndexKeyElement(
+        lIndex->getSpecification().theIsGeneral,
+        result, lKey, static_context::ZORBA_STORE_STATIC_INDEXES_DML_FN_NS
+      );
+    STACK_PUSH(true, state);
+  }
+
+  STACK_END(state);
+}
+
+} // namespace zorba
+/* vim:set et sw=2 ts=2: */
+

=== added file 'src/runtime/indexing/index_util.h'
--- src/runtime/indexing/index_util.h	1970-01-01 00:00:00 +0000
+++ src/runtime/indexing/index_util.h	2012-07-20 23:52:30 +0000
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2006-2012 The FLWOR Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef ZORBA_INDEX_UTIL_H
+#define ZORBA_INDEX_UTIL_H
+
+#include "stdafx.h"
+
+#include "context/namespace_context.h"
+
+#include "store/api/pul.h"
+#include "store/api/store.h"
+#include "store/api/item.h"
+#include "store/api/item_factory.h"
+#include "store/api/iterator.h"
+#include "store/api/index.h"
+
+#include "types/typeimpl.h"
+#include "types/typeops.h"
+#include "types/casting.h"
+
+namespace zorba {
+
+class IndexUtil
+{
+public:
+  /*******************************************************************************
+    generate result elements of the form
+    <aBase:key>
+      <aBase:attribute aBase:value="key1_value"/>
+      <aBase:attribute aBase:value="key2_value"/>
+      <aBase:attribute aBase:value="key3_value"/>
+    </aBase:key>
+  ********************************************************************************/
+  static void
+  createIndexKeyElement(
+      bool aIsGeneralIndex,
+      store::Item_t& result,
+      store::IndexKey& aKey,
+      const zstring& aBase)
+  {
+    store::Item_t lKeyNodeName;
+    GENV_ITEMFACTORY->createQName(lKeyNodeName,
+        aBase, "", "key");
+
+    zstring lBase = aBase;
+  
+    store::Item_t lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
+  
+    const store::NsBindings lBindings;
+
+    GENV_ITEMFACTORY->createElementNode(
+        result, NULL, lKeyNodeName, lTypeName,
+        true, false, lBindings, lBase);
+  
+    for (store::ItemVector::iterator lIter = aKey.begin();
+         lIter != aKey.end();
+         ++lIter)
+    {
+      store::Item_t lAttrElem, lAttrNodeName;
+      store::Item_t lNameAttr, lValueAttr, lValueAttrName;
+      store::Item_t lTypeAttr, lTypeAttrName;
+  
+      GENV_ITEMFACTORY->createQName(lAttrNodeName,
+          lBase, "", "attribute");
+
+      lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
+      GENV_ITEMFACTORY->createElementNode(
+          lAttrElem, result, lAttrNodeName, lTypeName,
+          true, false, lBindings, lBase);
+  
+      if (*lIter != NULL)
+      {
+
+        if (aIsGeneralIndex)
+        {
+          // for general indices, the type of index key values
+          // is returned too
+          GENV_ITEMFACTORY->createQName(lTypeAttrName,
+               "", "", "type");
+
+          store::Item_t lType = (*lIter)->getType();
+          GENV_ITEMFACTORY->createAttributeNode(
+              lValueAttr, lAttrElem.getp(), lTypeAttrName,
+              lTypeName, lType);
+        }
+
+        GENV_ITEMFACTORY->createQName(lValueAttrName,
+             "", "", "value");
+  
+        lTypeName = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
+        GENV_ITEMFACTORY->createAttributeNode(
+            lValueAttr, lAttrElem.getp(), lValueAttrName, lTypeName, (*lIter));
+
+      }
+    }
+  }
+}; /* class IndexUtil */
+
+} // namespace zorba
+/* vim:set et sw=2 ts=2: */
+#endif

=== added file 'src/runtime/indexing/pregenerated/index_func.cpp'
--- src/runtime/indexing/pregenerated/index_func.cpp	1970-01-01 00:00:00 +0000
+++ src/runtime/indexing/pregenerated/index_func.cpp	2012-07-20 23:52:30 +0000
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+// ******************************************
+// *                                        *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME           *
+// *                                        *
+// ******************************************
+
+#include "stdafx.h"
+#include "zorbatypes/rchandle.h"
+#include "zorbatypes/zstring.h"
+#include "runtime/visitors/planiter_visitor.h"
+#include "runtime/indexing/index_func.h"
+#include "system/globalenv.h"
+
+
+#include "store/api/iterator.h"
+
+namespace zorba {
+
+// <IndexKeysIterator>
+SERIALIZABLE_CLASS_VERSIONS(IndexKeysIterator)
+
+void IndexKeysIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+  serialize_baseclass(ar,
+  (NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>*)this);
+
+    ar & theNSBindings;
+}
+
+
+void IndexKeysIterator::accept(PlanIterVisitor& v) const
+{
+  v.beginVisit(*this);
+
+  std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+  std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+  for ( ; lIter != lEnd; ++lIter ){
+    (*lIter)->accept(v);
+  }
+
+  v.endVisit(*this);
+}
+
+IndexKeysIterator::~IndexKeysIterator() {}
+
+IndexKeysIteratorState::IndexKeysIteratorState() {}
+
+IndexKeysIteratorState::~IndexKeysIteratorState() {}
+
+
+void IndexKeysIteratorState::init(PlanState& planState) {
+  PlanIteratorState::init(planState);
+}
+
+void IndexKeysIteratorState::reset(PlanState& planState) {
+  PlanIteratorState::reset(planState);
+}
+// </IndexKeysIterator>
+
+
+
+}
+
+

=== added file 'src/runtime/indexing/pregenerated/index_func.h'
--- src/runtime/indexing/pregenerated/index_func.h	1970-01-01 00:00:00 +0000
+++ src/runtime/indexing/pregenerated/index_func.h	2012-07-20 23:52:30 +0000
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2006-2008 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+// ******************************************
+// *                                        *
+// * THIS IS A GENERATED FILE. DO NOT EDIT! *
+// * SEE .xml FILE WITH SAME NAME           *
+// *                                        *
+// ******************************************
+#ifndef ZORBA_RUNTIME_INDEXING_INDEX_FUNC_H
+#define ZORBA_RUNTIME_INDEXING_INDEX_FUNC_H
+
+
+#include "common/shared_types.h"
+
+
+
+#include "runtime/base/narybase.h"
+#include "store/api/index.h"
+
+
+namespace zorba {
+
+/**
+ * 
+ *      keys($iindexName as xs:QName) as ()
+ *    
+ * Author: Zorba Team
+ */
+class IndexKeysIteratorState : public PlanIteratorState
+{
+public:
+  store::Index::KeyIterator_t theIter; //
+
+  IndexKeysIteratorState();
+
+  ~IndexKeysIteratorState();
+
+  void init(PlanState&);
+  void reset(PlanState&);
+};
+
+class IndexKeysIterator : public NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>
+{ 
+protected:
+  store::NsBindings theNSBindings; //
+public:
+  SERIALIZABLE_CLASS(IndexKeysIterator);
+
+  SERIALIZABLE_CLASS_CONSTRUCTOR2T(IndexKeysIterator,
+    NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>);
+
+  void serialize( ::zorba::serialization::Archiver& ar);
+
+  IndexKeysIterator(
+    static_context* sctx,
+    const QueryLoc& loc,
+    std::vector<PlanIter_t>& children)
+    : 
+    NaryBaseIterator<IndexKeysIterator, IndexKeysIteratorState>(sctx, loc, children),
+    theNSBindings()
+  {}
+
+  virtual ~IndexKeysIterator();
+
+  void accept(PlanIterVisitor& v) const;
+
+  bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+}
+#endif
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */ 

=== modified file 'src/runtime/pregenerated/iterator_enum.h'
--- src/runtime/pregenerated/iterator_enum.h	2012-07-11 15:38:39 +0000
+++ src/runtime/pregenerated/iterator_enum.h	2012-07-20 23:52:30 +0000
@@ -123,6 +123,7 @@
   TYPE_ActivateICIterator,
   TYPE_DeactivateICIterator,
   TYPE_CheckICIterator,
+  TYPE_IndexKeysIterator,
   TYPE_StaticNamespacesIterator,
   TYPE_DefaultFunctionNamespaceIterator,
   TYPE_SctxBaseUriIterator,

=== added file 'src/runtime/spec/indexing/index_func.xml'
--- src/runtime/spec/indexing/index_func.xml	1970-01-01 00:00:00 +0000
+++ src/runtime/spec/indexing/index_func.xml	2012-07-20 23:52:30 +0000
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+////////////////////////////////////////////////////////////////////////////////
+//                                                                            //
+//                                                                            //
+////////////////////////////////////////////////////////////////////////////////
+-->
+<zorba:iterators
+  xmlns:zorba="http://www.zorba-xquery.com";
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
+
+<zorba:source>
+  <zorba:include  form="Quoted">store/api/iterator.h</zorba:include>
+</zorba:source>
+
+<zorba:header>
+    <zorba:include  form="Quoted">store/api/index.h</zorba:include>
+</zorba:header>
+
+<!--
+/*******************************************************************************
+*******************************************************************************/
+-->
+<zorba:iterator name="IndexKeysIterator" arity="nary">
+
+    <zorba:description author="Zorba Team">
+      keys($iindexName as xs:QName) as ()
+    </zorba:description>
+
+    <zorba:function>
+
+      <zorba:signature localname="keys" 
+        prefix="zorba-store-indexes-static-dml">
+        <zorba:param>xs:QName</zorba:param>
+        <zorba:output>node()*</zorba:output>
+      </zorba:signature>
+    
+      <zorba:methods>
+        <zorba:accessesDynCtx returnValue="true"/>
+      </zorba:methods>
+
+    </zorba:function>
+
+    <zorba:state>
+      <zorba:member type="store::Index::KeyIterator_t" name="theIter"/>
+    </zorba:state>
+
+    <zorba:member type="store::NsBindings" name="theNSBindings" brief=""/>
+
+</zorba:iterator>
+
+</zorba:iterators>
+

=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
--- src/runtime/visitors/pregenerated/planiter_visitor.h	2012-07-12 17:29:55 +0000
+++ src/runtime/visitors/pregenerated/planiter_visitor.h	2012-07-20 23:52:30 +0000
@@ -252,6 +252,8 @@
 
     class CheckICIterator;
 
+    class IndexKeysIterator;
+
     class StaticNamespacesIterator;
 
     class DefaultFunctionNamespaceIterator;
@@ -1047,6 +1049,9 @@
     virtual void beginVisit ( const CheckICIterator& ) = 0;
     virtual void endVisit   ( const CheckICIterator& ) = 0;
 
+    virtual void beginVisit ( const IndexKeysIterator& ) = 0;
+    virtual void endVisit   ( const IndexKeysIterator& ) = 0;
+
     virtual void beginVisit ( const StaticNamespacesIterator& ) = 0;
     virtual void endVisit   ( const StaticNamespacesIterator& ) = 0;
 

=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
--- src/runtime/visitors/pregenerated/printer_visitor.cpp	2012-07-12 17:29:55 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.cpp	2012-07-20 23:52:30 +0000
@@ -50,6 +50,7 @@
 #include "runtime/full_text/ft_module.h"
 #include "runtime/function_item/function_item_iter.h"
 #include "runtime/indexing/ic_ddl.h"
+#include "runtime/indexing/index_func.h"
 #include "runtime/introspection/sctx.h"
 #include "runtime/json/json.h"
 #include "runtime/json/jsoniq_functions.h"
@@ -1571,6 +1572,20 @@
 // </CheckICIterator>
 
 
+// <IndexKeysIterator>
+void PrinterVisitor::beginVisit ( const IndexKeysIterator& a) {
+  thePrinter.startBeginVisit("IndexKeysIterator", ++theId);
+  printCommons( &a, theId );
+  thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const IndexKeysIterator& ) {
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+// </IndexKeysIterator>
+
+
 // <StaticNamespacesIterator>
 void PrinterVisitor::beginVisit ( const StaticNamespacesIterator& a) {
   thePrinter.startBeginVisit("StaticNamespacesIterator", ++theId);

=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
--- src/runtime/visitors/pregenerated/printer_visitor.h	2012-07-12 17:29:55 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.h	2012-07-20 23:52:30 +0000
@@ -388,6 +388,9 @@
     void beginVisit( const CheckICIterator& );
     void endVisit  ( const CheckICIterator& );
 
+    void beginVisit( const IndexKeysIterator& );
+    void endVisit  ( const IndexKeysIterator& );
+
     void beginVisit( const StaticNamespacesIterator& );
     void endVisit  ( const StaticNamespacesIterator& );
 

=== modified file 'src/store/naive/simple_index_general.cpp'
--- src/store/naive/simple_index_general.cpp	2012-07-12 17:29:55 +0000
+++ src/store/naive/simple_index_general.cpp	2012-07-20 23:52:30 +0000
@@ -1151,8 +1151,7 @@
 *******************************************************************************/
 store::Index::KeyIterator_t GeneralHashIndex::keys() const
 {
-  assert(false);
-  return 0;
+  return new KeyIterator(theMaps);
 }
 
 
@@ -1255,6 +1254,14 @@
 //                                                                             //
 /////////////////////////////////////////////////////////////////////////////////
 
+/*******************************************************************************
+
+********************************************************************************/
+GeneralHashIndex::KeyIterator::KeyIterator(IndexMap* const* aMaps)
+  :
+  theMaps(aMaps)
+{
+}
 
 /******************************************************************************
 
@@ -1263,23 +1270,60 @@
 {
 }
 
+/******************************************************************************
+ * moves theIterator to the next available iterator from theMaps
+*******************************************************************************/
+void GeneralHashIndex::KeyIterator::setNextIter()
+{
+  for ( ;
+    theCurType < store::XS_LAST && theMaps[theCurType] == 0; 
+    ++theCurType)
+  {}
+
+  if (theCurType != store::XS_LAST)
+    theIterator = theMaps[theCurType]->begin();
+}
 
 /******************************************************************************
 
 *******************************************************************************/
 void GeneralHashIndex::KeyIterator::open()
 {
-  assert(false);
+  // start with first type from zorba::store::SchemaTypeCode enum
+  theCurType = 0;
+  // Index doesn't contain keys from all atomic types -> we need to skip the
+  // empty ones.
+  setNextIter();
 }
 
 
 /******************************************************************************
 
 *******************************************************************************/
-bool GeneralHashIndex::KeyIterator::next(store::IndexKey&)
+bool GeneralHashIndex::KeyIterator::next(store::IndexKey& aKey)
 {
-  assert(false);
-  return false;
+  // XS_LAST marks the end of the type list -> we stop
+  if (theCurType == store::XS_LAST)
+    return false;
+
+  const store::Item* lKeyItem = (*theIterator).first;
+  // the general index doesn't return an IndexKey object because
+  // it doesn't support multi-value keys -> we push the key directly
+  // into the passed IndexKey.
+  aKey.empty();
+  aKey.push_back(const_cast<zorba::store::Item*>(lKeyItem));
+
+  ++theIterator;
+
+  if (theIterator == theMaps[theCurType]->end())
+  {
+    // iteration of the keys of the current type is done.
+    // increase type and search for the next valid iterator.
+    ++theCurType;
+    setNextIter();
+  }
+
+  return true;
 }
 
 
@@ -1288,7 +1332,7 @@
 *******************************************************************************/
 void GeneralHashIndex::KeyIterator::close()
 {
-  assert(false);
+  theCurType = store::XS_LAST;
 }
 
 

=== modified file 'src/store/naive/simple_index_general.h'
--- src/store/naive/simple_index_general.h	2012-07-12 17:29:55 +0000
+++ src/store/naive/simple_index_general.h	2012-07-20 23:52:30 +0000
@@ -220,14 +220,25 @@
 
   typedef IndexMap::iterator EntryIterator;
 
+  /*
+   * This iterator iterates over all index keys from all types
+   */
   class KeyIterator : public Index::KeyIterator
   {
+  protected:
+    IndexMap::iterator     theIterator;
+    IndexMap* const*       theMaps;
+    ulong                  theCurType;
   public:
+    KeyIterator(IndexMap* const* aMaps);
     ~KeyIterator();
 
     void open();
     bool next(store::IndexKey&);
     void close();
+
+  private:
+    void setNextIter();
   };
 
   typedef rchandle<KeyIterator> KeyIterator_t;

=== modified file 'src/store/naive/simple_index_value.cpp'
--- src/store/naive/simple_index_value.cpp	2012-07-12 17:29:55 +0000
+++ src/store/naive/simple_index_value.cpp	2012-07-20 23:52:30 +0000
@@ -563,6 +563,13 @@
 /******************************************************************************
 
 ********************************************************************************/
+ValueTreeIndex::KeyIterator::KeyIterator(const IndexMap& aMap)
+  :
+  theMap(aMap)
+{
+}
+
+
 ValueTreeIndex::KeyIterator::~KeyIterator()
 {
 };
@@ -570,21 +577,29 @@
 
 void ValueTreeIndex::KeyIterator::open()
 {
-  assert(false);
+  theIterator = theMap.begin();
 }
 
 
-bool ValueTreeIndex::KeyIterator::next(store::IndexKey&)
+bool ValueTreeIndex::KeyIterator::next(store::IndexKey& aKey)
 {
-  assert(false);
+  if (theIterator != theMap.end())
+  {
+    const store::IndexKey* lKey = (*theIterator).first;
+    aKey = *lKey;
+
+    ++theIterator;
+    return true;
+  }
   return false;
 }
 
 
 void ValueTreeIndex::KeyIterator::close()
 {
-  assert(false);
-}
+  theIterator = theMap.end();
+};
+
 
 
 /******************************************************************************
@@ -652,8 +667,7 @@
 ********************************************************************************/
 store::Index::KeyIterator_t ValueTreeIndex::keys() const
 {
-  assert(false);
-  return 0;
+  return new KeyIterator(theMap);
 }
 
 

=== modified file 'src/store/naive/simple_index_value.h'
--- src/store/naive/simple_index_value.h	2012-07-12 17:29:55 +0000
+++ src/store/naive/simple_index_value.h	2012-07-20 23:52:30 +0000
@@ -208,7 +208,12 @@
 
   class KeyIterator : public Index::KeyIterator
   {
+  protected:
+    IndexMap::const_iterator   theIterator;
+    const IndexMap           & theMap;
+
   public:
+    KeyIterator(const IndexMap& aMap);
     ~KeyIterator();
 
     void open();

=== added file 'test/rbkt/ExpQueryResults/zorba/index/keys1.xml.res'
--- test/rbkt/ExpQueryResults/zorba/index/keys1.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/index/keys1.xml.res	2012-07-20 23:52:30 +0000
@@ -0,0 +1,1 @@
+<keys typeIsInteger="true"><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="10"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="5"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="6"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="1"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="7"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="2"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="8"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="3"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="9"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="4"/></key></keys>

=== added file 'test/rbkt/ExpQueryResults/zorba/index/keys1g.xml.res'
--- test/rbkt/ExpQueryResults/zorba/index/keys1g.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/index/keys1g.xml.res	2012-07-20 23:52:30 +0000
@@ -0,0 +1,32 @@
+<keys>
+  <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";>
+    <attribute type="xs:string" value="2"></attribute>
+  </key>
+  <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";>
+    <attribute type="xs:string" value="6"></attribute>
+  </key>
+  <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";>
+    <attribute type="xs:string" value="4"></attribute>
+  </key>
+  <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";>
+    <attribute type="xs:string" value="10"></attribute>
+  </key>
+  <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";>
+    <attribute type="xs:string" value="8"></attribute>
+  </key>
+  <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";>
+    <attribute type="xs:long" value="0"></attribute>
+  </key>
+  <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";>
+    <attribute type="xs:long" value="6"></attribute>
+  </key>
+  <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";>
+    <attribute type="xs:long" value="2"></attribute>
+  </key>
+  <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";>
+    <attribute type="xs:long" value="8"></attribute>
+  </key>
+  <key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";>
+    <attribute type="xs:long" value="4"></attribute>
+  </key>
+</keys>

=== added file 'test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res'
--- test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/index/keys2.xml.res	2012-07-20 23:52:30 +0000
@@ -0,0 +1,1 @@
+<keys><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="1"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="2"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="3"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="4"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="5"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="6"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="7"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="8"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="9"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="10"/></key></keys>

=== added file 'test/rbkt/ExpQueryResults/zorba/index/keys3.xml.res'
--- test/rbkt/ExpQueryResults/zorba/index/keys3.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/index/keys3.xml.res	2012-07-20 23:52:30 +0000
@@ -0,0 +1,1 @@
+<keys><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="1"/><attribute/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="10"/><attribute value="me"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="2"/><attribute/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="3"/><attribute/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="4"/><attribute/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="5"/><attribute value="me"/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="6"/><attribute/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="7"/><attribute/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="8"/><attribute/></key><key xmlns="http://www.zorba-xquery.com/modules/store/static/indexes/dml";><attribute value="9"/><attribute/></key></keys>

=== added file 'test/rbkt/Queries/zorba/index/keys1.xq'
--- test/rbkt/Queries/zorba/index/keys1.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/keys1.xq	2012-07-20 23:52:30 +0000
@@ -0,0 +1,22 @@
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";;
+import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl";;
+import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml";;
+
+import module namespace keys-lib = "http://www.example.com/"; at "keys_mod.xqlib";
+
+ddl:create(xs:QName("keys-lib:foo"));
+index_ddl:create(xs:QName("keys-lib:FooIdx"));
+
+for $i in 1 to 10
+return
+  dml:insert-nodes(xs:QName("keys-lib:foo"),
+    <foo id="{$i}"/>
+  );
+
+let $keys := index_dml:keys(xs:QName("keys-lib:FooIdx"))
+let $attr := $keys[1]/self::*:key/*:attribute/@*:value
+return
+  <keys typeIsInteger="{data($attr) instance of xs:integer}">{
+    $keys
+  }</keys>

=== added file 'test/rbkt/Queries/zorba/index/keys1g.xq'
--- test/rbkt/Queries/zorba/index/keys1g.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/keys1g.xq	2012-07-20 23:52:30 +0000
@@ -0,0 +1,26 @@
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";;
+import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl";;
+import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml";;
+
+import module namespace keys-lib = "http://www.example.com/"; at "keys_mod.xqlib";
+
+ddl:create(xs:QName("keys-lib:foo"));
+index_ddl:create(xs:QName("keys-lib:FooIdx-general"));
+
+for $i in 1 to 10
+return
+  dml:insert-nodes(xs:QName("keys-lib:foo"),
+    if ($i mod 2 = 0) then
+      <foo id="{$i}"/>
+    else
+      <foo id="{$i - 1}" string="true"/>
+  );
+
+let $keys := index_dml:keys(xs:QName("keys-lib:FooIdx-general"))
+let $attr := $keys[1]/self::*:key/*:attribute/@*:value
+return
+  <keys>{
+    $keys
+  }</keys>
+

=== added file 'test/rbkt/Queries/zorba/index/keys2.xq'
--- test/rbkt/Queries/zorba/index/keys2.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/keys2.xq	2012-07-20 23:52:30 +0000
@@ -0,0 +1,22 @@
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";;
+import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl";;
+import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml";;
+
+import module namespace keys-lib = "http://www.example.com/"; at "keys_mod.xqlib";
+
+ddl:create(xs:QName("keys-lib:foo"));
+index_ddl:create(xs:QName("keys-lib:FooIdx2"));
+
+for $i in 1 to 10
+return
+  dml:insert-nodes(xs:QName("keys-lib:foo"),
+    <foo id="{$i}"/>
+  );
+
+let $keys := index_dml:keys(xs:QName("keys-lib:FooIdx2"))
+return
+  <keys>{
+    $keys
+  }</keys>
+

=== added file 'test/rbkt/Queries/zorba/index/keys3.xq'
--- test/rbkt/Queries/zorba/index/keys3.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/keys3.xq	2012-07-20 23:52:30 +0000
@@ -0,0 +1,21 @@
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";;
+import module namespace index_ddl = "http://www.zorba-xquery.com/modules/store/static/indexes/ddl";;
+import module namespace index_dml = "http://www.zorba-xquery.com/modules/store/static/indexes/dml";;
+
+import module namespace keys-lib = "http://www.example.com/"; at "keys_mod.xqlib";
+
+ddl:create(xs:QName("keys-lib:foo"));
+index_ddl:create(xs:QName("keys-lib:FooIdx3"));
+
+for $i in 1 to 10
+return
+  dml:insert-nodes(xs:QName("keys-lib:foo"),
+    if ($i mod 5 eq 0) then <foo id="{$i}" name="me"/> else <foo id="{$i}"/>
+  );
+
+let $keys := index_dml:keys(xs:QName("keys-lib:FooIdx3"))
+return
+  <keys>{
+    $keys
+  }</keys>

=== added file 'test/rbkt/Queries/zorba/index/keys_mod.xqlib'
--- test/rbkt/Queries/zorba/index/keys_mod.xqlib	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/index/keys_mod.xqlib	2012-07-20 23:52:30 +0000
@@ -0,0 +1,40 @@
+module namespace keys-lib = "http://www.example.com/";;
+
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";;
+
+declare namespace ann = "http://www.zorba-xquery.com/annotations";;
+
+declare %ann:unordered collection keys-lib:foo as node()*;
+
+declare %ann:automatic %ann:value-equality index keys-lib:FooIdx
+  on nodes dml:collection(xs:QName("keys-lib:foo"))
+  by xs:integer(./@id) as xs:integer;
+
+declare %ann:automatic %ann:value-range index keys-lib:FooIdx2
+  on nodes dml:collection(xs:QName("keys-lib:foo"))
+  by xs:integer(./@id) as xs:integer;
+
+declare %ann:automatic %ann:value-range index keys-lib:FooIdx3
+  on nodes dml:collection(xs:QName("keys-lib:foo"))
+  by xs:string(./@id) as xs:string, (if (./@name) then xs:string(./@name) else ()) as xs:string?;
+
+declare %ann:automatic %ann:general-equality index keys-lib:FooIdx-general
+  on nodes dml:collection(xs:QName("keys-lib:foo"))
+  by 
+  (
+    let $val := fn:data(./@id)
+    return
+      if (./@string) then
+        xs:long($val)
+      else
+        xs:string($val)
+  )
+  as xs:anyAtomicType;
+
+declare %ann:automatic %ann:general-range index keys-lib:FooIdx2-general
+  on nodes dml:collection(xs:QName("keys-lib:foo"))
+  by xs:integer(./@id) as xs:integer;
+
+declare %ann:automatic %ann:general-range index keys-lib:FooIdx3-general
+  on nodes dml:collection(xs:QName("keys-lib:foo"))
+  by (if (./@name) then xs:string(./@name) else ()) as xs:string?;

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to