← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/dataguide into lp:zorba

 

Nicolae Brinza has proposed merging lp:~zorba-coders/zorba/dataguide into lp:zorba.

Commit message:
Dataguide implementation.

Requested reviews:
  Nicolae Brinza (nbrinza)

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

Dataguide implementation.
-- 
https://code.launchpad.net/~zorba-coders/zorba/dataguide/+merge/173026
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/annotations/annotations.cpp'
--- src/annotations/annotations.cpp	2013-04-29 01:51:11 +0000
+++ src/annotations/annotations.cpp	2013-07-04 13:34:33 +0000
@@ -133,6 +133,8 @@
   ZANN(read-only-nodes, read_only_nodes);
   ZANN(mutable-nodes, mutable_nodes);
 
+  ZANN(explores-json, explores_json);
+
 #undef ZANN
 
   // create a set of rules to detect conflicts between annotations
@@ -395,6 +397,13 @@
 }
 
 
+void AnnotationList::push_back(
+    AnnotationInternal::AnnotationId id)
+{
+  theAnnotationList.push_back(new AnnotationInternal(AnnotationInternal::lookup(id)));
+}
+
+
 /*******************************************************************************
   Called from translator to detect duplicates and conflicting declarations
 ********************************************************************************/

=== modified file 'src/annotations/annotations.h'
--- src/annotations/annotations.h	2013-04-29 00:41:13 +0000
+++ src/annotations/annotations.h	2013-07-04 13:34:33 +0000
@@ -89,7 +89,8 @@
     zann_ordered,
     zann_unordered,
     zann_read_only_nodes,
-    zann_mutable_nodes,
+    zann_mutable_nodes,    
+    zann_explores_json,
 
     // must be at the end
     zann_end
@@ -193,6 +194,8 @@
   void push_back(
       const store::Item_t& qname,
       const std::vector<const_expr*>& literals);
+  
+  void push_back(AnnotationInternal::AnnotationId id);
 
   void checkConflictingDeclarations(DeclarationKind k, const QueryLoc& loc) const;
 };

=== modified file 'src/common/shared_types.h'
--- src/common/shared_types.h	2013-06-26 13:56:00 +0000
+++ src/common/shared_types.h	2013-07-04 13:34:33 +0000
@@ -108,6 +108,9 @@
 
 typedef rchandle<CompilerCB> CompilerCB_t;
 
+// JSON dataguide
+class dataguide_cb;
+typedef rchandle<dataguide_cb> dataguide_cb_t;  
 
 /* datetime stuff */
 class DateTime;

=== modified file 'src/compiler/codegen/plan_visitor.cpp'
--- src/compiler/codegen/plan_visitor.cpp	2013-06-15 02:57:08 +0000
+++ src/compiler/codegen/plan_visitor.cpp	2013-07-04 13:34:33 +0000
@@ -49,6 +49,8 @@
 #include "compiler/expression/function_item_expr.h"
 #include "compiler/expression/path_expr.h"
 #include "compiler/expression/var_expr.h"
+#include "compiler/expression/json_dataguide.h"
+
 #include "compiler/parser/parse_constants.h"
 
 #include "context/namespace_context.h"
@@ -98,6 +100,9 @@
 #include "runtime/hof/dynamic_fncall_iterator.h"
 #include "runtime/misc/materialize.h"
 
+#include "runtime/collections/collections.h"
+#include "runtime/json/jsoniq_functions.h"
+
 #ifdef ZORBA_WITH_DEBUGGER
 #include "debugger/debugger_commons.h"
 #endif
@@ -2456,7 +2461,7 @@
   if (is_enclosed_expr(&v))
     theConstructorsStack.push(&v);
 
-	return true;
+  return true;
 }
 
 
@@ -2514,6 +2519,16 @@
       user_function* udf = static_cast<user_function*>(func);
       udf->computeResultCaching(theCCB->theXQueryDiagnostics);
     }
+    else if (dataguide_cb::func_uses_dataguide(func->getKind()) && v.get_dataguide() != NULL)
+    {      
+      ZorbaCollectionIterator* collIter;      
+      if ((collIter = dynamic_cast<ZorbaCollectionIterator*>(iter.getp())))
+        collIter->setDataguide(v.get_dataguide()->get_as_json(&v));  
+      
+      JSONParseIterator* parseIter;
+      if ((parseIter = dynamic_cast<JSONParseIterator*>(iter.getp())))
+        parseIter->setDataguide(v.get_dataguide()->get_as_json(&v));
+    }
   }
   else
   {

=== modified file 'src/compiler/expression/CMakeLists.txt'
--- src/compiler/expression/CMakeLists.txt	2013-02-07 17:24:36 +0000
+++ src/compiler/expression/CMakeLists.txt	2013-07-04 13:34:33 +0000
@@ -30,7 +30,8 @@
     function_item_expr.cpp
     pragma.cpp
     mem_manager.cpp
-    expr_manager.cpp)
+    expr_manager.cpp
+    json_dataguide.cpp)
 
 IF (NOT ZORBA_NO_FULL_TEXT)
   LIST(APPEND EXPRESSION_SRCS

=== modified file 'src/compiler/expression/expr_base.cpp'
--- src/compiler/expression/expr_base.cpp	2013-05-29 04:17:01 +0000
+++ src/compiler/expression/expr_base.cpp	2013-07-04 13:34:33 +0000
@@ -26,6 +26,8 @@
 #include "compiler/expression/expr_visitor.h"
 #include "compiler/expression/expr_manager.h"
 
+#include "compiler/expression/json_dataguide.h"
+
 #include "compiler/api/compilercb.h"
 
 #include "functions/function.h"
@@ -1418,6 +1420,29 @@
 }
 
 
+/*******************************************************************************
+
+********************************************************************************/
+dataguide_cb* expr::get_dataguide()
+{ 
+  return theJsonDataguide; 
+}
+
+
+dataguide_cb* expr::get_dataguide_or_new()
+{
+  if (!theJsonDataguide.getp()) 
+    theJsonDataguide = new dataguide_cb();
+  return theJsonDataguide; 
+}
+
+
+dataguide_cb* expr::set_dataguide(dataguide_cb* a_json_dataguide)
+{ 
+  theJsonDataguide = a_json_dataguide; 
+  return theJsonDataguide; 
+}
+
 
 /*******************************************************************************
 
@@ -1440,6 +1465,90 @@
   return cloneExpr->get_return_type();
 }
 
+/*******************************************************************************
+
+********************************************************************************/
+std::string expr::get_expr_kind_string() const
+{
+  const char* result;
+  
+  switch (get_expr_kind())
+  {
+  case const_expr_kind: result = "const_expr"; break;
+
+  case var_expr_kind: result = "var_expr"; break;
+
+  case doc_expr_kind: result = "doc_expr"; break;
+  case elem_expr_kind: result = "elem_expr"; break;
+  case attr_expr_kind: result = "attr_expr"; break;
+  case namespace_expr_kind: result = "namespace_expr"; break;
+  case text_expr_kind: result = "text_expr"; break;
+  case pi_expr_kind: result = "pi_expr"; break;
+
+  case relpath_expr_kind: result = "relpath_expr"; break;
+  case axis_step_expr_kind: result = "axis_step_expr"; break;
+  case match_expr_kind: result = "match_expr"; break;
+
+  case flwor_expr_kind: result = "flwor_expr"; break;
+  case if_expr_kind: result = "if_expr"; break;
+  case trycatch_expr_kind: result = "trycatch_expr"; break;
+
+  case fo_expr_kind: result = "fo_expr_expr"; break;
+  case dynamic_function_invocation_expr_kind: result = "dynamic_function_invocation_expr"; break;
+  case argument_placeholder_expr_kind: result = "argument_placeholder_expr"; break;
+  case function_item_expr_kind: result = "function_item_expr"; break;
+
+  case castable_expr_kind: result = "castable_expr"; break;
+  case cast_expr_kind: result = "cast_expr"; break;
+  case instanceof_expr_kind: result = "instanceof_expr"; break;
+  case treat_expr_kind: result = "treat_expr"; break;
+  case promote_expr_kind: result = "promote_expr"; break;
+  case name_cast_expr_kind: result = "name_cast_expr"; break;
+
+  case validate_expr_kind: result = "validate_expr"; break;
+
+  case extension_expr_kind: result = "extension_expr"; break;
+
+  case order_expr_kind: result = "order_expr"; break;
+
+#ifndef ZORBA_NO_FULL_TEXT
+  case ft_expr_kind: result = "ft_expr"; break;
+#endif /* ZORBA_NO_FULL_TEXT */
+
+  case delete_expr_kind: result = "delete_expr"; break;
+  case insert_expr_kind: result = "insert_expr"; break;
+  case rename_expr_kind: result = "rename_expr"; break;
+  case replace_expr_kind: result = "replace_expr"; break;
+  case transform_expr_kind: result = "transform_expr"; break;
+
+  case block_expr_kind: result = "block_expr"; break;
+  case var_decl_expr_kind: result = "var_decl_expr"; break;
+  case var_set_expr_kind: result = "var_set_expr"; break;
+  case apply_expr_kind: result = "apply_expr"; break;
+  case exit_expr_kind: result = "exit_expr"; break;
+  case exit_catcher_expr_kind: result = "exit_catcher_expr"; break;
+  case flowctl_expr_kind: result = "flowctl_expr"; break;
+  case while_expr_kind: result = "while_expr"; break;
+
+  case eval_expr_kind: result = "eval_expr"; break;
+  case debugger_expr_kind: result = "debugger_expr"; break;
+  case wrapper_expr_kind: result = "wrapper_expr"; break;
+  case function_trace_expr_kind: result = "function_trace_expr_expr"; break;
+
+  case json_direct_object_expr_kind: result = "json_direct_object_expr"; break;
+  case json_object_expr_kind: result = "json_object_expr"; break;
+  case json_array_expr_kind: result = "json_array_expr"; break;
+
+  case unknown_expr_kind: result = "unknown_expr"; break;
+    
+  default:
+    result = "expr kind not in list. Add it to expr_base::get_expr_kind_string()";  
+    break;
+  }
+  
+  return std::string(result);
+}
+
 
 } // namespace zorba
 /* vim:set et sw=2 ts=2: */

=== modified file 'src/compiler/expression/expr_base.h'
--- src/compiler/expression/expr_base.h	2013-05-29 04:17:01 +0000
+++ src/compiler/expression/expr_base.h	2013-07-04 13:34:33 +0000
@@ -45,6 +45,7 @@
 
 class CompilerCB;
 
+
 enum expr_kind_t
 {
   const_expr_kind,
@@ -198,6 +199,8 @@
   uint8_t            theVisitId;
 
   FreeVars           theFreeVars;
+  
+  dataguide_cb_t     theJsonDataguide;
 
 public:
   static bool is_sequential(unsigned short theScriptingKind);
@@ -223,6 +226,8 @@
   user_function* get_udf() const { return theUDF; }
 
   expr_kind_t get_expr_kind() const { return static_cast<expr_kind_t>(theKind); }
+  
+  std::string get_expr_kind_string() const;
 
   const QueryLoc& get_loc() const { return theLoc; }
 
@@ -404,6 +409,13 @@
   void clear_annotations();
 
   xqtref_t get_return_type_with_empty_input(const expr* input) const;
+  
+  dataguide_cb* get_dataguide(); 
+  
+  // If the object's dataguide is NULL, will create a new one and return it
+  dataguide_cb* get_dataguide_or_new();
+  
+  dataguide_cb* set_dataguide(dataguide_cb* a_json_dataguide); 
 
 protected:
   virtual void compute_scripting_kind() = 0;

=== modified file 'src/compiler/expression/expr_clone.cpp'
--- src/compiler/expression/expr_clone.cpp	2013-06-15 02:57:08 +0000
+++ src/compiler/expression/expr_clone.cpp	2013-07-04 13:34:33 +0000
@@ -27,6 +27,7 @@
 #include "compiler/expression/ft_expr.h"
 #include "compiler/expression/ftnode.h"
 #include "compiler/expression/expr_manager.h"
+#include "compiler/expression/json_dataguide.h"
 
 #include "compiler/api/compilercb.h"
 
@@ -337,6 +338,8 @@
       cloneExpr->theArgs.push_back(e->theArgs[i]->clone(udf, subst));
 
     cloneExpr->theScriptingKind  = e->theScriptingKind;
+    
+    cloneExpr->theJsonDataguide = e->theJsonDataguide;
 
     newExpr = cloneExpr;
     break;

=== modified file 'src/compiler/expression/expr_put.cpp'
--- src/compiler/expression/expr_put.cpp	2013-06-15 02:57:08 +0000
+++ src/compiler/expression/expr_put.cpp	2013-07-04 13:34:33 +0000
@@ -41,6 +41,8 @@
 #include "compiler/expression/flwor_expr.h"
 #include "compiler/expression/function_item_expr.h"
 #include "compiler/expression/pragma.h"
+#include "compiler/expression/json_dataguide.h"
+
 #include "compiler/parser/parse_constants.h"
 
 #include "diagnostics/assert.h"
@@ -56,18 +58,30 @@
 
 #define BEGIN_PUT(LABEL)                          \
   os << indent << #LABEL << expr_addr(this)       \
+  << " dg: " << (theJsonDataguide.getp() ? theJsonDataguide->toString() : "NULL") \
+  << " [\n" << inc_indent
+
+#define BEGIN_PUT_NO_DG(LABEL)                    \
+  os << indent << #LABEL << expr_addr(this)       \
   << " [\n" << inc_indent
 
 #define BEGIN_PUT_NL(LABEL)                       \
   os << indent << #LABEL << expr_addr(this)       \
+  << " dg: " << (theJsonDataguide.getp() ? theJsonDataguide->toString() : "NULL") \
   << std::endl << indent << "[\n" << inc_indent
 
+#define BEGIN_PUT_NL_NO_DG(LABEL)                       \
+  os << indent << #LABEL << expr_addr(this)       \
+  << std::endl << indent << "[\n" << inc_indent
+  
 #define BEGIN_PUT_MSG(MSG)                        \
   os << indent << MSG << expr_addr(this)          \
+  << " dg: " << (theJsonDataguide.getp() ? theJsonDataguide->toString() : "NULL") \
   << " [\n" << inc_indent
 
 #define BEGIN_PUT_NO_EOL(LABEL)                   \
   os << indent << #LABEL << expr_addr(this)       \
+  << " dg: " << (theJsonDataguide.getp() ? theJsonDataguide->toString() : "NULL") \
   << " [ "
 
 #define END_PUT() \
@@ -227,6 +241,8 @@
 
     os << expr_addr(theVarExpr);
   }
