Till Westmann has proposed merging 
lp:~zorba-coders/zorba/feature-node-reference-management into lp:zorba.

Requested reviews:
  Matthias Brantner (matthias-brantner)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/feature-node-reference-management/+merge/112660

Add ref:has-node-reference and ref:assign-node-reference to the node reference 
module that can be used to actively manage node references. As node-references 
are usually created on-demand, these functions are not needed for the usual 
lifecycle of node references. Therefore these functions are not part of the 
documentation. 
-- 
https://code.launchpad.net/~zorba-coders/zorba/feature-node-reference-management/+merge/112660
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/functions/pregenerated/func_nodes.cpp'
--- src/functions/pregenerated/func_nodes.cpp	2012-06-28 04:14:03 +0000
+++ src/functions/pregenerated/func_nodes.cpp	2012-06-28 22:02:21 +0000
@@ -41,6 +41,26 @@
   return new NodeReferenceIterator(sctx, loc, argv);
 }
 
+PlanIter_t fn_zorba_ref_has_node_reference::codegen(
+  CompilerCB*,
+  static_context* sctx,
+  const QueryLoc& loc,
+  std::vector<PlanIter_t>& argv,
+  expr& ann) const
+{
+  return new HasNodeReferenceIterator(sctx, loc, argv);
+}
+
+PlanIter_t fn_zorba_ref_assign_node_reference::codegen(
+  CompilerCB*,
+  static_context* sctx,
+  const QueryLoc& loc,
+  std::vector<PlanIter_t>& argv,
+  expr& ann) const
+{
+  return new AssignNodeReferenceIterator(sctx, loc, argv);
+}
+
 PlanIter_t fn_zorba_ref_node_by_reference::codegen(
   CompilerCB*,
   static_context* sctx,
@@ -258,6 +278,31 @@
 
 
       {
+    DECL_WITH_KIND(sctx, fn_zorba_ref_has_node_reference,
+        (createQName("http://www.zorba-xquery.com/modules/node-reference","","has-node-reference";), 
+        GENV_TYPESYSTEM.ANY_NODE_TYPE_ONE, 
+        GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+        FunctionConsts::FN_ZORBA_REF_HAS_NODE_REFERENCE_1);
+
+  }
+
+
+
+
+      {
+    DECL_WITH_KIND(sctx, fn_zorba_ref_assign_node_reference,
+        (createQName("http://www.zorba-xquery.com/modules/node-reference","","assign-node-reference";), 
+        GENV_TYPESYSTEM.ANY_NODE_TYPE_ONE, 
+        GENV_TYPESYSTEM.ANY_URI_TYPE_ONE, 
+        GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE),
+        FunctionConsts::FN_ZORBA_REF_ASSIGN_NODE_REFERENCE_2);
+
+  }
+
+
+
+
+      {
     DECL_WITH_KIND(sctx, fn_zorba_ref_node_by_reference,
         (createQName("http://www.zorba-xquery.com/modules/node-reference","","node-by-reference";), 
         GENV_TYPESYSTEM.ANY_URI_TYPE_ONE, 

=== modified file 'src/functions/pregenerated/func_nodes.h'
--- src/functions/pregenerated/func_nodes.h	2012-06-28 04:14:03 +0000
+++ src/functions/pregenerated/func_nodes.h	2012-06-28 22:02:21 +0000
@@ -55,6 +55,38 @@
 };
 
 
+//fn-zorba-ref:has-node-reference
+class fn_zorba_ref_has_node_reference : public function
+{
+public:
+  fn_zorba_ref_has_node_reference(const signature& sig, FunctionConsts::FunctionKind kind)
+    : 
+    function(sig, kind)
+  {
+
+  }
+
+  CODEGEN_DECL();
+};
+
+
+//fn-zorba-ref:assign-node-reference
+class fn_zorba_ref_assign_node_reference : public function
+{
+public:
+  fn_zorba_ref_assign_node_reference(const signature& sig, FunctionConsts::FunctionKind kind)
+    : 
+    function(sig, kind)
+  {
+
+  }
+
+  unsigned short getScriptingKind() const { return SEQUENTIAL_FUNC_EXPR; }
+
+  CODEGEN_DECL();
+};
+
+
 //fn-zorba-ref:node-by-reference
 class fn_zorba_ref_node_by_reference : public function
 {

=== modified file 'src/functions/pregenerated/function_enum.h'
--- src/functions/pregenerated/function_enum.h	2012-06-28 04:14:03 +0000
+++ src/functions/pregenerated/function_enum.h	2012-06-28 22:02:21 +0000
@@ -288,6 +288,8 @@
   FN_ZORBA_POS_IN_COLLECTION_1,
   FN_ZORBA_POS_IN_SAME_COLLECTION_OF_2,
   FN_ZORBA_REF_NODE_REFERENCE_1,
+  FN_ZORBA_REF_HAS_NODE_REFERENCE_1,
+  FN_ZORBA_REF_ASSIGN_NODE_REFERENCE_2,
   FN_ZORBA_REF_NODE_BY_REFERENCE_1,
   FN_LOCAL_NAME_0,
   FN_LOCAL_NAME_1,

=== modified file 'src/runtime/nodes/nodes_impl.cpp'
--- src/runtime/nodes/nodes_impl.cpp	2012-06-28 19:06:27 +0000
+++ src/runtime/nodes/nodes_impl.cpp	2012-06-28 22:02:21 +0000
@@ -40,8 +40,6 @@
 NodeReferenceIterator::nextImpl(store::Item_t& aResult, PlanState& aPlanState) const
 {
   store::Item_t lNode;
-  store::Item_t lGenerateIdentifier;
-  zstring lNodeId;
 
   PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
@@ -58,6 +56,58 @@
 
 ********************************************************************************/
 bool
+HasNodeReferenceIterator::nextImpl(store::Item_t& aResult, PlanState& aPlanState) const
+{
+  store::Item_t lNode;
+  xs_boolean lHasReference;
+
+  PlanIteratorState* state;
+  DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
+
+  consumeNext(lNode, theChildren[0].getp(), aPlanState);
+
+  lHasReference = GENV_STORE.hasReference(lNode);
+
+  STACK_PUSH(GENV_ITEMFACTORY->createBoolean(aResult, lHasReference), state);
+
+  STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
+AssignNodeReferenceIterator::nextImpl(store::Item_t& aResult, PlanState& aPlanState) const
+{
+  store::Item_t lNode;
+  store::Item_t lUUID;
+  xs_boolean lHaveResult;
+
+  PlanIteratorState* state;
+  DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
+
+  consumeNext(lNode, theChildren[0].getp(), aPlanState);
+  consumeNext(lUUID, theChildren[1].getp(), aPlanState);
+  try
+  {
+    lHaveResult = GENV_STORE.assignReference(lNode, lUUID->getStringValue());
+  }
+  catch (ZorbaException& e)
+  {
+    set_source( e, loc );
+    throw;
+  }
+  STACK_PUSH(GENV_ITEMFACTORY->createBoolean(aResult, lHaveResult), state);
+
+  STACK_END (state);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+bool
 NodeByReferenceIterator::nextImpl(store::Item_t& result, PlanState& planState) const
 {
   store::Item_t lUUID;

=== modified file 'src/runtime/nodes/pregenerated/nodes.cpp'
--- src/runtime/nodes/pregenerated/nodes.cpp	2012-06-28 04:14:03 +0000
+++ src/runtime/nodes/pregenerated/nodes.cpp	2012-06-28 22:02:21 +0000
@@ -60,6 +60,62 @@
 // </NodeReferenceIterator>
 
 
+// <HasNodeReferenceIterator>
+SERIALIZABLE_CLASS_VERSIONS(HasNodeReferenceIterator)
+
+void HasNodeReferenceIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+  serialize_baseclass(ar,
+  (NaryBaseIterator<HasNodeReferenceIterator, PlanIteratorState>*)this);
+}
+
+
+void HasNodeReferenceIterator::accept(PlanIterVisitor& v) const
+{
+  v.beginVisit(*this);
+
+  std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+  std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+  for ( ; lIter != lEnd; ++lIter ){
+    (*lIter)->accept(v);
+  }
+
+  v.endVisit(*this);
+}
+
+HasNodeReferenceIterator::~HasNodeReferenceIterator() {}
+
+// </HasNodeReferenceIterator>
+
+
+// <AssignNodeReferenceIterator>
+SERIALIZABLE_CLASS_VERSIONS(AssignNodeReferenceIterator)
+
+void AssignNodeReferenceIterator::serialize(::zorba::serialization::Archiver& ar)
+{
+  serialize_baseclass(ar,
+  (NaryBaseIterator<AssignNodeReferenceIterator, PlanIteratorState>*)this);
+}
+
+
+void AssignNodeReferenceIterator::accept(PlanIterVisitor& v) const
+{
+  v.beginVisit(*this);
+
+  std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+  std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+  for ( ; lIter != lEnd; ++lIter ){
+    (*lIter)->accept(v);
+  }
+
+  v.endVisit(*this);
+}
+
+AssignNodeReferenceIterator::~AssignNodeReferenceIterator() {}
+
+// </AssignNodeReferenceIterator>
+
+
 // <NodeByReferenceIterator>
 SERIALIZABLE_CLASS_VERSIONS(NodeByReferenceIterator)
 

=== modified file 'src/runtime/nodes/pregenerated/nodes.h'
--- src/runtime/nodes/pregenerated/nodes.h	2012-06-28 04:14:03 +0000
+++ src/runtime/nodes/pregenerated/nodes.h	2012-06-28 22:02:21 +0000
@@ -67,6 +67,70 @@
 
 /**
  * 
+ *      declare function ref:has-node-reference($node as node()) as xs:boolean
+ *    
+ * Author: Till Westmann
+ */
+class HasNodeReferenceIterator : public NaryBaseIterator<HasNodeReferenceIterator, PlanIteratorState>
+{ 
+public:
+  SERIALIZABLE_CLASS(HasNodeReferenceIterator);
+
+  SERIALIZABLE_CLASS_CONSTRUCTOR2T(HasNodeReferenceIterator,
+    NaryBaseIterator<HasNodeReferenceIterator, PlanIteratorState>);
+
+  void serialize( ::zorba::serialization::Archiver& ar);
+
+  HasNodeReferenceIterator(
+    static_context* sctx,
+    const QueryLoc& loc,
+    std::vector<PlanIter_t>& children)
+    : 
+    NaryBaseIterator<HasNodeReferenceIterator, PlanIteratorState>(sctx, loc, children)
+  {}
+
+  virtual ~HasNodeReferenceIterator();
+
+  void accept(PlanIterVisitor& v) const;
+
+  bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ * 
+ *      declare function ref:assign-node-reference($node as node()) as xs:boolean
+ *    
+ * Author: Till Westmann
+ */
+class AssignNodeReferenceIterator : public NaryBaseIterator<AssignNodeReferenceIterator, PlanIteratorState>
+{ 
+public:
+  SERIALIZABLE_CLASS(AssignNodeReferenceIterator);
+
+  SERIALIZABLE_CLASS_CONSTRUCTOR2T(AssignNodeReferenceIterator,
+    NaryBaseIterator<AssignNodeReferenceIterator, PlanIteratorState>);
+
+  void serialize( ::zorba::serialization::Archiver& ar);
+
+  AssignNodeReferenceIterator(
+    static_context* sctx,
+    const QueryLoc& loc,
+    std::vector<PlanIter_t>& children)
+    : 
+    NaryBaseIterator<AssignNodeReferenceIterator, PlanIteratorState>(sctx, loc, children)
+  {}
+
+  virtual ~AssignNodeReferenceIterator();
+
+  void accept(PlanIterVisitor& v) const;
+
+  bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
+};
+
+
+/**
+ * 
  *      declare function ref:node-by-reference($reference as xs:anyURI) as node()?
  *    
  * Author: Federico Cavalieri

=== modified file 'src/runtime/pregenerated/iterator_enum.h'
--- src/runtime/pregenerated/iterator_enum.h	2012-06-27 14:07:46 +0000
+++ src/runtime/pregenerated/iterator_enum.h	2012-06-28 22:02:21 +0000
@@ -215,6 +215,8 @@
   TYPE_InCollectionPositionIterator,
   TYPE_InSameCollectionPositionIterator,
   TYPE_NodeReferenceIterator,
+  TYPE_HasNodeReferenceIterator,
+  TYPE_AssignNodeReferenceIterator,
   TYPE_NodeByReferenceIterator,
   TYPE_FnLocalNameIterator,
   TYPE_FnNamespaceUriIterator,

=== modified file 'src/runtime/spec/nodes/nodes.xml'
--- src/runtime/spec/nodes/nodes.xml	2012-06-28 04:14:03 +0000
+++ src/runtime/spec/nodes/nodes.xml	2012-06-28 22:02:21 +0000
@@ -41,6 +41,53 @@
 /*******************************************************************************
 ********************************************************************************/
 -->
+  <zorba:iterator name="HasNodeReferenceIterator">
+
+    <zorba:description author="Till Westmann">
+      declare function ref:has-node-reference($node as node()) as xs:boolean
+    </zorba:description>
+
+    <zorba:function>
+
+      <zorba:signature localname="has-node-reference" prefix="fn-zorba-ref">
+        <zorba:param>node()</zorba:param>
+        <zorba:output>xs:boolean</zorba:output>
+      </zorba:signature>
+
+    </zorba:function>
+
+  </zorba:iterator>
+
+<!--
+/*******************************************************************************
+********************************************************************************/
+-->
+  <zorba:iterator name="AssignNodeReferenceIterator">
+
+    <zorba:description author="Till Westmann">
+      declare function ref:assign-node-reference($node as node()) as xs:boolean
+    </zorba:description>
+
+    <zorba:function>
+
+      <zorba:signature localname="assign-node-reference" prefix="fn-zorba-ref">
+        <zorba:param>node()</zorba:param>
+        <zorba:param>xs:anyURI</zorba:param>
+        <zorba:output>xs:boolean</zorba:output>
+      </zorba:signature>
+
+      <zorba:methods>
+        <zorba:getScriptingKind returnValue="SEQUENTIAL_FUNC_EXPR"/>
+      </zorba:methods>
+
+    </zorba:function>
+
+  </zorba:iterator>
+
+<!--
+/*******************************************************************************
+********************************************************************************/
+-->
   <zorba:iterator name="NodeByReferenceIterator">
 
     <zorba:description author="Federico Cavalieri">

=== modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h'
--- src/runtime/visitors/pregenerated/planiter_visitor.h	2012-06-28 04:14:03 +0000
+++ src/runtime/visitors/pregenerated/planiter_visitor.h	2012-06-28 22:02:21 +0000
@@ -450,6 +450,10 @@
 
     class NodeReferenceIterator;
 
+    class HasNodeReferenceIterator;
+
+    class AssignNodeReferenceIterator;
+
     class NodeByReferenceIterator;
 
     class FnLocalNameIterator;
@@ -1330,6 +1334,12 @@
     virtual void beginVisit ( const NodeReferenceIterator& ) = 0;
     virtual void endVisit   ( const NodeReferenceIterator& ) = 0;
 
+    virtual void beginVisit ( const HasNodeReferenceIterator& ) = 0;
+    virtual void endVisit   ( const HasNodeReferenceIterator& ) = 0;
+
+    virtual void beginVisit ( const AssignNodeReferenceIterator& ) = 0;
+    virtual void endVisit   ( const AssignNodeReferenceIterator& ) = 0;
+
     virtual void beginVisit ( const NodeByReferenceIterator& ) = 0;
     virtual void endVisit   ( const NodeByReferenceIterator& ) = 0;
 

=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp'
--- src/runtime/visitors/pregenerated/printer_visitor.cpp	2012-06-28 04:14:03 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.cpp	2012-06-28 22:02:21 +0000
@@ -2873,6 +2873,34 @@
 // </NodeReferenceIterator>
 
 
+// <HasNodeReferenceIterator>
+void PrinterVisitor::beginVisit ( const HasNodeReferenceIterator& a) {
+  thePrinter.startBeginVisit("HasNodeReferenceIterator", ++theId);
+  printCommons( &a, theId );
+  thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const HasNodeReferenceIterator& ) {
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+// </HasNodeReferenceIterator>
+
+
+// <AssignNodeReferenceIterator>
+void PrinterVisitor::beginVisit ( const AssignNodeReferenceIterator& a) {
+  thePrinter.startBeginVisit("AssignNodeReferenceIterator", ++theId);
+  printCommons( &a, theId );
+  thePrinter.endBeginVisit( theId );
+}
+
+void PrinterVisitor::endVisit ( const AssignNodeReferenceIterator& ) {
+  thePrinter.startEndVisit();
+  thePrinter.endEndVisit();
+}
+// </AssignNodeReferenceIterator>
+
+
 // <NodeByReferenceIterator>
 void PrinterVisitor::beginVisit ( const NodeByReferenceIterator& a) {
   thePrinter.startBeginVisit("NodeByReferenceIterator", ++theId);

=== modified file 'src/runtime/visitors/pregenerated/printer_visitor.h'
--- src/runtime/visitors/pregenerated/printer_visitor.h	2012-06-28 04:14:03 +0000
+++ src/runtime/visitors/pregenerated/printer_visitor.h	2012-06-28 22:02:21 +0000
@@ -692,6 +692,12 @@
     void beginVisit( const NodeReferenceIterator& );
     void endVisit  ( const NodeReferenceIterator& );
 
+    void beginVisit( const HasNodeReferenceIterator& );
+    void endVisit  ( const HasNodeReferenceIterator& );
+
+    void beginVisit( const AssignNodeReferenceIterator& );
+    void endVisit  ( const AssignNodeReferenceIterator& );
+
     void beginVisit( const NodeByReferenceIterator& );
     void endVisit  ( const NodeByReferenceIterator& );
 

=== modified file 'src/store/api/store.h'
--- src/store/api/store.h	2012-06-28 04:14:03 +0000
+++ src/store/api/store.h	2012-06-28 22:02:21 +0000
@@ -120,6 +120,14 @@
   virtual bool hasReference(const Item* node) = 0;
 
   /**
+   * Assigns a specific reference for the given node.
+   *
+   * @param item XDM node
+   * @param reference an xs:anyURI item
+   */
+  virtual bool assignReference(const Item* node, const zstring& reference) = 0;
+
+  /**
    * Returns the node which is identified by the given reference.
    * If the given reference is not a valid reference, as generated by
    * getReference, error ZAPI0028 is raised.

=== modified file 'src/store/naive/simple_store.cpp'
--- src/store/naive/simple_store.cpp	2012-06-28 04:14:03 +0000
+++ src/store/naive/simple_store.cpp	2012-06-28 22:02:21 +0000
@@ -292,10 +292,7 @@
   uuid_create(&uuid);
   zstring uuidStr = uuidToURI(uuid);
 
-  const_cast<XmlNode*>(xmlNode)->setHaveReference();
-
-  theNodeToReferencesMap.insert(xmlNode, uuidStr);
-  theReferencesToNodeMap[uuidStr] = node;
+  assignReference(xmlNode, uuidStr);
 
   return theItemFactory->createAnyURI(result, uuidStr);
 }
@@ -313,6 +310,24 @@
 }
 
 
+bool SimpleStore::assignReference(const store::Item* node, const zstring& reference)
+{
+  const XmlNode* xmlNode = static_cast<const XmlNode*>(node);
+  zstring uuidStr = reference;
+
+  if (xmlNode->haveReference())
+  {
+    return false;
+  }
+  const_cast<XmlNode*>(xmlNode)->setHaveReference();
+
+  theNodeToReferencesMap.insert(xmlNode, uuidStr);
+  theReferencesToNodeMap[uuidStr] = node;
+
+  return true;
+}
+
+
 /*******************************************************************************
   Returns the node which is identified by the given reference.
 

=== modified file 'src/store/naive/simple_store.h'
--- src/store/naive/simple_store.h	2012-06-28 04:14:03 +0000
+++ src/store/naive/simple_store.h	2012-06-28 22:02:21 +0000
@@ -108,6 +108,8 @@
 
   bool hasReference(const store::Item* node);
 
+  bool assignReference(const store::Item* node, const zstring& reference);
+
   bool getNodeByReference(store::Item_t& result, const zstring& reference);
 
 #ifdef ZORBA_WITH_JSON

=== added file 'test/rbkt/ExpQueryResults/zorba/reference/reference_coll_4.xml.res'
--- test/rbkt/ExpQueryResults/zorba/reference/reference_coll_4.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/reference/reference_coll_4.xml.res	2012-06-28 22:02:21 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+false true
\ No newline at end of file

=== added file 'test/rbkt/ExpQueryResults/zorba/reference/reference_coll_5.xml.res'
--- test/rbkt/ExpQueryResults/zorba/reference/reference_coll_5.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/reference/reference_coll_5.xml.res	2012-06-28 22:02:21 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+false true true
\ No newline at end of file

=== modified file 'test/rbkt/Queries/zorba/reference/collections.xqdata'
--- test/rbkt/Queries/zorba/reference/collections.xqdata	2012-06-28 04:14:03 +0000
+++ test/rbkt/Queries/zorba/reference/collections.xqdata	2012-06-28 22:02:21 +0000
@@ -3,3 +3,4 @@
 declare namespace ann = "http://www.zorba-xquery.com/annotations";;
 
 declare %ann:ordered collection ns:test as node()*;
+declare collection ns:test2 as node()*;

=== added file 'test/rbkt/Queries/zorba/reference/reference_coll_4.xq'
--- test/rbkt/Queries/zorba/reference/reference_coll_4.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/reference/reference_coll_4.xq	2012-06-28 22:02:21 +0000
@@ -0,0 +1,20 @@
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";;
+import module namespace ns = "http://example.org/datamodule/"; at "collections.xqdata";
+
+import module namespace ref = "http://www.zorba-xquery.com/modules/node-reference";;
+
+declare namespace ann = "http://www.zorba-xquery.com/annotations";;
+
+declare %ann:sequential function local:test()
+{
+  ddl:create(xs:QName("ns:test2"));
+  dml:insert-nodes(xs:QName("ns:test2"), <a><b><c d="e"></c></b></a>);
+  variable $node := dml:collection(xs:QName("ns:test2"))/b/c/@d;
+  variable $has1 := ref:has-node-reference($node);
+  variable $ref  := ref:node-reference($node);
+  variable $has2 := ref:has-node-reference($node);
+  ($has1, $has2)
+};
+
+local:test()

=== added file 'test/rbkt/Queries/zorba/reference/reference_coll_5.xq'
--- test/rbkt/Queries/zorba/reference/reference_coll_5.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/reference/reference_coll_5.xq	2012-06-28 22:02:21 +0000
@@ -0,0 +1,21 @@
+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";;
+import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";;
+import module namespace ns = "http://example.org/datamodule/"; at "collections.xqdata";
+
+import module namespace ref = "http://www.zorba-xquery.com/modules/node-reference";;
+
+declare namespace ann = "http://www.zorba-xquery.com/annotations";;
+
+declare %ann:sequential function local:test()
+{
+  ddl:create(xs:QName("ns:test2"));
+  variable $ref  := xs:anyURI("urn:uuid:e35e9021-0a1c-48c7-8902-833105a2f013");
+  variable $node := dml:apply-insert-nodes(xs:QName("ns:test2"), <f><g><h i="j"></h></g></f>);
+  variable $has1 := ref:has-node-reference($node);
+  ref:assign-node-reference($node, $ref);
+  variable $has2 := ref:has-node-reference($node);
+  variable $find := ref:node-by-reference($ref);
+  ($has1, $has2, $node is $find)
+};
+
+local:test()

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

Reply via email to