+  
+  os << " dg: " << (theVarExpr->get_dataguide() ? theVarExpr->get_dataguide()->toString() : "NULL");
 
   os << endl << indent << "[\n" << inc_indent;
     
@@ -238,7 +254,7 @@
 
 ostream& window_clause::put(ostream& os) const
 {
-  BEGIN_PUT_NL(WINDOW);
+  BEGIN_PUT_NL_NO_DG(WINDOW);
   theVarExpr->put(os);
   PUT_SUB("IN", theDomainExpr);
   PUT_SUB("START", theWinStartCond);
@@ -249,7 +265,7 @@
 
 ostream& flwor_wincond::vars::put(ostream& os) const
 {
-  BEGIN_PUT(flwor_wincond::vars);
+  BEGIN_PUT_NO_DG(flwor_wincond::vars);
   PUT_SUB( "AT", posvar );
   PUT_SUB( "CURR", curr );
   PUT_SUB( "NEXT", next );
@@ -260,7 +276,7 @@
 
 ostream& flwor_wincond::put(ostream& os) const
 {
-  BEGIN_PUT(flwor_wincond);
+  BEGIN_PUT_NO_DG(flwor_wincond);
   PUT_SUB("IN-VARS", &get_in_vars());
   PUT_SUB("OUT-VARS", &get_out_vars());
   PUT_SUB("WHEN", theCondExpr);
@@ -270,7 +286,7 @@
 
 ostream& groupby_clause::put(ostream& os) const
 {
-  BEGIN_PUT_NL(GROUPBY);
+  BEGIN_PUT_NL_NO_DG(GROUPBY);
 
   os << indent << "GROUPING SPECS";
 
@@ -303,7 +319,7 @@
 
 ostream& orderby_clause::put(ostream& os) const
 {
-  BEGIN_PUT_NL(ORDERBY);
+  BEGIN_PUT_NL_NO_DG(ORDERBY);
 
   csize numColumns = num_columns();
 
@@ -318,7 +334,7 @@
 
 ostream& materialize_clause::put(ostream& os) const
 {
-  BEGIN_PUT_NL(MATERIALIZE);
+  BEGIN_PUT_NL_NO_DG(MATERIALIZE);
   END_PUT();
 }
 
@@ -939,7 +955,7 @@
 
 ostream& copy_clause::put(ostream& os) const
 {
-  BEGIN_PUT(copy);
+  BEGIN_PUT_NO_DG(copy);
   theVar->put(os);
   theExpr->put(os);
   END_PUT();

=== modified file 'src/compiler/expression/expr_type.cpp'
--- src/compiler/expression/expr_type.cpp	2013-06-15 02:57:08 +0000
+++ src/compiler/expression/expr_type.cpp	2013-07-04 13:34:33 +0000
@@ -643,6 +643,10 @@
       const FunctionXQType* funcType = static_cast<const FunctionXQType*>(fiType.getp());
       newType = funcType->get_return_type();
     }
+    else if (fiType->type_kind() == XQType::STRUCTURED_ITEM_KIND && e->get_args().size() == 1)
+    {
+      newType = rtm.STRUCTURED_ITEM_TYPE_STAR;
+    } 
     else
     {
       newType = rtm.ITEM_TYPE_STAR;

=== added file 'src/compiler/expression/json_dataguide.cpp'
--- src/compiler/expression/json_dataguide.cpp	1970-01-01 00:00:00 +0000
+++ src/compiler/expression/json_dataguide.cpp	2013-07-04 13:34:33 +0000
@@ -0,0 +1,351 @@
+/*
+ * Copyright 2006-2013 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 "system/globalenv.h"
+#include "store/api/item_factory.h"
+
+#include "compiler/expression/expr_base.h"
+#include "compiler/expression/json_dataguide.h"
+
+
+namespace zorba
+{
+  
+/*******************************************************************************
+  
+********************************************************************************/  
+dataguide_node::dataguide_node(store::Item* key)
+  :
+  is_star(false)
+{
+  add(key);
+}
+
+
+dataguide_node* dataguide_node::add(store::Item* key)
+{
+  dataguide_node* existing = get(key);
+  if (existing)
+  {
+    return existing;
+  }
+  
+  keys.push_back(key);
+  values.push_back(dataguide_node());
+  return &values[values.size() - 1];
+}
+
+
+void dataguide_node::add_to_leaves(store::Item* key)
+{
+  if (is_star)
+    return;
+  
+  if (keys.size() == 0) // no children == leaf
+  {
+    keys.push_back(key);
+    values.push_back(dataguide_node());
+    return;
+  }
+  
+  for (unsigned int i=0; i != keys.size(); i++)
+    values[i].add_to_leaves(key);
+}
+
+
+void dataguide_node::add_to_leaves(const dataguide_node* other)
+{
+  if (is_star)
+    return;
+  
+  if (keys.size() == 0) // no children == leaf
+  {
+    clone(other);
+    return;
+  }
+  
+  for (unsigned int i=0; i != keys.size(); i++)
+    values[i].add_to_leaves(other);  
+}
+
+
+void dataguide_node::set_star()
+{
+  is_star = true;
+  keys.clear();
+  values.clear();  
+}
+
+
+void dataguide_node::set_star_on_leaves()
+{
+  if (is_star)
+    return;
+  
+  if (keys.size() == 0)
+  {
+    set_star();
+    return;
+  }
+  
+  for (unsigned int i=0; i != keys.size(); i++)
+    values[i].set_star_on_leaves();
+}
+
+
+void dataguide_node::do_union(const dataguide_node* other)
+{
+  if (other->is_star)
+  {
+    set_star();
+    return;
+  }
+  
+  for (unsigned int i=0; i<other->keys.size(); i++)
+  {
+    bool found = false;
+    unsigned int j = 0;
+    for ( ; j<keys.size(); j++)
+      if (keys[j]->equals(other->keys[i]))
+      {
+        found = true;
+        break;
+      }
+    
+    if (found)
+    {
+      values[i].do_union(&other->values[j]);      
+    }    
+    else
+    {          
+      keys.push_back(other->keys[i]);
+      values.push_back(dataguide_node());
+      values.back().do_union(&other->values[i]);      
+    }
+  }    
+}
+
+
+void dataguide_node::clone(const dataguide_node* other)
+{ 
+  if (other->is_star)
+  {
+    set_star();
+    return;
+  }
+  
+  for (unsigned int i=0; i<other->keys.size(); i++)
+  {
+    keys.push_back(other->keys[i]);
+    values.push_back(dataguide_node());
+    values.back().clone(&other->values[i]);
+  }
+}
+
+
+dataguide_node* dataguide_node::get(store::Item* key)
+{
+  for (unsigned int i=0; i<keys.size(); i++)
+    if (keys[i]->equals(key))
+      return &values[i];
+  
+  return NULL;
+}
+
+
+store::Item_t dataguide_node::get_as_json()
+{ 
+  std::vector<store::Item_t> vals;
+  for (unsigned int i=0; i<values.size(); i++)
+  {
+    if (values[i].is_star)
+    {
+      store::Item_t star_string;
+      zstring star = zstring("*");
+      GENV_ITEMFACTORY->createString(star_string, star);
+      vals.push_back(star_string);
+    }
+    else
+      vals.push_back(values[i].get_as_json());
+  }
+    
+  store::Item_t result;
+  GENV_ITEMFACTORY->createJSONObject(result, keys, vals);
+  
+  return result;
+}
+
+
+zstring dataguide_node::toString()
+{
+  return get_as_json()->show();  
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+dataguide_cb::dataguide_cb()
+{
+}
+
+
+void dataguide_cb::add_to_leaves(store::Item* object_name)
+{
+  // Append the given object to each leaf node
+  map_type::iterator i = theDataguideMap.begin();
+  for ( ; i != theDataguideMap.end(); i++)
+  {
+    i->second.add_to_leaves(object_name);
+  }
+}
+
+
+void dataguide_cb::add_to_leaves(dataguide_node* other)
+{
+  // Append the given object to each leaf node
+  map_type::iterator i = theDataguideMap.begin();
+  for ( ; i != theDataguideMap.end(); i++)
+  {
+    i->second.add_to_leaves(other);
+  }
+}
+
+
+void dataguide_cb::set_star_on_leaves()
+{
+  map_type::iterator i = theDataguideMap.begin();
+  for ( ; i != theDataguideMap.end(); i++)
+  {
+    i->second.set_star_on_leaves();
+  }
+}
+
+
+void dataguide_cb::set_star_on_roots()
+{
+  map_type::iterator i = theDataguideMap.begin();
+  for ( ; i != theDataguideMap.end(); i++)
+  {
+    i->second.set_star();
+  }
+}
+
+
+dataguide_node* dataguide_cb::add_source(expr* e)
+{
+  theDataguideMap[e] = dataguide_node();
+  return &theDataguideMap[e];
+}
+
+
+void dataguide_cb::do_union(const dataguide_cb *other)
+{
+  if (this == other || other == NULL)
+    return;
+  
+  map_type::const_iterator it = other->theDataguideMap.begin();
+  for (; it != other->theDataguideMap.end(); ++it)
+  {
+    theDataguideMap[it->first].do_union(&it->second);    
+  }  
+}
+
+
+void dataguide_cb::do_union(expr* other)
+{
+  if (other == NULL)
+    return;
+  
+  do_union(other->get_dataguide());
+}
+
+
+dataguide_cb_t dataguide_cb::clone()
+{
+  dataguide_cb_t new_dg = new dataguide_cb();
+  
+  map_type::iterator it = theDataguideMap.begin();
+  for (; it != theDataguideMap.end(); ++it)
+  {    
+    dataguide_node* new_node = new_dg->add_source(it->first);
+    new_node->clone(&it->second);
+  }
+  
+  return new_dg;
+}
+
+
+dataguide_node* dataguide_cb::get_for_source(expr* e)
+{
+  map_type::iterator it = theDataguideMap.find(e);
+  
+  if (it != theDataguideMap.end())
+    return &it->second;
+  else
+    return NULL;
+}
+
+
+bool dataguide_cb::is_empty(expr* e) 
+{  
+  return theDataguideMap[e].keys.size() == 0 || theDataguideMap[e].is_star;
+}
+
+
+store::Item_t dataguide_cb::get_as_json(expr* e)
+{
+  if (theDataguideMap[e].is_star)
+    return NULL;
+  else
+    return theDataguideMap[e].get_as_json();  
+}
+
+
+zstring dataguide_cb::toString()
+{
+  std::stringstream str;
+  str << this;
+  str << " {";
+  
+  map_type::iterator it = theDataguideMap.begin();
+  for (; it != theDataguideMap.end(); ++it)
+  {
+    str << " " << it->first << ": " << it->second.toString();
+  }  
+  
+  str << "}";
+  return str.str();
+}
+
+bool dataguide_cb::func_uses_dataguide(FunctionConsts::FunctionKind kind)
+{
+  if (kind == FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_1 ||
+      kind == FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_2 ||
+      kind == FunctionConsts::STATIC_COLLECTIONS_DML_COLLECTION_3 ||
+      kind == FunctionConsts::DYNAMIC_COLLECTIONS_DML_COLLECTION_1 ||
+      kind == FunctionConsts::DYNAMIC_COLLECTIONS_DML_COLLECTION_2 ||
+      kind == FunctionConsts::DYNAMIC_COLLECTIONS_DML_COLLECTION_3 ||
+      kind == FunctionConsts::FN_JSONIQ_PARSE_JSON_1 ||
+      kind == FunctionConsts::FN_JSONIQ_PARSE_JSON_2)
+    return true;
+  else
+    return false;
+}
+
+}
+/* vim:set et sw=2 ts=2: */

=== added file 'src/compiler/expression/json_dataguide.h'
--- src/compiler/expression/json_dataguide.h	1970-01-01 00:00:00 +0000
+++ src/compiler/expression/json_dataguide.h	2013-07-04 13:34:33 +0000
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2006-2013 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.
+ */
+#pragma once
+#ifndef ZORBA_COMPILER_JSON_DATAGUIDE
+#define ZORBA_COMPILER_JSON_DATAGUIDE
+
+#include "zorbautils/string_util.h"
+#include "store/api/item.h"
+#include "functions/function_consts.h"
+
+
+namespace zorba
+{
+
+class expr;  
+  
+
+/******************************************************************************
+  
+*******************************************************************************/
+class dataguide_node
+{
+public:
+  bool is_star;
+  
+  std::vector<store::Item_t> keys;
+  
+  std::vector<dataguide_node> values;
+  
+  
+public:  
+  dataguide_node() : is_star(false) { }
+  
+  dataguide_node(store::Item* key);
+    
+  // returns the newly created node
+  dataguide_node* add(store::Item* key); 
+  
+  void add_to_leaves(store::Item* key);
+  
+  void add_to_leaves(const dataguide_node* other);
+  
+  void set_star();
+  
+  void set_star_on_leaves();
+  
+  void do_union(const dataguide_node* other);
+  
+  // returns the child dataguide node associated with the given key, or NULL if there is none
+  dataguide_node* get(store::Item* key);
+  
+  // Will build a clone of the "other" dataguide_node into "this"
+  // Will return the newly constructed dataguide_node* that will become "current"
+  // dataguide_node* clone(dataguide_node* other, dataguide_node* current);
+  
+  // recursively constructs "this" to be a clone of the other dataguide
+  void clone(const dataguide_node* other);
+  
+  store::Item_t get_as_json();
+
+  zstring toString();
+};
+
+
+/******************************************************************************
+  The JSON dataguide control block
+*******************************************************************************/
+class dataguide_cb : public SimpleRCObject
+{
+friend class JsonDataguide;
+
+public:
+  typedef std::map<expr*, dataguide_node> map_type;
+  
+protected:  
+  std::map<expr*,dataguide_node> theDataguideMap;
+  
+  
+public:
+  dataguide_cb();
+    
+  dataguide_node* add_source(expr* e);
+  
+  void add_to_leaves(store::Item* object_name);
+  
+  void add_to_leaves(dataguide_node* other);
+  
+  void set_star_on_leaves();
+  
+  void set_star_on_roots();
+      
+  void do_union(const dataguide_cb* other);
+  
+  void do_union(expr *other);
+  
+  dataguide_cb_t clone();
+  
+  dataguide_node* get_for_source(expr* e);
+  
+  bool is_empty(expr *e);                                             
+  
+  store::Item_t get_as_json(expr *e);  
+  
+  zstring toString();  
+  
+public:
+
+  static bool func_uses_dataguide(FunctionConsts::FunctionKind kind);
+};
+
+
+}
+
+#endif  // ZORBA_COMPILER_JSON_DATAGUIDE
+
+/*
+ * Local variables:
+ * mode: c++
+ * End:
+ */
+/* vim:set et sw=2 ts=2: */

=== modified file 'src/compiler/expression/var_expr.cpp'
--- src/compiler/expression/var_expr.cpp	2013-04-24 01:35:58 +0000
+++ src/compiler/expression/var_expr.cpp	2013-07-04 13:34:33 +0000
@@ -23,6 +23,7 @@
 #include "compiler/expression/flwor_expr.h"
 #include "compiler/expression/expr_visitor.h"
 #include "compiler/api/compilercb.h"
+#include "compiler/expression/json_dataguide.h"
 
 #include "types/typeops.h"
 

=== modified file 'src/compiler/rewriter/framework/default_optimizer.cpp'
--- src/compiler/rewriter/framework/default_optimizer.cpp	2013-05-15 10:27:06 +0000
+++ src/compiler/rewriter/framework/default_optimizer.cpp	2013-07-04 13:34:33 +0000
@@ -266,7 +266,16 @@
       driverMarkNodeCopyProps.rewrite(rCtx);
     }
   }
-
+  
+  // Compute Json Dataguide
+  RuleOnceDriver<JsonDataguide> driverJsonDataguide;
+  driverJsonDataguide.rewrite(rCtx);
+  
+  if (Properties::instance()->printDataguide())
+  {
+    driverJsonDataguide.getRule()->printDataguides(rCtx.getRoot());
+  }
+  
   return modified;
 }
 

=== modified file 'src/compiler/rewriter/rules/nodeid_rules.cpp'
--- src/compiler/rewriter/rules/nodeid_rules.cpp	2013-06-15 02:57:08 +0000
+++ src/compiler/rewriter/rules/nodeid_rules.cpp	2013-07-04 13:34:33 +0000
@@ -36,6 +36,8 @@
 #include "functions/func_node_sort_distinct.h"
 #include "functions/udf.h"
 
+#include "compiler/expression/json_dataguide.h"
+
 #include "diagnostics/assert.h"
 
 
@@ -1538,5 +1540,461 @@
 }
 
 
+/*******************************************************************************
+
+********************************************************************************/
+expr* JsonDataguide::apply(
+    RewriterContext& rCtx,
+    expr* node,
+    bool& modified)
+{     
+  iterateChildren(node, true);
+  postprocess(node, true);
+  
+  if (node->get_dataguide() != NULL)
+  {    
+    std::map<expr*,dataguide_node>::iterator i = node->get_dataguide()->theDataguideMap.begin();
+    for ( ; i != node->get_dataguide()->theDataguideMap.end(); ++i)
+    {
+      i->first->set_dataguide(node->get_dataguide());
+    }
+  }
+    
+  return NULL;
+}
+
+
+void JsonDataguide::printDataguides(expr* root)
+{
+  dataguide_cb* dg = root->get_dataguide();
+  if (dg == NULL)
+    return;
+  
+  std::map<expr*,dataguide_node>::iterator i = dg->theDataguideMap.begin();
+  for ( ; i != dg->theDataguideMap.end(); ++i)
+  {
+    fo_expr* fo = dynamic_cast<fo_expr*>(i->first);
+    // TODO: make sure only fo_exprs get dataguides
+    // ZORBA_ASSERT(fo != NULL);    
+    if (fo != NULL)
+    {
+      store::Item_t json_dg = dg->get_as_json(fo);
+      if (json_dg.getp())
+        std::cout << "Dataguide for function " << fo->get_func()->getName()->getStringValue() << "() at " 
+                  << fo->get_loc().getLineBegin() << ":" << fo->get_loc().getColumnBegin() << ": "
+                  << json_dg->show() << std::endl;                  
+    }
+  }  
+}
+
+
+// For a given expression that is bound to a clause var (for/let/groupby), return the var_expr 
+// or NULL if expr is not bound to a clause var
+var_expr* getClauseVar(flwor_expr* flwor, expr* node, bool& is_groupby)
+{  
+  is_groupby = false;
+  
+  for (unsigned int i=0; i < flwor->num_clauses(); i++)
+  {
+    flwor_clause* c = flwor->get_clause(i);
+    if (c->get_kind() == flwor_clause::for_clause ||
+        c->get_kind() == flwor_clause::let_clause)
+    {
+      forlet_clause* fc = static_cast<forlet_clause*>(c);
+      if (fc->get_expr() == node)      
+        return fc->get_var();
+    }      
+    else if (c->get_kind() == flwor_clause::groupby_clause)
+    {
+      groupby_clause* gc = static_cast<groupby_clause*>(c);
+      flwor_clause::rebind_list_t::iterator it = gc->beginGroupVars();
+      for ( ; it != gc->endGroupVars(); ++it)
+        if (it->first == node)
+        {
+          is_groupby = true;
+          return it->second;
+        }
+      
+      it = gc->beginNonGroupVars();
+      for ( ; it != gc->endNonGroupVars(); ++it)
+        if (it->first == node)
+        {
+          is_groupby = true;
+          return it->second;
+        }
+    }
+  }
+  
+  return NULL;  
+}
+
+
+void propagate_dg(expr* node, expr* child)
+{
+  if (node->get_dataguide() != NULL)
+  {
+    node->set_dataguide(node->get_dataguide()->clone());
+    node->get_dataguide()->do_union(child);
+  }
+  else if (child->get_dataguide() != NULL)
+    node->set_dataguide(child->get_dataguide());
+}
+
+
+void JsonDataguide::iterateChildren(expr* node, bool set_star)
+{    
+  flwor_expr* flwor = NULL;      
+  if (node->get_expr_kind() == flwor_expr_kind)
+    flwor = static_cast<flwor_expr*>(node);
+    
+  if (node->get_udf() != NULL && node->get_udf()->getBody() == node)
+  {
+    // std::cerr << "--> " << node << " is root expr for udf: " << node->get_udf()->getName()->getStringValue() << std::endl;
+    for (unsigned int i=0; i<node->get_udf()->numArgs(); i++)
+    {
+      var_expr* v = node->get_udf()->getArgVar(i);
+      v->get_dataguide_or_new()->add_source(v);
+      // std::cerr << "--> to udf: " << node->get_udf()->getName()->getStringValue() << " adding source: " << v << " which is var: " << v->get_name()->getStringValue() << std::endl;      
+    }    
+  }
+  
+  if (node->get_expr_kind() == fo_expr_kind && static_cast<fo_expr*>(node)->get_func()->isUdf())
+  {
+    set_star = false;         
+    // std::cerr << "--> " << node << " setting set_star to false" << std::endl;
+  }
+      
+  ExprIterator iter(node);
+  while (!iter.done())
+  {    
+    expr* child = (**iter);      
+    if (child == NULL)
+      continue;
+  
+    bool is_groupby;
+    var_expr* clause_var;
+    if (flwor && (clause_var = getClauseVar(flwor, child, is_groupby)))
+    {
+      iterateChildren(child, false);
+      postprocess(child, false);      
+      clause_var->set_dataguide(child->get_dataguide());      
+      if (is_groupby)
+        propagate_dg(node, child);
+      // std::cerr << "--> clause dg: " << (child->get_dataguide() ? child->get_dataguide()->toString() : "NULL") << std::endl;
+    }
+    else
+    {             
+      iterateChildren(child, set_star);
+      postprocess(child, set_star);
+      propagate_dg(node, child);
+      // if (flwor) std::cerr << "--> flwor " << flwor << " child expr: " << child << " with dg: " << child->get_dataguide()->toString() << std::endl;     
+    }
+            
+    iter.next();
+  } // while
+    
+  // std::cerr << "--> " << node << " " << node->get_expr_kind_string() << " set_star: " << set_star << " dataguide: " << (node->get_dataguide() ? node->get_dataguide()->toString() : "") << std::endl;
+}
+
+
+void JsonDataguide::postprocess(expr* node, bool set_star)
+{ 
+  switch (node->get_expr_kind())
+  {  
+  case dynamic_function_invocation_expr_kind:
+  {
+    dynamic_function_invocation_expr* fo = static_cast<dynamic_function_invocation_expr*>(node);
+    expr* sourceExpr = fo->get_function();
+    TypeManager* tm = sourceExpr->get_type_manager();
+    xqtref_t sourceType = sourceExpr->get_return_type();    
+    if ((TypeOps::is_subtype(tm, *sourceType, *GENV_TYPESYSTEM.JSON_ITEM_TYPE_STAR) 
+          || TypeOps::is_subtype(tm, *sourceType, *GENV_TYPESYSTEM.STRUCTURED_ITEM_TYPE_STAR))
+        && fo->get_args().size() == 1
+        && fo->get_args()[0]->get_expr_kind() == const_expr_kind)
+    {
+      dataguide_cb_t dg = fo->get_dataguide() ? fo->get_dataguide()->clone().getp() : new dataguide_cb();      
+      dg->add_to_leaves(static_cast<const_expr*>(fo->get_args()[0])->get_val());         
+      fo->set_dataguide(dg);
+      
+      // std::cerr << "--> " << node << " after adding \"" << static_cast<const_expr*>(fo->get_args()[0])->get_val()->toString() 
+      //           << "\" dg: " << fo->get_dataguide()->toString() << std::endl;
+    }
+    break;
+  }   
+  case fo_expr_kind :
+  {
+    fo_expr* fo = static_cast<fo_expr*>(node);
+    function* f = fo->get_func();
+    if (fo->get_dataguide() && f->getKind() == FunctionConsts::FN_JSONIQ_VALUE_2)
+    {      
+      if (fo->get_arg(1)->get_expr_kind() == const_expr_kind)
+      {         
+        // dataguide_cb_t dg = fo->get_dataguide() ? fo->get_dataguide()->clone().getp() : new dataguide_cb();
+        dataguide_cb_t dg = fo->get_dataguide()->clone();
+        
+        // std::cerr << "--> fo_expr original dg: " << fo->get_dataguide()->toString() << std::endl;
+        // std::cerr << "--> cloned dg: " << (dg ? dg->toString() : "NULL") << std::endl;        
+        
+        dg->add_to_leaves(static_cast<const_expr*>(fo->get_arg(1))->get_val());         
+        fo->set_dataguide(dg);
+                
+        // std::cerr << "--> fo_expr node: " << fo << " after adding \"" << static_cast<const_expr*>(fo->get_arg(1))->get_val()->toString() 
+        //           << "\" dg: " << fo->get_dataguide()->toString() << std::endl;
+      }
+      else
+      {
+        // std::cerr << "--> " << node << " setting star on dg: " << node->get_dataguide()->toString() << std::endl;
+        node->get_dataguide()->set_star_on_leaves();
+      }      
+    }
+    else if (dataguide_cb::func_uses_dataguide(f->getKind()))
+    {      
+      fo->get_dataguide_or_new()->add_source(fo);
+    }
+    else if (f->isExternal()
+             ||
+             (f->getAnnotationList() != NULL
+              &&
+              f->getAnnotationList()->contains(AnnotationInternal::zann_explores_json)))
+    {
+      if (fo->get_dataguide())
+      {
+        // std::cerr << "--> " << node << " setting star on dg: " << node->get_dataguide()->toString() << std::endl;
+        fo->get_dataguide()->set_star_on_leaves();
+      }
+    }
+    else if (f->isUdf())
+    {
+      user_function* udf = static_cast<user_function*>(f);
+      if (udf->isRecursive())
+      {
+        if (fo->get_dataguide())
+          fo->get_dataguide()->set_star_on_leaves();
+      }    
+      else
+      {
+        // Iterate through the effective parameters and prepend to it the function's formal parameter's dataguide
+        for (unsigned int i=0; i<udf->numArgs(); i++)
+        { 
+          dataguide_cb_t new_dg;
+          dataguide_node* var_dg = udf->getBody()->get_dataguide()->get_for_source(udf->getArgVar(i));          
+          if (var_dg)     
+          {
+            // std::cerr << "--> adding to fo effective arg " << i << " "  << fo->get_arg(i) << " with dg: " << fo->get_arg(i)->get_dataguide_or_new()->toString()
+            //          << " the dg: " << var_dg->toString() << std::endl;
+            
+            new_dg = new dataguide_cb();
+            if (fo->get_arg(i)->get_dataguide())
+              new_dg = fo->get_arg(i)->get_dataguide()->clone();
+            
+            new_dg->add_to_leaves(var_dg);
+            // std::cerr << "--> dg after addition: " << new_dg->toString() << std::endl;
+          }
+            
+          if (fo->get_dataguide())
+            fo->get_dataguide()->do_union(new_dg);
+          else
+            fo->set_dataguide(new_dg);
+        } // for
+      }
+    }
+    
+    break;
+  }  
+  case flwor_expr_kind:
+  { 
+    flwor_expr* flwor = static_cast<flwor_expr*>(node);
+    if (flwor->get_dataguide() && set_star) 
+    {
+      // std::cerr << "--> " << node << " set_star: " << set_star << " setting star on dg: " << node->get_dataguide()->toString() << std::endl;
+      // TOOD: decide if it is needed:
+      flwor->get_dataguide()->set_star_on_leaves();
+    }
+    break;
+  }    
+  case eval_expr_kind:
+  {
+    // invalidate all dataguides
+    dataguide_cb* dg = node->get_dataguide_or_new();
+    dg->set_star_on_roots();    
+    break;
+  }
+    
+  case const_expr_kind:    
+  case treat_expr_kind:
+  case wrapper_expr_kind:
+    break;    
+    
+  case var_expr_kind:
+  {
+    var_expr* e = static_cast<var_expr*>(node);
+
+    switch (e->get_kind())
+    {
+    case var_expr::for_var:
+    case var_expr::let_var:
+    case var_expr::win_var:
+    case var_expr::wincond_out_var:
+    case var_expr::wincond_in_var:
+    case var_expr::groupby_var:
+    case var_expr::non_groupby_var:
+    {
+      break;
+    }
+
+    case var_expr::wincond_in_pos_var:
+    case var_expr::wincond_out_pos_var:
+    case var_expr::pos_var:
+    case var_expr::score_var:
+    case var_expr::count_var:
+    {
+      break;
+    }
+
+    case var_expr::copy_var:
+    {      
+      break;
+    }
+
+    case var_expr::prolog_var:
+    case var_expr::local_var:
+    {
+      break;
+    }
+
+    case var_expr::catch_var:
+    {      
+      break;
+    }
+
+    case var_expr::arg_var:
+    {      
+      break;
+    }
+
+    case var_expr::eval_var:
+    default:
+    {
+      ZORBA_ASSERT(false);
+    }
+    } // switch
+
+    break;
+  }
+    
+  case attr_expr_kind:
+  case namespace_expr_kind:
+  case text_expr_kind:
+  case pi_expr_kind:
+  {
+    break;
+  }
+
+#ifdef ZORBA_WITH_JSON
+  case json_direct_object_expr_kind:
+  case json_object_expr_kind:
+  case json_array_expr_kind:
+  {
+    // TODO? We need to drill inside a json pair or array constructor only
+    // if we are coming from an unbox or flatten call ????
+    break;
+  }
+#endif
+
+  case relpath_expr_kind:
+  { 
+    break;
+  }
+
+  case if_expr_kind:
+  {    
+    break;
+  }
+
+  case trycatch_expr_kind:
+  {
+    break;
+  }
+
+  case promote_expr_kind:
+  case order_expr_kind:
+  case function_trace_expr_kind:
+  case extension_expr_kind:
+  case validate_expr_kind:
+  {
+    break;
+  }
+
+  case transform_expr_kind:
+  {    
+    break;
+  }
+
+  case block_expr_kind:
+  {
+    // block_expr* e = static_cast<block_expr*>(node);
+    // findNodeSourcesRec((*e)[e->size()-1], sources, currentUdf);
+    break;
+  }
+
+  case var_decl_expr_kind:
+  case var_set_expr_kind:
+  {
+    break;
+  }
+
+  case apply_expr_kind:
+  {
+    break;
+  }
+
+  case exit_catcher_expr_kind:
+  {
+    break;
+  }
+
+  
+  case debugger_expr_kind:
+  {
+    break;
+  }
+
+ 
+  // These expressions do not modify any dataguides
+  case doc_expr_kind:
+  case elem_expr_kind:
+  case argument_placeholder_expr_kind:    
+  case function_item_expr_kind:
+    break;  
+    
+  case json_direct_object_expr_kind:
+  case json_object_expr_kind:
+  case json_array_expr_kind:
+
+  case castable_expr_kind:
+  case cast_expr_kind:
+  case instanceof_expr_kind:
+  case name_cast_expr_kind:
+  case axis_step_expr_kind:
+  case match_expr_kind:
+  case delete_expr_kind:
+  case insert_expr_kind:
+  case rename_expr_kind:
+  case replace_expr_kind:
+  case while_expr_kind:
+  case exit_expr_kind:
+  case flowctl_expr_kind:
+#ifndef ZORBA_NO_FULL_TEXT
+  case ft_expr_kind:
+#endif
+    break;
+    
+  case unknown_expr_kind:
+    ZORBA_ASSERT(false);
+    break;
+  } // switch
+}
+
+
 }
 /* vim:set et sw=2 ts=2: */

=== modified file 'src/compiler/rewriter/rules/rule_base.h'
--- src/compiler/rewriter/rules/rule_base.h	2013-02-07 17:24:36 +0000
+++ src/compiler/rewriter/rules/rule_base.h	2013-07-04 13:34:33 +0000
@@ -55,7 +55,8 @@
     InlineFunctions,
     PartialEval,
     EchoNodes,
-    PlanPrinter
+    PlanPrinter,
+    JsonDataguide
   } RuleKind;
 
 private:

=== modified file 'src/compiler/rewriter/rules/ruleset.h'
--- src/compiler/rewriter/rules/ruleset.h	2013-05-13 10:10:08 +0000
+++ src/compiler/rewriter/rules/ruleset.h	2013-07-04 13:34:33 +0000
@@ -223,6 +223,31 @@
 };
 
 
+/*******************************************************************************
+
+********************************************************************************/
+class JsonDataguide : public RewriteRule
+{
+public:
+  JsonDataguide()
+    :
+    RewriteRule(RewriteRule::JsonDataguide, "JsonDataguide")
+  {
+  }
+
+  expr* apply(RewriterContext& rCtx, expr* node, bool& modified);
+  
+public:
+  // used for automated testing
+  void printDataguides(expr* root); 
+  
+protected:
+  void iterateChildren(expr* node, bool set_star);
+  
+  void postprocess(expr* node, bool set_star);  
+};
+
+
 }
 
 #endif /* ZORBA_REWRITE_RULE_H */

=== modified file 'src/functions/function.cpp'
--- src/functions/function.cpp	2013-04-15 13:52:08 +0000
+++ src/functions/function.cpp	2013-07-04 13:34:33 +0000
@@ -131,6 +131,30 @@
 }
 
 
+void function::addAnnotation(AnnotationInternal::AnnotationId id)
+{
+  if (theAnnotationList.getp() == NULL)
+    theAnnotationList = new AnnotationList();
+  
+  if (theAnnotationList->contains(id))
+    return;
+  
+  theAnnotationList->push_back(id);
+  
+  if (theAnnotationList->contains(AnnotationInternal::zann_nondeterministic))
+    setDeterministic(false);
+
+  setPrivate(theAnnotationList->contains(AnnotationInternal::fn_private));
+
+  if (isUpdating() &&
+      theAnnotationList->contains(AnnotationInternal::zann_sequential))
+  {
+    throw XQUERY_EXCEPTION(zerr::XSST0001,
+    ERROR_PARAMS(getName()->getStringValue()));
+  }
+}
+
+
 /*******************************************************************************
   This is a virstual method. It is redefined by udf and external-function
   classes. 

=== modified file 'src/functions/function.h'
--- src/functions/function.h	2013-04-15 13:52:08 +0000
+++ src/functions/function.h	2013-07-04 13:34:33 +0000
@@ -51,7 +51,7 @@
 class function : public SimpleRCObject
 {
 protected:
-	signature                    theSignature;
+  signature                    theSignature;
   FunctionConsts::FunctionKind theKind;
   uint32_t                     theFlags;
   AnnotationList_t             theAnnotationList;
@@ -165,8 +165,10 @@
   void setAnnotations(AnnotationList* annotations);
 
   const AnnotationList* getAnnotationList() const { return theAnnotationList.getp(); }
+  
+  void addAnnotation(AnnotationInternal::AnnotationId id);
 
-	bool validate_args(std::vector<PlanIter_t>& argv) const;
+  bool validate_args(std::vector<PlanIter_t>& argv) const;
 
   bool isUpdating() const { return (getScriptingKind() & UPDATING_EXPR) != 0; }
 

=== modified file 'src/functions/pregenerated/func_accessors.h'
--- src/functions/pregenerated/func_accessors.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_accessors.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
@@ -62,7 +62,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
@@ -79,7 +78,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
@@ -95,7 +94,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
@@ -112,7 +110,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
@@ -129,7 +126,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   xqtref_t getReturnType(const fo_expr* caller) const;
@@ -154,7 +150,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
@@ -171,7 +166,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
@@ -187,7 +182,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
@@ -204,7 +198,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }

=== modified file 'src/functions/pregenerated/func_any_uri.h'
--- src/functions/pregenerated/func_any_uri.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_any_uri.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }

=== modified file 'src/functions/pregenerated/func_base64.h'
--- src/functions/pregenerated/func_base64.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_base64.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -61,7 +60,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_booleans.h'
--- src/functions/pregenerated/func_booleans.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_booleans.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -63,7 +62,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -80,7 +78,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }

=== modified file 'src/functions/pregenerated/func_collections.h'
--- src/functions/pregenerated/func_collections.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_collections.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -67,7 +66,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -88,7 +86,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -105,7 +102,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -122,7 +118,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -141,7 +136,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -172,7 +166,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -191,7 +184,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -210,7 +202,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -233,7 +225,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -256,7 +248,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -279,7 +271,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -302,7 +294,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -325,7 +317,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   unsigned short getScriptingKind() const { return APPLYING_EXPR; }
@@ -350,7 +342,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   unsigned short getScriptingKind() const { return APPLYING_EXPR; }
@@ -375,7 +367,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   unsigned short getScriptingKind() const { return APPLYING_EXPR; }
@@ -400,7 +392,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   unsigned short getScriptingKind() const { return APPLYING_EXPR; }
@@ -425,7 +417,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   unsigned short getScriptingKind() const { return APPLYING_EXPR; }
@@ -450,7 +442,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -475,7 +466,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -496,7 +486,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -517,7 +506,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -540,7 +529,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -559,7 +547,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -576,7 +563,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -593,7 +579,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -610,7 +595,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -627,7 +611,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -642,7 +625,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -657,7 +639,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -672,7 +653,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -687,7 +667,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -702,7 +681,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -717,7 +695,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_context.h'
--- src/functions/pregenerated/func_context.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_context.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -63,7 +62,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -80,7 +78,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -97,7 +94,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -114,7 +110,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -131,7 +126,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -146,7 +140,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -161,7 +154,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_datetime.h'
--- src/functions/pregenerated/func_datetime.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_datetime.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -61,7 +60,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -76,7 +74,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -91,7 +88,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -106,7 +102,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -121,7 +116,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -136,7 +130,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -151,7 +144,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -166,7 +158,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_documents.h'
--- src/functions/pregenerated/func_documents.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_documents.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -67,7 +66,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -86,7 +84,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -103,7 +100,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -120,7 +116,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }

=== modified file 'src/functions/pregenerated/func_durations_dates_times.h'
--- src/functions/pregenerated/func_durations_dates_times.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_durations_dates_times.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -61,7 +60,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -76,7 +74,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -91,7 +88,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -106,7 +102,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -121,7 +116,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -136,7 +130,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -151,7 +144,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -166,7 +158,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -181,7 +172,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -196,7 +186,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -211,7 +200,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -226,7 +214,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -241,7 +228,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -256,7 +242,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -271,7 +256,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -286,7 +270,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -301,7 +284,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -316,7 +298,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -331,7 +312,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -346,7 +326,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_errors_and_diagnostics.h'
--- src/functions/pregenerated/func_errors_and_diagnostics.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_errors_and_diagnostics.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return VACUOUS_EXPR; }
@@ -65,7 +64,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool isMap(csize producer) const { return producer == 0; }

=== modified file 'src/functions/pregenerated/func_fetch.h'
--- src/functions/pregenerated/func_fetch.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_fetch.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -63,7 +62,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -80,7 +78,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }

=== modified file 'src/functions/pregenerated/func_fn_hof_functions.h'
--- src/functions/pregenerated/func_fn_hof_functions.h	2013-06-04 21:47:40 +0000
+++ src/functions/pregenerated/func_fn_hof_functions.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -61,7 +61,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -76,7 +76,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -91,7 +91,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -106,7 +106,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -121,7 +121,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -136,7 +136,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_fnput.h'
--- src/functions/pregenerated/func_fnput.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_fnput.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }

=== modified file 'src/functions/pregenerated/func_ft_module.h'
--- src/functions/pregenerated/func_ft_module.h	2013-06-26 00:10:23 +0000
+++ src/functions/pregenerated/func_ft_module.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -62,7 +61,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -78,7 +76,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -94,7 +91,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -110,7 +106,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -126,7 +121,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -142,7 +136,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -158,7 +151,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -174,7 +166,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -190,7 +181,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -206,7 +196,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -222,7 +211,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -238,7 +226,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -254,7 +241,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -270,7 +256,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_ic_ddl.h'
--- src/functions/pregenerated/func_ic_ddl.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_ic_ddl.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -65,7 +64,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -84,7 +82,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }

=== modified file 'src/functions/pregenerated/func_index_func.h'
--- src/functions/pregenerated/func_index_func.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_index_func.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }

=== modified file 'src/functions/pregenerated/func_item.h'
--- src/functions/pregenerated/func_item.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_item.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_json.h'
--- src/functions/pregenerated/func_json.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_json.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -61,7 +60,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_jsoniq_functions.h'
--- src/functions/pregenerated/func_jsoniq_functions.h	2013-06-08 05:33:57 +0000
+++ src/functions/pregenerated/func_jsoniq_functions.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool propagatesInputNodes(expr* fo, csize producer) const { return false; }
@@ -65,7 +64,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   bool propagatesInputNodes(expr* fo, csize producer) const { return false; }
@@ -84,7 +83,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -103,7 +101,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -122,7 +119,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool propagatesInputNodes(expr* fo, csize producer) const { return producer == 0; }
@@ -141,7 +137,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   bool propagatesInputNodes(expr* fo, csize producer) const { return false; }
@@ -162,7 +158,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool propagatesInputNodes(expr* fo, csize producer) const { return false; }
@@ -181,7 +176,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool propagatesInputNodes(expr* fo, csize producer) const { return producer == 0; }
@@ -200,7 +194,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   bool propagatesInputNodes(expr* fo, csize producer) const { return producer == 0; }
@@ -219,7 +213,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool propagatesInputNodes(expr* fo, csize producer) const { return producer == 0; }
@@ -238,7 +231,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool propagatesInputNodes(expr* fo, csize producer) const { return producer == 0; }
@@ -259,7 +251,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool propagatesInputNodes(expr* fo, csize producer) const { return producer == 0; }
@@ -278,7 +269,7 @@
     : 
     function(sig, kind)
   {
-
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   bool propagatesInputNodes(expr* fo, csize producer) const { return false; }
@@ -297,7 +288,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool propagatesInputNodes(expr* fo, csize producer) const { return true; }
@@ -316,7 +306,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -331,7 +320,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -346,7 +334,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -367,7 +354,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -388,7 +374,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -407,7 +392,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -428,7 +412,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -447,7 +430,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -468,7 +450,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   xqtref_t getReturnType(const fo_expr* caller) const;

=== modified file 'src/functions/pregenerated/func_maps.h'
--- src/functions/pregenerated/func_maps.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_maps.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
@@ -65,7 +64,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
@@ -84,7 +82,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
@@ -103,7 +100,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -120,7 +116,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
@@ -141,7 +136,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
@@ -160,7 +154,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -177,7 +170,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -194,7 +186,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -211,7 +202,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }

=== modified file 'src/functions/pregenerated/func_maths.h'
--- src/functions/pregenerated/func_maths.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_maths.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -61,7 +60,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -76,7 +74,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -91,7 +88,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -106,7 +102,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -121,7 +116,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -136,7 +130,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -151,7 +144,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -166,7 +158,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -181,7 +172,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -196,7 +186,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -211,7 +200,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -226,7 +214,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -241,7 +228,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -256,7 +242,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -271,7 +256,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -286,7 +270,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -301,7 +284,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -316,7 +298,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -331,7 +312,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -346,7 +326,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -361,7 +340,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -376,7 +354,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -391,7 +368,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -406,7 +382,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -421,7 +396,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_node_position.h'
--- src/functions/pregenerated/func_node_position.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_node_position.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -61,7 +60,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -76,7 +74,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -91,7 +88,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -106,7 +102,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -121,7 +116,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -136,7 +130,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -151,7 +144,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -166,7 +158,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -181,7 +172,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -196,7 +186,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -211,7 +200,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -226,7 +214,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -241,7 +228,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -256,7 +242,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -271,7 +256,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -286,7 +270,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -301,7 +284,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -316,7 +298,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -331,7 +312,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -346,7 +326,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -361,7 +340,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -376,7 +354,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -391,7 +368,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_nodes.h'
--- src/functions/pregenerated/func_nodes.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_nodes.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -63,7 +62,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -78,7 +76,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
@@ -95,7 +92,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -110,7 +106,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
@@ -127,7 +122,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
@@ -144,7 +138,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
@@ -161,7 +154,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -176,7 +168,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return false; }
@@ -193,7 +185,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -210,7 +202,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -227,7 +219,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -244,7 +236,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -261,7 +252,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -278,7 +268,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -295,7 +284,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -312,7 +300,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -329,7 +316,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -346,7 +332,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -363,7 +348,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -380,7 +364,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -397,7 +380,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -414,7 +396,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -429,7 +411,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const;

=== modified file 'src/functions/pregenerated/func_numerics.h'
--- src/functions/pregenerated/func_numerics.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_numerics.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -61,7 +60,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -76,7 +74,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   xqtref_t getReturnType(const fo_expr* caller) const;
@@ -93,7 +90,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -107,7 +104,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -122,7 +118,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -137,7 +132,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -152,7 +147,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_other_diagnostics.h'
--- src/functions/pregenerated/func_other_diagnostics.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_other_diagnostics.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -63,7 +62,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }

=== modified file 'src/functions/pregenerated/func_parse_fragment.h'
--- src/functions/pregenerated/func_parse_fragment.h	2013-03-06 07:39:18 +0000
+++ src/functions/pregenerated/func_parse_fragment.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -63,7 +62,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -78,7 +76,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   bool accessesDynCtx() const { return true; }

=== modified file 'src/functions/pregenerated/func_parsing_and_serializing.h'
--- src/functions/pregenerated/func_parsing_and_serializing.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_parsing_and_serializing.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   bool accessesDynCtx() const { return true; }
@@ -65,7 +65,8 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    addAnnotation(AnnotationInternal::zann_explores_json);
   }
 
   bool accessesDynCtx() const { return true; }

=== modified file 'src/functions/pregenerated/func_qnames.h'
--- src/functions/pregenerated/func_qnames.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_qnames.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 1; }
@@ -63,7 +62,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -78,7 +76,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -93,7 +90,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -108,7 +104,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -123,7 +118,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -138,7 +132,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return producer == 1; }
@@ -155,7 +148,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }

=== modified file 'src/functions/pregenerated/func_random.h'
--- src/functions/pregenerated/func_random.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_random.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -61,7 +60,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -77,7 +75,6 @@
     function(sig, kind)
   {
 setDeterministic(false);
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_reference.h'
--- src/functions/pregenerated/func_reference.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_reference.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const { return true; }
@@ -63,7 +62,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -78,7 +76,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
@@ -95,7 +92,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_schema.h'
--- src/functions/pregenerated/func_schema.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_schema.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   unsigned short getScriptingKind() const { return UPDATING_EXPR; }
@@ -67,7 +66,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const;
@@ -84,7 +82,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool mustCopyInputNodes(expr* fo, csize producer) const;

=== modified file 'src/functions/pregenerated/func_sctx.h'
--- src/functions/pregenerated/func_sctx.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_sctx.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -61,7 +60,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -76,7 +74,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -91,7 +88,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -106,7 +102,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -121,7 +116,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -136,7 +130,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -151,7 +144,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -166,7 +158,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -181,7 +172,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -196,7 +186,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -211,7 +200,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -226,7 +214,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -241,7 +228,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -256,7 +242,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -271,7 +256,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -286,7 +270,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -301,7 +284,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -316,7 +298,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -331,7 +312,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -346,7 +326,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -361,7 +340,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -376,7 +354,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -391,7 +368,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -406,7 +382,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_sequences.h'
--- src/functions/pregenerated/func_sequences.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_sequences.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   xqtref_t getReturnType(const fo_expr* caller) const;
@@ -69,7 +68,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -84,7 +82,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
@@ -105,7 +102,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
@@ -126,7 +122,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   xqtref_t getReturnType(const fo_expr* caller) const;
@@ -147,7 +142,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   xqtref_t getReturnType(const fo_expr* caller) const;
@@ -170,7 +164,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   xqtref_t getReturnType(const fo_expr* caller) const;
@@ -197,7 +190,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   xqtref_t getReturnType(const fo_expr* caller) const;
@@ -222,7 +214,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   xqtref_t getReturnType(const fo_expr* caller) const;
@@ -247,7 +238,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   xqtref_t getReturnType(const fo_expr* caller) const;
@@ -270,7 +260,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   xqtref_t getReturnType(const fo_expr* caller) const;
@@ -293,7 +282,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   xqtref_t getReturnType(const fo_expr* caller) const;
@@ -314,7 +302,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   xqtref_t getReturnType(const fo_expr* caller) const;
@@ -343,7 +330,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -362,7 +348,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
@@ -381,7 +366,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
@@ -398,7 +382,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool specializable() const { return true; }
@@ -420,7 +403,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
@@ -437,7 +419,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
@@ -454,7 +435,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
@@ -471,7 +451,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
@@ -488,7 +467,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -503,7 +481,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   FunctionConsts::AnnotationValue producesDistinctNodes() const 
@@ -534,7 +511,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   FunctionConsts::AnnotationValue producesDistinctNodes() const 
@@ -565,7 +541,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   FunctionConsts::AnnotationValue producesDistinctNodes() const 
@@ -596,7 +571,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool accessesDynCtx() const { return true; }
@@ -615,7 +589,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -630,7 +603,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -645,7 +618,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -660,7 +633,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -675,7 +648,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -690,7 +663,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_strings.h'
--- src/functions/pregenerated/func_strings.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_strings.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -61,7 +60,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -76,7 +74,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -91,7 +88,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -106,7 +102,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   BoolAnnotationValue ignoresSortedNodes(expr* fo, csize producer) const;
@@ -125,7 +120,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -139,7 +134,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -154,7 +148,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   bool specializable() const { return true; }
@@ -174,7 +167,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -189,7 +181,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -204,7 +195,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -219,7 +209,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -234,7 +223,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -249,7 +237,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -264,7 +251,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -279,7 +265,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -294,7 +279,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -309,7 +293,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -324,7 +307,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -339,7 +321,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -354,7 +335,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -369,7 +349,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -384,7 +363,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -399,7 +377,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -414,7 +391,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -429,7 +405,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -444,7 +419,7 @@
     : 
     function(sig, kind)
   {
-theXQueryVersion = StaticContextConsts::xquery_version_3_0;
+    theXQueryVersion = StaticContextConsts::xquery_version_3_0;
   }
 
   CODEGEN_DECL();
@@ -459,7 +434,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -474,7 +448,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -489,7 +462,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_uris.h'
--- src/functions/pregenerated/func_uris.h	2013-04-12 21:25:35 +0000
+++ src/functions/pregenerated/func_uris.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -61,7 +60,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -76,7 +74,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/functions/pregenerated/func_xqdoc.h'
--- src/functions/pregenerated/func_xqdoc.h	2013-03-05 23:11:50 +0000
+++ src/functions/pregenerated/func_xqdoc.h	2013-07-04 13:34:33 +0000
@@ -46,7 +46,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();
@@ -61,7 +60,6 @@
     : 
     function(sig, kind)
   {
-
   }
 
   CODEGEN_DECL();

=== modified file 'src/runtime/collections/collections_impl.cpp'
--- src/runtime/collections/collections_impl.cpp	2013-05-02 18:34:27 +0000
+++ src/runtime/collections/collections_impl.cpp	2013-07-04 13:34:33 +0000
@@ -61,8 +61,9 @@
     const static_context* sctx,
     const store::Item_t& name,
     const QueryLoc& loc,
-    bool dynamic,
-    store::Collection_t& coll)
+    bool dynamic,    
+    store::Collection_t& coll,
+    store::Item_t dataguide = NULL)
 {
   const StaticallyKnownCollection* collectionDecl = sctx->lookup_collection(name);
 
@@ -72,7 +73,7 @@
     ERROR_PARAMS(name->getStringValue()));
   }
 
-  coll = GENV_STORE.getCollection(name, dynamic);
+  coll = GENV_STORE.getCollection(name, dynamic, dataguide);
 
   if (coll == NULL)
   {
@@ -291,7 +292,7 @@
 
   consumeNext(name, theChildren[0].getp(), planState);
 
-  (void)getCollection(theSctx, name, loc, theIsDynamic, collection);
+  (void)getCollection(theSctx, name, loc, theIsDynamic, collection, theDataguide);
 
   if (theChildren.size() == 1)
   {

=== modified file 'src/runtime/collections/pregenerated/collections.cpp'
--- src/runtime/collections/pregenerated/collections.cpp	2013-03-05 23:11:50 +0000
+++ src/runtime/collections/pregenerated/collections.cpp	2013-07-04 13:34:33 +0000
@@ -194,6 +194,7 @@
   (NaryBaseIterator<ZorbaCollectionIterator, ZorbaCollectionIteratorState>*)this);
 
     ar & theIsDynamic;
+    ar & theDataguide;
 }
 
 

=== modified file 'src/runtime/collections/pregenerated/collections.h'
--- src/runtime/collections/pregenerated/collections.h	2013-03-24 20:40:03 +0000
+++ src/runtime/collections/pregenerated/collections.h	2013-07-04 13:34:33 +0000
@@ -266,6 +266,7 @@
 { 
 protected:
   bool theIsDynamic; //
+  store::Item_t theDataguide; //
 public:
   SERIALIZABLE_CLASS(ZorbaCollectionIterator);
 
@@ -281,13 +282,16 @@
     bool isDynamic)
     : 
     NaryBaseIterator<ZorbaCollectionIterator, ZorbaCollectionIteratorState>(sctx, loc, children),
-    theIsDynamic(isDynamic)
+    theIsDynamic(isDynamic),
+    theDataguide()
   {}
 
   virtual ~ZorbaCollectionIterator();
 
   bool isDynamic() const { return theIsDynamic; }
 
+  void setDataguide(store::Item_t aValue) { theDataguide= aValue; }
+
 public:
   bool isCountOptimizable() const;
   bool count(store::Item_t& result, PlanState& planState) const;

=== modified file 'src/runtime/json/json_loader.cpp'
--- src/runtime/json/json_loader.cpp	2013-06-19 15:35:24 +0000
+++ src/runtime/json/json_loader.cpp	2013-07-04 13:34:33 +0000
@@ -80,10 +80,11 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-loader::loader( istream &is, bool allow_multiple, bool strip_top_level_array ) :
+loader::loader( istream &is, bool allow_multiple, bool strip_top_level_array, const store::Item *aDataguide) :
   parser_( is, allow_multiple ),
   strip_top_level_array_( strip_top_level_array ),
-  stripped_top_level_array_( false )
+  stripped_top_level_array_( false ),
+  dataguide(aDataguide)
 {
 }
 

=== modified file 'src/runtime/json/json_loader.h'
--- src/runtime/json/json_loader.h	2012-12-03 18:29:05 +0000
+++ src/runtime/json/json_loader.h	2013-07-04 13:34:33 +0000
@@ -47,8 +47,10 @@
    * @param strip_top_level_array If \c true, strips the top-level array, if
    * any.
    */
-  loader( std::istream &is, bool allow_multiple = false,
-          bool strip_top_level_array = false );
+  loader( std::istream &is, 
+          bool allow_multiple = false,
+          bool strip_top_level_array = false,
+          const store::Item* aDataguide = NULL);
 
   /**
    * Destroys this %loader.
@@ -123,6 +125,7 @@
   parser parser_;
   bool const strip_top_level_array_;
   bool stripped_top_level_array_;
+  const store::Item* dataguide;
 };
 
 ///////////////////////////////////////////////////////////////////////////////

=== modified file 'src/runtime/json/jsoniq_functions_impl.cpp'
--- src/runtime/json/jsoniq_functions_impl.cpp	2013-06-18 18:55:33 +0000
+++ src/runtime/json/jsoniq_functions_impl.cpp	2013-07-04 13:34:33 +0000
@@ -863,7 +863,7 @@
     }
 
     state->loader_ = new json::loader(
-      *state->theInputStream, true, lStripTopLevelArray
+      *state->theInputStream, true, lStripTopLevelArray, theDataguide
     );
 
     if ( state->theInput == NULL && theRelativeLocation ) {

=== modified file 'src/runtime/json/pregenerated/jsoniq_functions.cpp'
--- src/runtime/json/pregenerated/jsoniq_functions.cpp	2013-06-18 18:55:33 +0000
+++ src/runtime/json/pregenerated/jsoniq_functions.cpp	2013-07-04 13:34:33 +0000
@@ -121,6 +121,7 @@
   (NaryBaseIterator<JSONParseIterator, JSONParseIteratorState>*)this);
 
     ar & theRelativeLocation;
+    ar & theDataguide;
 }
 
 

=== modified file 'src/runtime/json/pregenerated/jsoniq_functions.h'
--- src/runtime/json/pregenerated/jsoniq_functions.h	2013-06-18 18:55:33 +0000
+++ src/runtime/json/pregenerated/jsoniq_functions.h	2013-07-04 13:34:33 +0000
@@ -163,6 +163,7 @@
 { 
 protected:
   QueryLoc theRelativeLocation; //
+  store::Item_t theDataguide; //
 public:
   SERIALIZABLE_CLASS(JSONParseIterator);
 
@@ -178,11 +179,14 @@
     QueryLoc aRelativeLocation)
     : 
     NaryBaseIterator<JSONParseIterator, JSONParseIteratorState>(sctx, loc, children),
-    theRelativeLocation(aRelativeLocation)
+    theRelativeLocation(aRelativeLocation),
+    theDataguide()
   {}
 
   virtual ~JSONParseIterator();
 
+  void setDataguide(store::Item_t aValue) { theDataguide= aValue; }
+
 public:
   bool processBooleanOption(const store::Item_t& options, char const* option_name, bool* option_value) const;
   void accept(PlanIterVisitor& v) const;

=== modified file 'src/runtime/spec/codegen-h.xq'
--- src/runtime/spec/codegen-h.xq	2013-02-07 17:24:36 +0000
+++ src/runtime/spec/codegen-h.xq	2013-07-04 13:34:33 +0000
@@ -89,6 +89,12 @@
                                  then 
                                    "setDeterministic(false);&#xA;"
                                  else ""
+    let $annotations := string-join(
+                          for $a in $function//zorba:annotation
+                          return concat($gen:indent, $gen:indent, "addAnnotation(AnnotationInternal::", $a, ");", $gen:newline),
+                          '')
+    let $funcVersionStr := if ($funcVersion eq "") then ""
+                           else concat($gen:indent, $gen:indent, $funcVersion, $gen:newline)
     return 
       concat($name, '(const signature&amp; sig, FunctionConsts::FunctionKind kind)',
              $gen:newline, $gen:indent,
@@ -96,8 +102,12 @@
              $gen:newline, $gen:indent, $gen:indent,
              local:base-class($function), 
              '(sig, kind)',
-             $gen:newline, $gen:indent,
-             '{&#xA;', $setNoneDeterministic, $funcVersion, '&#xA;', $gen:indent, '}'),
+             $gen:newline, 
+             $gen:indent, '{', $gen:newline,
+               $setNoneDeterministic, 
+               $funcVersionStr,
+               $annotations,
+             $gen:indent, '}'),
   
   $gen:newline,
         

=== modified file 'src/runtime/spec/collections/collections.xml'
--- src/runtime/spec/collections/collections.xml	2013-04-02 22:54:20 +0000
+++ src/runtime/spec/collections/collections.xml	2013-07-04 13:34:33 +0000
@@ -12,7 +12,7 @@
   xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
 
 <zorba:source>
-    <zorba:include  form="Quoted">store/api/iterator.h</zorba:include>
+    <zorba:include form="Quoted">store/api/iterator.h</zorba:include>
 </zorba:source>
 
 <zorba:header>
@@ -306,6 +306,7 @@
     </zorba:constructor>
 
     <zorba:member type="bool" name="theIsDynamic" getterName="isDynamic"/>
+    <zorba:member type="store::Item_t" name="theDataguide" setterName="setDataguide"/>
 
     <zorba:method const="true" name="isCountOptimizable" return="bool" />
     
@@ -405,6 +406,7 @@
     </zorba:description>
 
     <zorba:function generateCodegen="false">
+      <zorba:annotation>zann_explores_json</zorba:annotation>
 
       <zorba:signature localname="insert-nodes" prefix="static-collections-dml">
         <zorba:param>xs:QName</zorba:param>
@@ -461,7 +463,8 @@
     </zorba:description>
 
     <zorba:function generateCodegen="false">
-
+      <zorba:annotation>zann_explores_json</zorba:annotation>
+      
       <zorba:signature localname="insert-nodes-first" prefix="static-collections-dml">
         <zorba:param>xs:QName</zorba:param>
         <zorba:param>node()*</zorba:param>
@@ -522,6 +525,7 @@
     </zorba:description>
 
     <zorba:function generateCodegen="false">
+      <zorba:annotation>zann_explores_json</zorba:annotation>
 
       <zorba:signature localname="insert-nodes-last" prefix="static-collections-dml">
         <zorba:param>xs:QName</zorba:param>
@@ -582,6 +586,7 @@
     </zorba:description>
 
     <zorba:function generateCodegen="false">
+      <zorba:annotation>zann_explores_json</zorba:annotation>
 
       <zorba:signature localname="insert-nodes-before" prefix="static-collections-dml">
         <zorba:param>xs:QName</zorba:param>
@@ -646,7 +651,8 @@
     </zorba:description>
 
     <zorba:function generateCodegen="false">
-
+      <zorba:annotation>zann_explores_json</zorba:annotation>
+      
       <zorba:signature localname="insert-nodes-after" prefix="static-collections-dml">
         <zorba:param>xs:QName</zorba:param>
         <zorba:param>node()</zorba:param>
@@ -712,6 +718,7 @@
     </zorba:description>
 
     <zorba:function generateCodegen="false">
+      <zorba:annotation>zann_explores_json</zorba:annotation>
 
       <zorba:signature localname="apply-insert-nodes" prefix="static-collections-dml">
         <zorba:param>xs:QName</zorba:param>
@@ -776,6 +783,7 @@
     </zorba:description>
 
     <zorba:function generateCodegen="false">
+      <zorba:annotation>zann_explores_json</zorba:annotation>
 
       <zorba:signature localname="apply-insert-nodes-first" 
                        prefix="static-collections-dml">
@@ -846,6 +854,7 @@
     </zorba:description>
 
     <zorba:function generateCodegen="false">
+      <zorba:annotation>zann_explores_json</zorba:annotation>
 
       <zorba:signature localname="apply-insert-nodes-last" 
                        prefix="static-collections-dml">
@@ -916,6 +925,7 @@
     </zorba:description>
 
     <zorba:function generateCodegen="false">
+      <zorba:annotation>zann_explores_json</zorba:annotation>
 
       <zorba:signature localname="apply-insert-nodes-before" 
                        prefix="static-collections-dml">
@@ -990,6 +1000,7 @@
     </zorba:description>
 
     <zorba:function generateCodegen="false">
+      <zorba:annotation>zann_explores_json</zorba:annotation>
 
       <zorba:signature localname="apply-insert-nodes-after" 
                        prefix="static-collections-dml">
@@ -1271,6 +1282,7 @@
     </zorba:description>
     
     <zorba:function generateCodegen="false">
+      <zorba:annotation>zann_explores_json</zorba:annotation>
       
       <zorba:signature localname="edit" prefix="static-collections-dml">
         <zorba:param>structured-item()</zorba:param>

=== modified file 'src/runtime/spec/json/jsoniq_functions.xml'
--- src/runtime/spec/json/jsoniq_functions.xml	2013-06-18 18:55:33 +0000
+++ src/runtime/spec/json/jsoniq_functions.xml	2013-07-04 13:34:33 +0000
@@ -92,6 +92,7 @@
 <zorba:iterator name="JSONEncodeForRoundtripIterator">
 
   <zorba:function isDeterministic="true">
+    <zorba:annotation>zann_explores_json</zorba:annotation>
 
     <zorba:signature localname="encode-for-roundtrip" prefix="fn-jsoniq">
       <zorba:param>item()*</zorba:param>
@@ -188,6 +189,7 @@
   </zorba:constructor>
 
   <zorba:member type="QueryLoc" name="theRelativeLocation" />
+  <zorba:member type="store::Item_t" name="theDataguide" setterName="setDataguide"/>
 
   <zorba:method return="bool" name="processBooleanOption" const="true">
     <zorba:param type="const store::Item_t&amp;" name="options"/>
@@ -273,6 +275,8 @@
 
   <zorba:function isDeterministic="true"
                   generateCodegen="false">
+                  
+    <zorba:annotation>zann_explores_json</zorba:annotation>
 
     <zorba:signature localname="keys" prefix="fn-jsoniq">
       <zorba:param>item()*</zorba:param>
@@ -361,6 +365,10 @@
 <zorba:iterator name="JSONObjectProjectIterator" arity="binary">
 
   <zorba:function isDeterministic="true">
+    <!-- TODO: project() could be used for document projection if the second
+         parameter is all consts. If this is done, this annotation should be
+         removed -->
+    <zorba:annotation>zann_explores_json</zorba:annotation>
 
     <zorba:signature localname="project" prefix="fn-jsoniq">
       <zorba:param>object()</zorba:param>
@@ -475,6 +483,8 @@
 <zorba:iterator name="JSONArraySizeIterator" arity="unary">
 
   <zorba:function isDeterministic="true">
+    <zorba:annotation>zann_explores_json</zorba:annotation>
+    
     <zorba:signature localname="size" prefix="fn-jsoniq">
       <zorba:param>array()</zorba:param>
       <zorba:output>xs:integer</zorba:output>

=== modified file 'src/runtime/spec/parsing_and_serializing/parsing_and_serializing.xml'
--- src/runtime/spec/parsing_and_serializing/parsing_and_serializing.xml	2013-02-07 17:24:36 +0000
+++ src/runtime/spec/parsing_and_serializing/parsing_and_serializing.xml	2013-07-04 13:34:33 +0000
@@ -47,6 +47,7 @@
     <zorba:description author="Zorba Team">fn:serialize</zorba:description>
 
     <zorba:function>
+      <zorba:annotation>zann_explores_json</zorba:annotation>
 
       <zorba:signature localname="serialize" prefix="fn" version="3.0">
         <zorba:param>item()*</zorba:param>

=== modified file 'src/store/api/store.h'
--- src/store/api/store.h	2013-02-07 17:24:36 +0000
+++ src/store/api/store.h	2013-07-04 13:34:33 +0000
@@ -259,10 +259,12 @@
    *
    * @param QName the name of the collection
    * @param bool whether the collection searched is a dynamic or static collection
+   * @param dataguide the dataguie to be used for document projection and query 
+   *        push-down. Pass NULL if no dataguide is available
    * @return handle object of the collection. Returns NULL if the collection
    *         does not exist
    */
-  virtual Collection_t getCollection(const Item* name, bool isDynamic) = 0;
+  virtual Collection_t getCollection(const Item* name, bool isDynamic, const Item* dataguide = NULL) = 0;
 
   /** 
    * Returns an iterator that lists the names of all the available collections.

=== modified file 'src/store/naive/json_items.cpp'
--- src/store/naive/json_items.cpp	2013-06-05 00:37:35 +0000
+++ src/store/naive/json_items.cpp	2013-07-04 13:34:33 +0000
@@ -696,8 +696,19 @@
 zstring SimpleJSONObject::show() const
 {
   std::stringstream str;
-  str << "{ }";
-
+  str << "{";
+  
+  for (unsigned int i=0; i<thePairs.size(); i++)  
+  {
+    str << thePairs[i].first->getStringValue() << ": " ;
+    if (thePairs[i].second->isAtomic())
+      str << "\"" << thePairs[i].second->getStringValue() << "\"";
+    else
+      str << thePairs[i].second->show();        
+    str << (i<thePairs.size()-1 ? ", " : "");
+  }
+  
+  str << "}";  
   return str.str();
 }
 

=== modified file 'src/store/naive/store.cpp'
--- src/store/naive/store.cpp	2013-06-15 02:57:08 +0000
+++ src/store/naive/store.cpp	2013-07-04 13:34:33 +0000
@@ -441,7 +441,8 @@
 ********************************************************************************/
 store::Collection_t Store::getCollection(
     const store::Item* name,
-    bool isDynamic)
+    bool isDynamic, 
+    const store::Item *dataguide)
 {
   if (name == NULL)
     return NULL;

=== modified file 'src/store/naive/store.h'
--- src/store/naive/store.h	2013-06-15 02:57:08 +0000
+++ src/store/naive/store.h	2013-07-04 13:34:33 +0000
@@ -279,7 +279,7 @@
 
   virtual void deleteCollection(const store::Item* name, bool isDynamic);
 
-  virtual store::Collection_t getCollection(const store::Item* name, bool isDynamic);
+  virtual store::Collection_t getCollection(const store::Item* name, bool isDynamic, const store::Item* dataguide = NULL);
 
   virtual store::Iterator_t listCollectionNames(bool dynamic);
 

=== modified file 'src/system/globalenv.cpp'
--- src/system/globalenv.cpp	2013-05-13 08:45:43 +0000
+++ src/system/globalenv.cpp	2013-07-04 13:34:33 +0000
@@ -89,10 +89,10 @@
   RCHelper::addReference(m_globalEnv->theRootStaticContext);
   m_globalEnv->theRootStaticContext->init();
 
+  AnnotationInternal::createBuiltIn();
+  
   BuiltinFunctionLibrary::create(m_globalEnv->theRootStaticContext);
 
-  AnnotationInternal::createBuiltIn();
-
 #ifdef ZORBA_XQUERYX
   //libxml2 and libxslt are needed
   xmlInitMemory();

=== modified file 'src/system/zorba_properties.h'
--- src/system/zorba_properties.h	2013-03-22 05:41:14 +0000
+++ src/system/zorba_properties.h	2013-07-04 13:34:33 +0000
@@ -38,12 +38,12 @@
       "--print-normalized", "--print-optimized", "--print-iterator-tree",
       "--print-item-flow", "--print-static-types", "--dump-lib",
       "--stable-iterator-ids", "--no-tree-ids", "--print-intermediate-opt",
-      "--print-locations", "--force-gflwor", "--reorder-globals",
+      "--print-locations", "--print-dataguide", "--force-gflwor", "--reorder-globals",
       "--specialize-num", "--specialize-cmp", "--inline-udf", "--loop-hoisting",
       "--infer-joins", "--no-copy-optim", "--serialize-only-query",
       "--trace-translator", "--trace-codegen", "--trace-fulltext", "--debug",
       "--compile-only", "--lib-module", "--tz", "--external-var", "--serializer-param",
-      "--iter-plan-test", "--dot-plan-file", "--plan", "jsoniq", "--max-udf-call-depth",
+      "--iter-plan-test", "--dot-plan-file", "--plan", "--jsoniq", "--max-udf-call-depth",
       "--CLASSPATH", NULL };
 
     return result;
@@ -72,6 +72,7 @@
   bool theNoTreeIds;
   bool thePrintIntermediateOpt;
   bool thePrintLocations;
+  bool thePrintDataguide;
   bool theForceGflwor;
   bool theReorderGlobals;
   bool theSpecializeNum;
@@ -120,6 +121,7 @@
     theNoTreeIds = false;
     thePrintIntermediateOpt = false;
     thePrintLocations = false;
+    thePrintDataguide = false;
     theForceGflwor = false;
     theReorderGlobals = true;
     theSpecializeNum = true;
@@ -166,6 +168,7 @@
   const bool &noTreeIds () const { return theNoTreeIds; }
   const bool &printIntermediateOpt () const { return thePrintIntermediateOpt; }
   const bool &printLocations () const { return thePrintLocations; }
+  const bool &printDataguide () const { return thePrintDataguide; }
   const bool &forceGflwor () const { return theForceGflwor; }
   const bool &reorderGlobals () const { return theReorderGlobals; }
   const bool &specializeNum () const { return theSpecializeNum; }
@@ -191,6 +194,8 @@
   const bool& jsoniqParser() const { return theJsoniqParser; }
   const uint32_t &maxUdfCallDepth () const { return theMaxUdfCallDepth; }
   const std::string &CLASSPATH () const { return theCLASSPATH; }
+  
+  void setPrintDataguide() { thePrintDataguide = true; }
 
   std::string load_argv (int argc, const char **argv) 
   {
@@ -289,6 +294,9 @@
       else if (strcmp (*argv, "--print-locations") == 0) {
         thePrintLocations = true;
       }
+      else if (strcmp (*argv, "--print-dataguide") == 0) {
+        thePrintDataguide = true;
+      }
       else if (strcmp (*argv, "--force-gflwor") == 0) {
         theForceGflwor = true;
       }
@@ -479,6 +487,7 @@
 "--no-tree-ids\nsuppress ids and locations from compiler tree dumps\n\n"
 "--print-intermediate-opt\nprint intermediate optimizations\n\n"
 "--print-locations\nprint parser locations for compiler expressions\n\n"
+"--print-dataguide\nprint the JSON dataguides\n\n"
 "--force-gflwor\nforce compiler to generate GFLWOR iterators\n\n"
 "--reorder-globals\nreorder global variables (1=enabled (default), 0=off)\n\n"
 "--specialize-num\nspecialize numerics (1=enabled (default), 0=off)\n\n"
@@ -501,6 +510,7 @@
 "--iter-plan-test\nrun as iterator plan test\n\n"
 "--dot-plan-file\ngenerate the dot iterator plan\n\n"
 "--plan\ntest plan serialization, i.e. save the plan, load it back and then execute it\n\n"
+"--jsoniq, -j\nuse the JSONiq grammar to parse the query\n\n"
 "--max-udf-call-depth\nmaximum stack depth of udf function calls\n\n"
 "--CLASSPATH\nJVM classpath to be used by modules using Java implementations\n\n"
 ;

=== modified file 'src/system/zorba_properties.txt'
--- src/system/zorba_properties.txt	2013-03-22 05:41:14 +0000
+++ src/system/zorba_properties.txt	2013-07-04 13:34:33 +0000
@@ -16,6 +16,7 @@
       ("print-iterator-tree,i", "print the iterator tree")
       ("print-item-flow,f", "show items produced by all iterators")
       ("print-static-types", po::value<bool> ()->default_value (true), "print static type inference")
+      ("print-dataguide", "print JSON dataguides")
       ("dump-lib", "dump function library")
       ("stable-iterator-ids", "print the iterator plan with stable ids")
       ("no-tree-ids", "suppress ids and locations from compiler tree dumps")

=== modified file 'test/driver/specification.h'
--- test/driver/specification.h	2013-05-16 08:22:46 +0000
+++ test/driver/specification.h	2013-07-04 13:34:33 +0000
@@ -55,7 +55,8 @@
     theInline(false),
     theComparisonMethod("Fragment"),
     theEnableDtd(false),
-    theEnableUriTestResolver(false)
+    theEnableUriTestResolver(false),
+    thePrintDataguide(false)
 #ifndef ZORBA_NO_FULL_TEXT
     ,
     theStopWordsMapper(zorba::EntityData::STOP_WORDS),
@@ -81,6 +82,7 @@
   bool                     theUseIndent;
   bool                     theEnableDtd;
   bool                     theEnableUriTestResolver;
+  bool                     thePrintDataguide;
 #ifndef ZORBA_NO_FULL_TEXT
   zorba::OneToOneURIMapper theStopWordsMapper;
   zorba::OneToOneURIMapper theThesaurusMapper;
@@ -229,6 +231,10 @@
   bool getEnableUriTestResolver() const {
     return theEnableUriTestResolver;
   }
+  
+  bool getPrintDataguide() const {
+    return thePrintDataguide;
+  }
 
   void tokenize(const std::string& str,
                 std::vector<std::string>& tokens,
@@ -305,7 +311,8 @@
               (str.find("DefaultCollection:")!=std::string::npos) ||
               (str.find("Error:")!=std::string::npos) || 
               (str.find("Date:")!=std::string::npos) || 
-              (str.find("Timezone:")!=std::string::npos));
+              (str.find("Timezone:")!=std::string::npos) || 
+              (str.find("Dataguide:")!=std::string::npos));
     return c;
   }
 
@@ -491,6 +498,12 @@
           if(lIter == tokens.end() ) { return false; }
           setTimezone(lIter->begin(), lIter->end());
         }
+        else if ( *lIter == "Dataguide:" ) 
+        {
+          ++lIter;
+          if(lIter == tokens.end() ) { return false; }
+          thePrintDataguide = true;
+        }
         else
         {
           break;

=== modified file 'test/driver/testdriver.cpp'
--- test/driver/testdriver.cpp	2013-06-15 02:57:08 +0000
+++ test/driver/testdriver.cpp	2013-07-04 13:34:33 +0000
@@ -248,6 +248,10 @@
     // If command-line argument --module-path passed, set up module paths.
     setModulePaths(lModulePath, lContext);
 
+    // If dataguide printing is requested, enable it in the properties
+    if (lSpec.getPrintDataguide())
+      zorba::Properties::instance()->setPrintDataguide();
+            
     // Get the pathnames of the reference-result files found in the .spec
     // file (if any).
     std::vector<std::string> lRefFiles;
@@ -325,8 +329,22 @@
     bool lJSONiqMode = 
     (lQueryFile.rfind(".jq") == lQueryFile.size() - 3);
 
-    if (lJSONiqMode) lContext->setJSONiqVersion(zorba::jsoniq_version_1_0);
-    lQuery->compile(lQueryString.c_str(), lContext, getCompilerHints());
+    if (lJSONiqMode) 
+      lContext->setJSONiqVersion(zorba::jsoniq_version_1_0);
+    
+    // Create and open the results file here so that the dataguide tests can use it to output projection information
+    std::ofstream lResFileStream(lResultFile.c_str());
+    assert (lResFileStream.good());
+    std::streambuf *coutbuf = std::cout.rdbuf(); //save old buf
+    
+    if (lSpec.getPrintDataguide())
+      std::cout.rdbuf(lResFileStream.rdbuf());
+    
+    lQuery->compile(lQueryString.c_str(), lContext, getCompilerHints()); 
+    
+    // reset cout to standard output
+    if (lSpec.getPrintDataguide())
+      std::cout.rdbuf(coutbuf);
 
     errors = -1;
     if ( errHandler.errors() )
@@ -422,8 +440,7 @@
       errors = -1;
       {
         // serialize xml/txt
-        std::ofstream lResFileStream(lResultFile.c_str());
-        assert (lResFileStream.good());
+        
         // QQQ all this code should be in testdriver_common and used by
         // testdriver_mt as well
         // Initialize default serialization method
@@ -441,6 +458,8 @@
         }
         
         lQuery->execute(lResFileStream, &lSerOptions);
+        
+        lResFileStream.close();
       }
 
       // Stopwatch ends here

=== added directory 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide'
=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-01.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-01.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 16:13: {category: {name: "*"}}
+food

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-02.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-02.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,3 @@
+Dataguide for function collection() at 25:49: {product: {price: "*"}, category: {name: "*"}}
+Dataguide for function collection() at 25:14: {product: {price: "*"}, category: {name: "*"}}
+100 150 food

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-03.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-03.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,3 @@
+Dataguide for function collection() at 37:49: {product: "*"}
+Dataguide for function collection() at 37:14: {product: "*"}
+broiler toaster toaster toaster blender blender socks socks shirt broiler toaster toaster toaster blender blender socks socks shirt

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-04.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-04.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-04.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 18:13: {category: {category2: "*"}}
+value3{ "category3" : "value3" }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-05.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-05.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-05.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 20:13: {category: {category2: {category3: "*"}}}
+{ "category3" : "value3" }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-06.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-06.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-06.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 21:13: {category: {category2: {category3: "*"}}}
+value3

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-07.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-07.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-07.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 22:13: {category: {category2: {category3: "*"}, category4: "*"}}
+value4

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-08.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-08.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-08.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 21:13: {category: {category2: {category3: "*"}, category3: "*"}}
+foo

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-09.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-09.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-09.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,3 @@
+Dataguide for function collection() at 28:13: {category: "*"}
+Dataguide for function collection() at 29:14: {product: "*"}
+{ "name" : "food" }{ "name" : "toaster", "price" : "150" }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-10.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-10.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-10.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 21:13: {category1: {category3: "*"}, category2: {category3: "*"}}
+{ "category4" : "value4" }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-11.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-11.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-11.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 21:13: {category: {category2: "*"}, category3: "*"}
+{ "category3" : "value3" }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-12.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-12.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-12.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+{ "category2" : { "category3" : "value3" } }{ "product" : { "name" : "broiler", "price" : 100 }, "category" : { "category2" : { "category3" : "value3" } } }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-13.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-13.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-13.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 26:13: {category1: "*"}
+{ "name" : "broiler", "price" : 200 } broiler

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-14.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-14.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-14.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 24:13: {category1: "*"}
+name broiler price broiler

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-15.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-15.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-15.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 23:13: {category1: {price: "*"}}
+100 200 300 200

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-16.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-16.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-16.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 24:13: {category1: {price: {test: "*"}}, category2: "*"}
+100 200 300{ "name" : "food", "price" : 200 }{ "name" : "food", "price" : 200 }{ "name" : "food", "price" : 200 }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-17.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-17.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-17.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 25:13: {category1: {price: "*"}, category2: "*"}
+100 200 300{ "name" : "food", "price" : 200 }{ "name" : "food", "price" : 200 }{ "name" : "food", "price" : 200 }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-18.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-18.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-18.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 29:13: {category: {category1: "*"}}
+{ "category2" : "value3" }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-19.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-19.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-19.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 29:13: {category: {category1: {category2: "*"}}}
+value3

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-20.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-20.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-20.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 34:13: {category2: "*", category: {category1: "*"}}
+{ "category2" : "value3" }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-21.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-21.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-21.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 30:13: {category2: "*", category: {category1: "*"}}
+{ "category2" : "value3" }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-22.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-22.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-22.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 35:13: {category: {category1: "*"}, category2: "*"}
+{ "category2" : "value3" }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-23.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-23.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-23.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 36:13: {category: {category1: "*"}, category2: "*"}
+{ "category2" : "value3" }

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-24.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-24.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/dataguide/dataguide-24.xml.res	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Dataguide for function collection() at 29:13: {category: "*"}
+{ "category" : { "category" : "value" } }{ "category" : "value" }value Done.

=== added directory 'test/rbkt/Queries/zorba/jsoniq/dataguide'
=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-01.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-01.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-01.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,19 @@
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "name" : "food" } 
+    }
+  )
+);
+
+let $col := dml:collection(xs:QName("sales"))
+return {
+         $col.category.name
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-01.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-01.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-01.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,2 @@
+Serialization: omit-xml-declaration=yes
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-02.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-02.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-02.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,29 @@
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "name" : "food" } 
+    }
+  )
+);
+
+ddl:create(xs:QName("sales2"));
+dml:insert-last(xs:QName("sales2"),
+  ( { "product" : { "name" : "toaster", 
+                    "price" : "150"                    
+                  } 
+    }
+  )
+);
+
+let $col := (dml:collection(xs:QName("sales")), dml:collection(xs:QName("sales2"))  )
+return {
+         $col.product.price,
+         $col.category.name
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-02.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-02.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-02.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-03.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-03.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-03.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,38 @@
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  (
+    { "product" : "broiler", "store number" : 1, "quantity" : 20  },
+    { "product" : "toaster", "store number" : 2, "quantity" : 100 },
+    { "product" : "toaster", "store number" : 2, "quantity" : 50 },
+    { "product" : "toaster", "store number" : 3, "quantity" : 50 },
+    { "product" : "blender", "store number" : 3, "quantity" : 100 },
+    { "product" : "blender", "store number" : 3, "quantity" : 150 },
+    { "product" : "socks", "store number" : 1, "quantity" : 500 },
+    { "product" : "socks", "store number" : 2, "quantity" : 10 },
+    { "product" : "shirt", "store number" : 3, "quantity" : 10 }
+  )
+);
+
+ddl:create(xs:QName("sales2"));
+dml:insert-last(xs:QName("sales2"),
+  (
+    { "product" : "broiler", "store number" : 1, "quantity" : 20  },
+    { "product" : "toaster", "store number" : 2, "quantity" : 100 },
+    { "product" : "toaster", "store number" : 2, "quantity" : 50 },
+    { "product" : "toaster", "store number" : 3, "quantity" : 50 },
+    { "product" : "blender", "store number" : 3, "quantity" : 100 },
+    { "product" : "blender", "store number" : 3, "quantity" : 150 },
+    { "product" : "socks", "store number" : 1, "quantity" : 500 },
+    { "product" : "socks", "store number" : 2, "quantity" : 10 },
+    { "product" : "shirt", "store number" : 3, "quantity" : 10 }
+  )
+);
+
+
+let $col := (dml:collection(xs:QName("sales")), dml:collection(xs:QName("sales2")))
+return $col."product"

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-03.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-03.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-03.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-04.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-04.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-04.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,22 @@
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "category2" :
+                       { "category3" : "value3" }
+                   } 
+    }
+  )
+);
+
+let $col := dml:collection(xs:QName("sales"))
+return {
+         $col.category.category2.category3,
+         $col.category.category2
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-04.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-04.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-04.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-05.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-05.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-05.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,25 @@
+(:
+  Dataguide for a FLWOR expression that has a where clause.
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "category2" : { "category3" : "value3" }
+                   } 
+    }
+  )
+);
+
+let $col := dml:collection(xs:QName("sales"))
+let $col1 := $col.category 
+where $col1.category2.category3 eq "value3"
+return {
+         $col1.category2
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-05.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-05.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-05.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-06.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-06.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-06.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,26 @@
+(:
+  Dataguide for a FLWOR expression that has a where clause.
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "category2" : { "category3" : "value3" },
+                     "type" : "type1"   
+                   } 
+    }
+  )
+);
+
+let $col := dml:collection(xs:QName("sales"))
+let $col1 := $col.category 
+where $col1.category2.category3 eq "value3"
+return {
+         $col1.category2.category3
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-06.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-06.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-06.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-07.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-07.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-07.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,27 @@
+(:
+  Dataguide for a FLWOR expression that has a where clause.
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "category2" : { "category3" : "value3" },
+                     "type" : "type1",
+                     "category4" : "value4"
+                   } 
+    }
+  )
+);
+
+let $col := dml:collection(xs:QName("sales"))
+let $col1 := $col.category 
+where $col1.category2.category3 eq "value3"
+return {
+         $col1.category4
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-07.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-07.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-07.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-08.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-08.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-08.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,27 @@
+(:
+  Dataguide for a FLWOR expression that has a where clause.
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "category2" : { "category3" : "value3" },
+                     "type" : "type1"   
+                   } 
+    }
+  )
+);
+
+let $col := dml:collection(xs:QName("sales"))
+let $col1 := $col.category 
+where $col1.category2.category3 eq "value3"
+return {
+         $col1.category3,
+         "foo"
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-08.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-08.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-08.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-09.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-09.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-09.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,33 @@
+(:
+  Two dataguides for two collection sources.
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "name" : "food" } 
+    }
+  )
+);
+
+ddl:create(xs:QName("sales2"));
+dml:insert-last(xs:QName("sales2"),
+  ( { "product" : { "name" : "toaster", 
+                    "price" : "150"                    
+                  } 
+    }
+  )
+);
+
+let $col := dml:collection(xs:QName("sales"))
+let $col1 := dml:collection(xs:QName("sales2"))
+return {
+         $col.category,
+         $col1.product
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-09.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-09.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-09.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-10.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-10.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-10.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,27 @@
+(:
+  Dataguide for a object lookup that has two collection sources.
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category1" : { "category3" :
+                       { "category4" : "value4" }
+                   } 
+    }
+  )
+);
+
+let $col := dml:collection(xs:QName("sales"))
+let $col1 := $col.category1
+let $col2 := $col.category2
+let $col3 := ($col1, $col2)
+return {
+         $col3.category3
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-10.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-10.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-10.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-11.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-11.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-11.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,25 @@
+(:
+  Dataguide for two object lookups: the result is the union of the two individual dataguides.
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "category2" :
+                       { "category3" : "value3" }
+                   } 
+    }
+  )
+);
+
+let $col := dml:collection(xs:QName("sales"))
+return {
+         $col.category.category2,
+         $col.category3
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-11.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-11.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-11.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-12.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-12.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-12.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,28 @@
+(:
+  Dataguide when using the eval() function: 
+  invalidate all projection information.
+:)
+jsoniq version "1.0";
+
+import module namespace refl = "http://www.zorba-xquery.com/modules/reflection";;
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "category2" :
+                       { "category3" : "value3" }
+                   } 
+    }
+  )
+);
+
+
+let $col := dml:collection(xs:QName("sales"))
+return {
+         $col.category,
+         refl:eval("$col") 
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-12.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-12.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-12.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-13.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-13.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-13.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,29 @@
+(:
+  Dataguide in combination with fn:serialize(), which
+  performs a deep exploration of JSON objects:
+  the entire object that is serialized must be retrieved.
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "category1" : { "name" : "broiler",
+                      "price" : 200},
+                      
+      "category2" : { "name" : "food",
+                      "price" : 200},
+                      
+      "category3" : { "name" : "beverage",
+                      "price" : 100} 
+    }
+  )
+);
+
+
+let $col := dml:collection(xs:QName("sales"))
+return { serialize($col.category1), 
+         $col.category1.name 
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-13.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-13.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-13.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-14.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-14.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-14.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,29 @@
+(:
+  Dataguide in combination with the jsoniq:keys() function
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "category1" : { "name" : "broiler",
+                      "price" : 200},
+                      
+      "category2" : { "name" : "food",
+                      "price" : 200},
+                      
+      "category3" : { "name" : "beverage",
+                      "price" : 100} 
+    }
+  )
+);
+
+
+let $col := dml:collection(xs:QName("sales"))
+for $var in keys($col.category1)
+return { 
+         $var,
+         $col.category1.name
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-14.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-14.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-14.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-15.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-15.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-15.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,29 @@
+(:
+  Dataguide and group by clauses: simple case
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "category1" : { "name" : "broiler",
+                      "price" : 200},
+                      
+      "category2" : { "name" : "food",
+                      "price" : 200},
+                      
+      "category3" : { "name" : "beverage",
+                      "price" : 100} 
+    }
+  )
+);
+
+let $col := dml:collection(xs:QName("sales"))
+for $p in (100,200,300)
+group by $price := $col.category1.price
+return (
+         $p, 
+         $price
+       )

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-15.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-15.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-15.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-16.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-16.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-16.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,31 @@
+(:
+  Dataguide and group by clauses: 
+  a clause variable in union with a simple object lookup
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "category1" : { "name" : "broiler",
+                      "price" : 200},
+                      
+      "category2" : { "name" : "food",
+                      "price" : 200},
+                      
+      "category3" : { "name" : "beverage",
+                      "price" : 100} 
+    }
+  )
+);
+
+let $col := dml:collection(xs:QName("sales"))
+for $p in (100,200,300)
+group by $price := $col.category1.price
+return (
+         $p, 
+         $price.test,
+         $col.category2
+       )

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-16.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-16.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-16.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-17.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-17.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-17.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,31 @@
+(:
+  Dataguide and group by clauses: 
+  a clause variable that is not referred in the return expression,  
+  in union with a simple object lookup
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "category1" : { "name" : "broiler",
+                      "price" : 200},
+                      
+      "category2" : { "name" : "food",
+                      "price" : 200},
+                      
+      "category3" : { "name" : "beverage",
+                      "price" : 100} 
+    }
+  )
+);
+
+let $col := dml:collection(xs:QName("sales"))
+for $p in (100,200,300)
+group by $price := $col.category1.price
+return (
+         $p, 
+         $col.category2
+       )

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-17.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-17.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-17.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-18.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-18.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-18.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,32 @@
+(:
+  Dataguides and UDFs: 
+  simple case
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+declare function local:nav($var)
+{
+  $var.category.category1
+};
+
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "category1" :
+                       { "category2" : "value3" }
+                   } 
+    }
+  )
+);
+
+
+let $col := dml:collection(xs:QName("sales"))
+return {
+         local:nav($col)
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-18.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-18.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-18.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-19.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-19.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-19.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,32 @@
+(:
+  Dataguide and UDFs: 
+  object lookup both in the main query and in the UDF
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+declare function local:nav($var)
+{
+  $var.category1.category2
+};
+
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "category1" :
+                       { "category2" : "value3" }
+                   } 
+    }
+  )
+);
+
+
+let $col := dml:collection(xs:QName("sales"))
+return {
+         local:nav($col.category)
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-19.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-19.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-19.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-20.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-20.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-20.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,38 @@
+(:
+  Dataguides and UDFs:
+  two UDFs doing object lookup on the same source 
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+declare function local:nav1($var)
+{
+  $var.category2
+};
+
+declare function local:nav2($var)
+{
+  $var.category1
+};
+
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "category1" :
+                       { "category2" : "value3" }
+                   } 
+    }
+  )
+);
+
+
+let $col := dml:collection(xs:QName("sales"))
+return {
+         local:nav1($col),
+         local:nav2($col.category)
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-20.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-20.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-20.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-21.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-21.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-21.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,33 @@
+(: 
+  Dataguide and UDFs:
+  UDF with two parameters that have the same source
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+declare function local:nav($var1, $var2)
+{
+  $var1.category2,
+  $var2.category1
+};
+
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "category1" :
+                       { "category2" : "value3" }
+                   } 
+    }
+  )
+);
+
+
+let $col := dml:collection(xs:QName("sales"))
+return {
+         local:nav($col, $col.category)
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-21.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-21.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-21.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-22.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-22.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-22.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,38 @@
+(:
+  Dataguide and UDFs:
+  two UDFs where the second one invokes the first one
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+declare function local:nav1($var1, $var2)
+{
+  $var1.category2,
+  $var2.category1
+};
+
+declare function local:nav2($var1, $var2)
+{
+  local:nav1($var1, $var2)
+};
+
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "category1" :
+                       { "category2" : "value3" }
+                   } 
+    }
+  )
+);
+
+
+let $col := dml:collection(xs:QName("sales"))
+return {
+         local:nav2($col, $col.category)
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-22.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-22.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-22.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-23.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-23.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-23.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,39 @@
+(:
+  Dataguide and UDFs:
+  two UDFs where the second one invokes the first one, with the order
+  of parameters reversed.
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+declare function local:nav1($var1, $var2)
+{
+  $var1.category1,
+  $var2.category2
+};
+
+declare function local:nav2($var1, $var2)
+{
+  local:nav1($var2, $var1)
+};
+
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "category1" :
+                       { "category2" : "value3" }
+                   } 
+    }
+  )
+);
+
+
+let $col := dml:collection(xs:QName("sales"))
+return {
+         local:nav2($col, $col.category)
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-23.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-23.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-23.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-24.jq'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-24.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-24.jq	2013-07-04 13:34:33 +0000
@@ -0,0 +1,32 @@
+(:
+  Dataguide and UDFs:
+  recursive function -- dataguide past the function call is "*"
+:)
+jsoniq version "1.0";
+
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+declare function local:nav($var)
+{
+  if ($var instance of structured-item())
+  then ($var.category, local:nav($var.category) )
+  else "Done."
+};
+
+
+ddl:create(xs:QName("sales"));
+dml:insert-last(xs:QName("sales"),
+  ( { "product" :  { "name" : "broiler",
+                     "price" : 100 
+                   },
+      "category" : { "category" : { "category" : { "category" : "value" } } }
+    }
+  )
+);
+
+
+let $col := dml:collection(xs:QName("sales"))
+return {
+         local:nav($col.category)
+       }

=== added file 'test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-24.spec'
--- test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-24.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/dataguide/dataguide-24.spec	2013-07-04 13:34:33 +0000
@@ -0,0 +1,1 @@
+Dataguide: print
\ No newline at end of file


Follow ups