Merge lp:~zorba-coders/zorba/identifiers into lp:zorba

Proposed by Federico Cavalieri on 2011-10-06
Status: Merged
Approved by: Federico Cavalieri on 2011-10-10
Approved revision: 10515
Merged at revision: 10505
Proposed branch: lp:~zorba-coders/zorba/identifiers
Merge into: lp:zorba
Diff against target: 2249 lines (+994/-590)
43 files modified
ChangeLog (+4/-0)
include/zorba/pregenerated/diagnostic_list.h (+4/-0)
modules/com/zorba-xquery/www/modules/node-reference.xq (+25/-15)
modules/com/zorba-xquery/www/modules/pregenerated/errors.xq (+8/-0)
src/diagnostics/diagnostic_en.xml (+8/-0)
src/diagnostics/pregenerated/diagnostic_list.cpp (+6/-0)
src/diagnostics/pregenerated/dict_en.cpp (+2/-0)
src/runtime/nodes/nodes_impl.cpp (+74/-32)
src/runtime/nodes/pregenerated/nodes.h (+6/-6)
src/runtime/spec/nodes/nodes.xml (+38/-34)
src/store/api/store.h (+29/-20)
src/store/naive/node_items.cpp (+5/-2)
src/store/naive/node_items.h (+20/-15)
src/store/naive/simple_index_value.cpp (+1/-1)
src/store/naive/simple_store.cpp (+128/-354)
src/store/naive/simple_store.h (+84/-65)
src/util/uuid/uuid.cpp (+12/-0)
src/util/uuid/uuid.h (+3/-0)
src/zorbautils/hashmap.h (+36/-9)
test/rbkt/ExpQueryResults/zorba/paths/ref1.xml.res (+387/-0)
test/rbkt/ExpQueryResults/zorba/reference/reference_1.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/reference/reference_2.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/reference/reference_3.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/reference/reference_4.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/reference/reference_5.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/reference/reference_coll_1.xml.res (+2/-1)
test/rbkt/ExpQueryResults/zorba/reference/reference_coll_2.xml.res (+2/-1)
test/rbkt/ExpQueryResults/zorba/reference/reference_coll_3.xml.res (+2/-1)
test/rbkt/Queries/CMakeLists.txt (+3/-0)
test/rbkt/Queries/zorba/paths/ref1.spec (+0/-1)
test/rbkt/Queries/zorba/reference/error.spec (+0/-4)
test/rbkt/Queries/zorba/reference/error.xq (+0/-6)
test/rbkt/Queries/zorba/reference/reference.xqlib (+3/-0)
test/rbkt/Queries/zorba/reference/reference_1.xq (+13/-0)
test/rbkt/Queries/zorba/reference/reference_2.xq (+14/-0)
test/rbkt/Queries/zorba/reference/reference_3.xq (+33/-0)
test/rbkt/Queries/zorba/reference/reference_4.spec (+1/-0)
test/rbkt/Queries/zorba/reference/reference_4.xq (+3/-0)
test/rbkt/Queries/zorba/reference/reference_5.xq (+29/-0)
test/rbkt/Queries/zorba/reference/reference_doc_example_01.spec (+0/-4)
test/rbkt/Queries/zorba/reference/reference_doc_example_01.xq (+0/-7)
test/rbkt/Queries/zorba/reference/reference_doc_example_02.spec (+0/-4)
test/rbkt/Queries/zorba/reference/reference_doc_example_02.xq (+0/-8)
To merge this branch: bzr merge lp:~zorba-coders/zorba/identifiers
Reviewer Review Type Date Requested Status
Markos Zaharioudakis 2011-10-06 Approve on 2011-10-10
Matthias Brantner Approve on 2011-10-07
Review via email: mp+78383@code.launchpad.net

Commit message

Changed the implementation of the reference module.
Now the module provides functions to compute an immutable and opaque reference
for any node, either temporary or stored in a collection and for retrieving
nodes given their identifier. The identifiers are immutable, i.e. a node
identifier do not change during the node lifetime. Identifiers are also
unique, in that, two nodes with different identities have different identifiers.
A node, at any time during its lifetime, can be retrieved by its identifier.

Description of the change

Changed the implementation of the reference module.
Now the module provides functions to compute an immutable and opaque reference
for any node, either temporary or stored in a collection and for retrieving
nodes given their identifier. The identifiers are immutable, i.e. a node
identifier do not change during the node lifetime. Identifiers are also
unique, in that, two nodes with different identities have different identifiers.
A node, at any time during its lifetime, can be retrieved by its identifier.

To post a comment you must log in.
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job identifiers-2011-10-06T10-20-22.864Z is finished. The final status was:

All tests succeeded!

Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 0, Disapprove < 1. Got: 1 Pending.

Minor comments from Ghislain;

node-reference.xq
line 41: do -> does
line 42: in that, a generated identifier has never been generated before. -> in that two nodes with different identifies will never have identical identifiers.
("generate" is an implementation detail).
Same for lines 73/74.
line 96: missing newline

nodes.h
line 366: node-by-identifier -> node-by-reference?

review: Needs Fixing
Federico Cavalieri (fcavalieri) wrote :

Thanks,

I fixed
a generated identifier has never been generated before.
with
in that two different nodes will never have identical identifiers.

Is this ok?

Federico Cavalieri (fcavalieri) wrote :

I think identifies was identities.
Fixing again

<p>Please see the <a href="../../html/data_lifecycle.html">data lifecycle
 documentation</a> about details on management and manipulation of collections.</p>
=>
<p>Please see the <a href="../../html/data_lifecycle.html">data lifecycle
 documentation</a> about details on storing nodes in collections or as documents.</p>

Computes an immutable and opaque node reference
=>
Returns an immutable and opaque node reference...

The function returns the empty sequence if the node
that is referenced was deleted.
=>
The function returns the empty sequence if the node
that is referenced does not exist (e.g. because it was deleted or the temporary node is not available anymore)

zerr::ZAPI0028
=>
zerr:ZAPI0028

Can any of the functions return ZAPI0029? If so, it's not documented. Same for ZAPI0030.

fix indentation in NodeByReferenceIterator (two spaces)
Also, add a space before and after the assignment

Fix comment in FnGenerateIdIterator => remove e.g. z0.1.1.c.50

Why is hasReference still needed?

What is the following change in node_items.cpp for?
513 - theTypesMap = new NodeTypeMap(source->theTypesMap->object_count(), false);
514 + theTypesMap = new NodeTypeMap(source->theTypesMap->size(), false);

What is the CopyMode's theCopyReference member for? Isn't it always false?

review: Needs Fixing
Markos Zaharioudakis (markos-za) wrote :

More comments on the documentation inside node-reference.xq:

1. I think the definition of "immutable" should say:

i.e. a node identifier does not change during the node lifetime, and cannot be reused for another node after the original node gets deleted.

instead of just

i.e. a node identifier does not change during the node lifetime

2. I don't like this sentence:

"Identifiers are also unique, in that, two nodes with different identities will never have identical identifiers.".

Identifiers are actually an implementation of the "node identity" concept defined by the w3c specs. So the above sentence is a tautology. I would say the following:

"Identifiers are also unique, in that, two different nodes will never have the same identifier.".

3. When we say "any node", I don't think it is necessary to add "either temporary or stored in a collection". What is a "temporary" node after all? There is no definition for "temporary" or "persistent" nodes anywhere.

4. Should we say something about text nodes, eg, that their identifier is not really immutable and it can be used to dereference the node only during the same snapshot in which the identifier was retrieved?

Markos Zaharioudakis (markos-za) wrote :

>
> The function returns the empty sequence if the node
> that is referenced was deleted.
> =>
> The function returns the empty sequence if the node
> that is referenced does not exist (e.g. because it was deleted or the
> temporary node is not available anymore)
>

I wouldn't add the "(e.g. because ....)" part. After all, a temporary node becomes not available by being deleted. So, the phrase does not really add any additional info.

> zerr::ZAPI0028
> =>
> zerr:ZAPI0028
>
> Can any of the functions return ZAPI0029? If so, it's not documented. Same for
> ZAPI0030.
>

I am not sure, but these 2 errors are being used just for internal sanity checks. If so, they should be removed from the diagnostics list (use ZORBA_ASSERT() instead).

>
> What is the following change in node_items.cpp for?
> 513 - theTypesMap = new
> NodeTypeMap(source->theTypesMap->object_count(), false);
> 514 + theTypesMap = new NodeTypeMap(source->theTypesMap->size(),
> false);
>

I made this change because I changed theNodeToReferencesMap to be a hashmap (instead of std::map), and in doing so, I renamed some of the HashMap methods to better match the std::map methods.

Markos Zaharioudakis (markos-za) wrote :

Federico, on Wednesday, we agreed that you send us an example that shows when you have to copy over the identifier of a node that is being copied. Have you done it? (it's possible that I missed it in the deluge of emails).

In the meantime, and in the interest of making some progress, shall we delete the copy-reference stuff from the identifiers branch, so that we can merge it to the trunk. The copy-reference stuff is not actually used anywhere within the identifiers branch, so removing it will make for a "cleaner" (more self-contained) commit. If we decide that we really need it, you can put the copy-reference stuff to the branch where it is actually used, and then it will be easier to understand as well.

Federico Cavalieri (fcavalieri) wrote :

> <p>Please see the <a href="../../html/data_lifecycle.html">data lifecycle
> documentation</a> about details on management and manipulation of
> collections.</p>
> =>
> <p>Please see the <a href="../../html/data_lifecycle.html">data lifecycle
> documentation</a> about details on storing nodes in collections or as
> documents.</p>

Done.
>
> Computes an immutable and opaque node reference
> =>
> Returns an immutable and opaque node reference...
>
Done.

> The function returns the empty sequence if the node
> that is referenced was deleted.
> =>
> The function returns the empty sequence if the node
> that is referenced does not exist (e.g. because it was deleted or the
> temporary node is not available anymore)
>
Done.

> zerr::ZAPI0028
> =>
> zerr:ZAPI0028
>

Done.

> Can any of the functions return ZAPI0029? If so, it's not documented. Same for
> ZAPI0030.
>

They cannot be raised by the functions in this module. However they can be raised when some of the simple_store methods are called directly, like i do in my pul module.
An example could be a PUL which requires to insert a node with an identity which is already assigned to another node. (Either the same PUL/operation is applied twice or the user is using crafting ids). In those function these errors are either catched and wrapped into other errors or thrown.

>
> fix indentation in NodeByReferenceIterator (two spaces)
>
Done
> Also, add a space before and after the assignment
Done, also in the other module
>
> Fix comment in FnGenerateIdIterator => remove e.g. z0.1.1.c.50
Done.
>
> Why is hasReference still needed?
I use this in my pul module to verify whether a node has a reference or not.

>
> What is the following change in node_items.cpp for?
> 513 - theTypesMap = new
> NodeTypeMap(source->theTypesMap->object_count(), false);
> 514 + theTypesMap = new NodeTypeMap(source->theTypesMap->size(),
> false);

I think Markos changed it when he replaced one of my tree-based maps with a more efficient hash-based map.

> What is the CopyMode's theCopyReference member for? Isn't it always false?
Yes in the current module it is. Should I move it in the branch which uses it/by itself?

Federico Cavalieri (fcavalieri) wrote :

> More comments on the documentation inside node-reference.xq:
>
> 1. I think the definition of "immutable" should say:
>
> i.e. a node identifier does not change during the node lifetime, and cannot be
> reused for another node after the original node gets deleted.
>
> instead of just
>
> i.e. a node identifier does not change during the node lifetime
>

Done.

> 2. I don't like this sentence:
>
> "Identifiers are also unique, in that, two nodes with different identities
> will never have identical identifiers.".
>
> Identifiers are actually an implementation of the "node identity" concept
> defined by the w3c specs. So the above sentence is a tautology. I would say
> the following:
>
> "Identifiers are also unique, in that, two different nodes will never have the
> same identifier.".

Done.
>
> 3. When we say "any node", I don't think it is necessary to add "either
> temporary or stored in a collection". What is a "temporary" node after all?
> There is no definition for "temporary" or "persistent" nodes anywhere.
>

Done.

> 4. Should we say something about text nodes, eg, that their identifier is not
> really immutable and it can be used to dereference the node only during the
> same snapshot in which the identifier was retrieved?

This refers to the other module, the one with the structural uris. Identifiers/references work the same for every node. Structural uris cannot be dereferenced (our choice), so it is not a problem.
We never say however that the structural relationship of a non-text node remains the same in the node lifetime. Maybe we should. What do you think?

Federico Cavalieri (fcavalieri) wrote :

> >
> > The function returns the empty sequence if the node
> > that is referenced was deleted.
> > =>
> > The function returns the empty sequence if the node
> > that is referenced does not exist (e.g. because it was deleted or the
> > temporary node is not available anymore)
> >
>

Done.

> I wouldn't add the "(e.g. because ....)" part. After all, a temporary node
> becomes not available by being deleted. So, the phrase does not really add any
> additional info.
>
> > zerr::ZAPI0028
> > =>
> > zerr:ZAPI0028
> >
> > Can any of the functions return ZAPI0029? If so, it's not documented. Same
> for
> > ZAPI0030.
> >
>
> I am not sure, but these 2 errors are being used just for internal sanity
> checks. If so, they should be removed from the diagnostics list (use
> ZORBA_ASSERT() instead).

They cannot be raised by the functions in this module. However they can be raised when some of the simple_store methods are called directly, like i do in my pul module.
An example could be a PUL which requires to insert a node with an identity which is already assigned to another node. (Either the same PUL/operation is applied twice or the user is using crafting ids). In those function these errors are either catched and wrapped into other errors or thrown.

Markos Zaharioudakis (markos-za) wrote :

> > 4. Should we say something about text nodes, eg, that their identifier is
> not
> > really immutable and it can be used to dereference the node only during the
> > same snapshot in which the identifier was retrieved?
>
> This refers to the other module, the one with the structural uris.
> Identifiers/references work the same for every node. Structural uris cannot be
> dereferenced (our choice), so it is not a problem.
> We never say however that the structural relationship of a non-text node
> remains the same in the node lifetime. Maybe we should. What do you think?

Sorry, I got confused again between identifiers and ordpaths.

Markos Zaharioudakis (markos-za) wrote :

> > What is the CopyMode's theCopyReference member for? Isn't it always false?
> Yes in the current module it is. Should I move it in the branch which uses
> it/by itself?

YES! I made the same suggestion in one of my other comments.

Identifiers are useful by themselves, i.e., independently from the PUL-manipulation module. So, this branch should be about identifiers only. Anything that is relevant to PUL-manipulation should be moved to the associated branch.

Federico Cavalieri (fcavalieri) wrote :

Moved the copy-reference extension to copy_mode into another branch. It is no longer in this one

Federico Cavalieri (fcavalieri) wrote :

> Identifiers are useful by themselves, i.e., independently from the PUL-
> manipulation module. So, this branch should be about identifiers only.
> Anything that is relevant to PUL-manipulation should be moved to the
> associated branch.

What about the hasIdentifier and similar functions offered in the store?
They seems to be on the edge between being general utility functions and
something specific to the PUL module,

Federico Cavalieri (fcavalieri) wrote :

>
> YES! I made the same suggestion in one of my other comments.
>

OK. I was in the middle of the process of moving them

Federico Cavalieri (fcavalieri) wrote :

> Federico, on Wednesday, we agreed that you send us an example that shows when
> you have to copy over the identifier of a node that is being copied. Have you
> done it? (it's possible that I missed it in the deluge of emails).

Done and sent

I'm fine with it now.

review: Approve
Markos Zaharioudakis (markos-za) wrote :

Federico I made some changes to the branch, the most important of which is that I removed from SimpleStore the methods related to copying of identifiers. I guess you will have to put this code back in the branch where it is actually used.

review: Approve
Zorba Build Bot (zorba-buildbot) wrote :

Attempt to merge into lp:zorba failed due to conflicts:

text conflict in test/rbkt/Queries/CMakeLists.txt

Federico Cavalieri (fcavalieri) wrote :

> Federico I made some changes to the branch, the most important of which is
> that I removed from SimpleStore the methods related to copying of identifiers.
> I guess you will have to put this code back in the branch where it is actually
> used.

OK, Thanks.

I am going to fix the arisen merge conflicts.

lp:~zorba-coders/zorba/identifiers updated on 2011-10-10
10515. By Federico Cavalieri on 2011-10-10

Merged the trunk in the branch. Fixed conflict in test/rbkt/Queries/CMakeLists.txt

Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job identifiers-2011-10-10T10-38-30.063Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2011-10-05 22:39:18 +0000
3+++ ChangeLog 2011-10-10 10:35:29 +0000
4@@ -41,6 +41,10 @@
5 * Fixed bug #863730 (static delete-node* functions don't raise ZDDY0012)
6 * Implemented the probe-index-range-value for general indexes
7 * Fixed bug #867662 ("nullptr" warning)
8+ * Fixed bug #869024 (segmentation fault with node-reference)
9+ * Fixed bug #869025 (segmentation fault with node-reference)
10+ * New node-reference module. References can be obtained for any node, and different nodes cannot
11+ have the same identifier.
12
13 version 2.0.1
14
15
16=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
17--- include/zorba/pregenerated/diagnostic_list.h 2011-10-04 05:28:07 +0000
18+++ include/zorba/pregenerated/diagnostic_list.h 2011-10-10 10:35:29 +0000
19@@ -488,6 +488,10 @@
20
21 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0028_INVALID_NODE_URI;
22
23+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0029_REFERENCE_ALREADY_PRESENT;
24+
25+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0030_NO_CURRENT_REFERENCE;
26+
27 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0039_XQUERY_HAS_ITERATOR_ALREADY;
28
29 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZAPI0040_ITERATOR_NOT_OPEN;
30
31=== modified file 'modules/com/zorba-xquery/www/modules/node-reference.xq'
32--- modules/com/zorba-xquery/www/modules/node-reference.xq 2011-08-26 23:36:24 +0000
33+++ modules/com/zorba-xquery/www/modules/node-reference.xq 2011-10-10 10:35:29 +0000
34@@ -17,15 +17,20 @@
35 :)
36
37 (:~
38- : The module provides functions to compute a stable reference (URI) for
39- : a node that is stored in a collection and vice versa.
40+ : The module provides functions to compute an immutable and opaque reference
41+ : for any node and to retrieve nodes given their identifier. The identifiers
42+ : are immutable, i.e. a node identifier does not change during the node lifetime
43+ : and cannot be reused for another node after the original node gets deleted.
44+ : Identifiers are unique, in that, two different nodes will never have the same
45+ : identifier. A node, at any time during its lifetime, can be retrieved by its
46+ : identifier.
47 :
48 : <p>Please see the <a href="../../html/data_lifecycle.html">data lifecycle
49- : documentation</a> about details on management and manipulation of collections.</p>
50+ : documentation</a> about details on storing nodes in collections or as documents.</p>
51 :
52 : @see <a href="../../html/data_lifecycle.html">Data Lifecycle</a>
53 :
54- : @author Matthias Brantner
55+ : @author Federico Cavalieri
56 :
57 : @project XDM/node
58 :
59@@ -35,17 +40,22 @@
60 declare namespace zerr = "http://www.zorba-xquery.com/errors";
61
62 declare namespace ver = "http://www.zorba-xquery.com/options/versioning";
63+
64 declare option ver:module-version "2.0";
65
66 (:~
67- : Compute a stable and opaque node reference (with type xs:anyURI) for
68+ : Returns an immutable and opaque node reference (with type xs:anyURI) for
69 : a given node.
70- :
71- : <p>The function can only compute reference for nodes that a stored
72- : in a collection [zerr:ZAPI0080].</p>
73- :
74- : <p>The returned URI is stable, i.e. it still can be dereferenced if
75- : the node or the containing collection is modified.</p>
76+ :
77+ : <p>The generated identifier is immutable, i.e. a node identifier does not
78+ : change during the node lifetime and cannot be reused for another node after
79+ : the original node gets deleted.</p>
80+ :
81+ : <p>Identifiers are also unique, in that, two different nodes will never
82+ : have the same identifier.</p>
83+ :
84+ : A node, at any time during its lifetime, can be retrieved by its
85+ : identifier, using the <tt>ref:node-by-reference</tt> function.
86 :
87 : @param $arg the node for which the URI should be computed
88 :
89@@ -58,16 +68,16 @@
90 (:~
91 : Returns the node identified by the given node reference.
92 :
93- : <p>The function may return the empty sequence if the node
94- : that is referenced was deleted.</p>
95+ : <p>The function returns the empty sequence if the node
96+ : that is referenced does not exist.</p>
97 :
98 : @param $arg the URI of the node to retrieve.
99 :
100 : @return the node identified by the URI passed as parameter
101 : or the empty-sequence if no node with that URI is found.
102 :
103- : @error zerr::ZAPI0028 if the given URI is not a valid node reference
104- : computed by the <tt>ref:node-reference</tt> function.
105+ : @error zerr:ZAPI0028 if the given URI is not a valid node reference
106+ : computed by the <tt>ref:node-reference</tt> function.
107 :)
108 declare function ref:node-by-reference(
109 $arg as xs:anyURI
110
111=== modified file 'modules/com/zorba-xquery/www/modules/pregenerated/errors.xq'
112--- modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2011-09-30 14:06:33 +0000
113+++ modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2011-10-10 10:35:29 +0000
114@@ -277,6 +277,14 @@
115
116 (:~
117 :)
118+declare variable $zerr:ZAPI0029 as xs:QName := fn:QName($zerr:NS, "zerr:ZAPI0029");
119+
120+(:~
121+:)
122+declare variable $zerr:ZAPI0030 as xs:QName := fn:QName($zerr:NS, "zerr:ZAPI0030");
123+
124+(:~
125+:)
126 declare variable $zerr:ZAPI0039 as xs:QName := fn:QName($zerr:NS, "zerr:ZAPI0039");
127
128 (:~
129
130=== modified file 'src/diagnostics/diagnostic_en.xml'
131--- src/diagnostics/diagnostic_en.xml 2011-10-04 05:28:07 +0000
132+++ src/diagnostics/diagnostic_en.xml 2011-10-10 10:35:29 +0000
133@@ -1768,6 +1768,14 @@
134 <value>"$1": invalid node URI</value>
135 </diagnostic>
136
137+ <diagnostic code="ZAPI0029" name="REFERENCE_ALREADY_PRESENT">
138+ <value>"$1": reference already present in the store</value>
139+ </diagnostic>
140+
141+ <diagnostic code="ZAPI0030" name="NO_CURRENT_REFERENCE">
142+ <value>node has no current reference</value>
143+ </diagnostic>
144+
145 <diagnostic code="ZAPI0039" name="XQUERY_HAS_ITERATOR_ALREADY">
146 <value>XQuery has iterator already</value>
147 </diagnostic>
148
149=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
150--- src/diagnostics/pregenerated/diagnostic_list.cpp 2011-10-04 05:28:07 +0000
151+++ src/diagnostics/pregenerated/diagnostic_list.cpp 2011-10-10 10:35:29 +0000
152@@ -711,6 +711,12 @@
153 ZorbaErrorCode ZAPI0028_INVALID_NODE_URI( "ZAPI0028" );
154
155
156+ZorbaErrorCode ZAPI0029_REFERENCE_ALREADY_PRESENT( "ZAPI0029" );
157+
158+
159+ZorbaErrorCode ZAPI0030_NO_CURRENT_REFERENCE( "ZAPI0030" );
160+
161+
162 ZorbaErrorCode ZAPI0039_XQUERY_HAS_ITERATOR_ALREADY( "ZAPI0039" );
163
164
165
166=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
167--- src/diagnostics/pregenerated/dict_en.cpp 2011-10-04 05:28:07 +0000
168+++ src/diagnostics/pregenerated/dict_en.cpp 2011-10-10 10:35:29 +0000
169@@ -238,6 +238,8 @@
170 { "ZAPI0021", "\"$1\": item to load is not a node" },
171 { "ZAPI0027", "cannot update dynamic context with iterators" },
172 { "ZAPI0028", "\"$1\": invalid node URI" },
173+ { "ZAPI0029", "\"$1\": reference already present in the store" },
174+ { "ZAPI0030", "node has no current reference" },
175 { "ZAPI0039", "XQuery has iterator already" },
176 { "ZAPI0040", "iterator is not open" },
177 { "ZAPI0041", "iterator is already open" },
178
179=== modified file 'src/runtime/nodes/nodes_impl.cpp'
180--- src/runtime/nodes/nodes_impl.cpp 2011-08-04 02:39:56 +0000
181+++ src/runtime/nodes/nodes_impl.cpp 2011-10-10 10:35:29 +0000
182@@ -33,40 +33,48 @@
183
184 namespace zorba {
185
186-bool NodeReferenceIterator::nextImpl(store::Item_t& result, PlanState& planState) const
187+/*******************************************************************************
188+********************************************************************************/
189+bool
190+NodeReferenceIterator::nextImpl(store::Item_t& aResult, PlanState& aPlanState) const
191 {
192+ store::Item_t lNode;
193+ store::Item_t lGenerateIdentifier;
194+ zstring lNodeId;
195+
196 PlanIteratorState *state;
197- bool valid;
198- store::Item_t inNode;
199- DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
200-
201- valid = consumeNext(inNode, theChildren[0], planState);
202- assert(valid);
203-
204- if (! inNode->getCollection() )
205- {
206- throw XQUERY_EXCEPTION(
207- zerr::ZAPI0080_CANNOT_RETRIEVE_NODE_REFERENCE,
208- ERROR_LOC( loc )
209- );
210- }
211-
212- STACK_PUSH(GENV_STORE.getReference(result, inNode), state);
213- STACK_END(state);
214+ DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
215+
216+ consumeNext(lNode, theChildren[0].getp(), aPlanState);
217+
218+ STACK_PUSH(GENV_STORE.getReference(aResult, lNode), state);
219+
220+ STACK_END (state);
221 }
222
223-bool NodeByReferenceIterator::nextImpl(store::Item_t& result, PlanState& planState) const
224+/*******************************************************************************
225+********************************************************************************/
226+bool
227+NodeByReferenceIterator::nextImpl(store::Item_t& result, PlanState& planState) const
228 {
229- store::Item_t inUri;
230- bool valid;
231+ store::Item_t lUUID;
232+ bool haveResult;
233
234 PlanIteratorState *state;
235 DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
236
237- valid = consumeNext(inUri, theChildren[0], planState);
238- assert(valid);
239+ consumeNext(lUUID, theChildren[0].getp(), planState);
240+ try
241+ {
242+ haveResult = GENV_STORE.getNodeByReference(result, lUUID->getStringValue());
243+ }
244+ catch (ZorbaException& e)
245+ {
246+ set_source( e, loc );
247+ throw;
248+ }
249+ STACK_PUSH(haveResult, state);
250
251- STACK_PUSH(GENV_STORE.getNodeByReference(result, inUri), state);
252 STACK_END (state);
253 }
254
255@@ -138,8 +146,9 @@
256 }
257
258
259-// 14.5 fn:lang
260-//---------------------
261+/*******************************************************************************
262+ 14.5 fn:lang
263+********************************************************************************/
264 bool
265 FnLangIterator::isLangAttr(const store::Item_t& aAttr) const
266 {
267@@ -149,6 +158,7 @@
268 ZSTREQ(lAttrName->getNamespace(), XML_NS));
269 }
270
271+
272 bool
273 FnLangIterator::matchesReqLang(
274 const store::Item_t& aAttr,
275@@ -158,6 +168,7 @@
276 aAttr->getStringValue(), aRequestLang.str() + "(?:-.+)?", "i");
277 }
278
279+
280 bool FnLangIterator::nextImpl(store::Item_t& result, PlanState& planState) const
281 {
282 store::Item_t item, attr;
283@@ -218,6 +229,10 @@
284 STACK_END (state);
285 }
286
287+
288+/*******************************************************************************
289+
290+********************************************************************************/
291 bool FnHasChildrenIterator::nextImpl(store::Item_t& result, PlanState& planState) const
292 {
293 store::Item_t item, child1;
294@@ -244,6 +259,10 @@
295 STACK_END (state);
296 }
297
298+
299+/*******************************************************************************
300+
301+********************************************************************************/
302 static bool is_ancestor_of(store::Item_t parent, store::Item_t child)
303 {
304 if(parent == NULL)
305@@ -257,6 +276,10 @@
306 return false;
307 }
308
309+
310+/*******************************************************************************
311+
312+********************************************************************************/
313 bool FnInnermostIterator::nextImpl(store::Item_t& result, PlanState& planState) const
314 {
315 store::Item_t item;
316@@ -295,6 +318,10 @@
317 STACK_END (state);
318 }
319
320+
321+/*******************************************************************************
322+
323+********************************************************************************/
324 bool FnOutermostIterator::nextImpl(store::Item_t& result, PlanState& planState) const
325 {
326 store::Item_t item;
327@@ -333,30 +360,33 @@
328 STACK_END (state);
329 }
330
331+
332+/*******************************************************************************
333+
334+********************************************************************************/
335 bool FnGenerateIdIterator::nextImpl(store::Item_t& result, PlanState& planState) const
336 {
337 store::Item_t item;
338 bool retval;
339
340- PlanIteratorState *state;
341+ PlanIteratorState* state;
342 DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
343
344- if(theChildren.size())
345+ if (theChildren.size())
346 {
347 {
348 zstring uri_string, lRes;
349 if(consumeNext(item, theChildren[0].getp(), planState))
350 {
351 store::Item_t item_uri;
352- if(GENV_STORE.getReference(item_uri, item.getp()))
353+ if (GENV_STORE.getReference(item_uri, item.getp()))
354 {
355 uri_string = item_uri->getStringValue();
356 // need to convert the opaque uri into a valid ncname
357- // e.g. z0.1.1.c.50
358 #ifndef NDEBUG
359- ZORBA_ASSERT( uri_string.find_first_of("zorba:") == 0 );
360+ ZORBA_ASSERT( uri_string.find_first_of("urn:uuid:") == 0 );
361 #endif
362- lRes = "z" + uri_string.substr(uri_string.find_first_of(":") + 1);
363+ lRes = "u" + uri_string.substr(9);
364 }
365 }
366 retval = GENV_ITEMFACTORY->createString(result, lRes);
367@@ -367,7 +397,9 @@
368 STACK_END (state);
369 }
370
371+
372 /*******************************************************************************
373+
374 ********************************************************************************/
375 bool
376 IsFollowingSiblingIterator::nextImpl(store::Item_t& result, PlanState& planState) const
377@@ -389,7 +421,9 @@
378 STACK_END (state);
379 }
380
381+
382 /*******************************************************************************
383+
384 ********************************************************************************/
385 bool
386 IsFollowingIterator::nextImpl(store::Item_t& result, PlanState& planState) const
387@@ -411,7 +445,9 @@
388 STACK_END (state);
389 }
390
391+
392 /*******************************************************************************
393+
394 ********************************************************************************/
395 bool
396 IsChildIterator::nextImpl(store::Item_t& result, PlanState& planState) const
397@@ -433,6 +469,7 @@
398 STACK_END (state);
399 }
400
401+
402 /*******************************************************************************
403 ********************************************************************************/
404 bool
405@@ -452,6 +489,7 @@
406 STACK_END (state);
407 }
408
409+
410 /*******************************************************************************
411 ********************************************************************************/
412 bool
413@@ -472,6 +510,7 @@
414 STACK_END (state);
415 }
416
417+
418 /*******************************************************************************
419 ********************************************************************************/
420 bool
421@@ -494,6 +533,7 @@
422 STACK_END (state);
423 }
424
425+
426 /*******************************************************************************
427 ********************************************************************************/
428 bool
429@@ -516,6 +556,7 @@
430 STACK_END (state);
431 }
432
433+
434 /*******************************************************************************
435 ********************************************************************************/
436 bool
437@@ -538,6 +579,7 @@
438 STACK_END (state);
439 }
440
441+
442 /*******************************************************************************
443 ********************************************************************************/
444 bool
445
446=== modified file 'src/runtime/nodes/pregenerated/nodes.h'
447--- src/runtime/nodes/pregenerated/nodes.h 2011-06-16 19:47:58 +0000
448+++ src/runtime/nodes/pregenerated/nodes.h 2011-10-10 10:35:29 +0000
449@@ -34,10 +34,10 @@
450 namespace zorba {
451
452 /**
453- *
454- * Iterator to implement the zorba:node-reference function.
455- *
456- * Author: Zorba Team
457+ *
458+ * declare function ref:node-reference($node as node()) as xs:anyURI
459+ *
460+ * Author: Federico Cavalieri
461 */
462 class NodeReferenceIterator : public NaryBaseIterator<NodeReferenceIterator, PlanIteratorState>
463 {
464@@ -71,9 +71,9 @@
465
466 /**
467 *
468- * Iterator to implement the zorba:node-by-reference function.
469+ * declare function ref:node-by-reference($reference as xs:anyURI) as node()?
470 *
471- * Author: Zorba Team
472+ * Author: Federico Cavalieri
473 */
474 class NodeByReferenceIterator : public NaryBaseIterator<NodeByReferenceIterator, PlanIteratorState>
475 {
476
477=== modified file 'src/runtime/spec/nodes/nodes.xml'
478--- src/runtime/spec/nodes/nodes.xml 2011-08-04 02:39:56 +0000
479+++ src/runtime/spec/nodes/nodes.xml 2011-10-10 10:35:29 +0000
480@@ -11,45 +11,49 @@
481 xmlns:zorba="http://www.zorba-xquery.com"
482 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
483 xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
484-
485-<!--
486-/*******************************************************************************
487-********************************************************************************/
488--->
489-<zorba:iterator name="NodeReferenceIterator">
490-
491- <zorba:description author="Zorba Team">
492- Iterator to implement the zorba:node-reference function.
493- </zorba:description>
494-
495- <zorba:function>
496- <zorba:signature localname="node-reference" prefix="fn-zorba-ref">
497- <zorba:param>node()</zorba:param>
498- <zorba:output>xs:anyURI</zorba:output>
499- </zorba:signature>
500- </zorba:function>
501-
502-</zorba:iterator>
503-
504-<!--
505-/*******************************************************************************
506-********************************************************************************/
507--->
508-<zorba:iterator name="NodeByReferenceIterator">
509-
510- <zorba:description author="Zorba Team">
511- Iterator to implement the zorba:node-by-reference function.
512- </zorba:description>
513-
514- <zorba:function>
515+
516+<!--
517+/*******************************************************************************
518+********************************************************************************/
519+-->
520+ <zorba:iterator name="NodeReferenceIterator">
521+
522+ <zorba:description author="Federico Cavalieri">
523+ declare function ref:node-reference($node as node()) as xs:anyURI
524+ </zorba:description>
525+
526+ <zorba:function>
527+
528+ <zorba:signature localname="node-reference" prefix="fn-zorba-ref">
529+ <zorba:param>node()</zorba:param>
530+ <zorba:output>xs:anyURI</zorba:output>
531+ </zorba:signature>
532+
533+ </zorba:function>
534+
535+ </zorba:iterator>
536+
537+<!--
538+/*******************************************************************************
539+********************************************************************************/
540+-->
541+ <zorba:iterator name="NodeByReferenceIterator">
542+
543+ <zorba:description author="Federico Cavalieri">
544+ declare function ref:node-by-reference($reference as xs:anyURI) as node()?
545+ </zorba:description>
546+
547+ <zorba:function>
548+
549 <zorba:signature localname="node-by-reference" prefix="fn-zorba-ref">
550 <zorba:param>xs:anyURI</zorba:param>
551 <zorba:output>node()?</zorba:output>
552 </zorba:signature>
553+
554 </zorba:function>
555-
556-</zorba:iterator>
557-
558+
559+ </zorba:iterator>
560+
561 <!--
562 /*******************************************************************************
563 ********************************************************************************/
564
565=== modified file 'src/store/api/store.h'
566--- src/store/api/store.h 2011-09-27 10:43:46 +0000
567+++ src/store/api/store.h 2011-10-10 10:35:29 +0000
568@@ -87,26 +87,35 @@
569 */
570 virtual TempSeq_t createTempSeq(bool lazy) = 0;
571
572-
573- /* -------------------------- Reference Management --------------------------*/
574-
575- /**
576- * Computes the URI of the passed item.
577- *
578- * @param item XDM item
579- * @return Returns an item of type xs:uri
580- */
581- virtual bool getReference(Item_t& result, const Item* node) = 0;
582-
583- /**
584- * Returns Item which is identified by a reference
585- *
586- * @param uri Has to be an xs:URI item
587- * @returns referenced item if it exists, otherwise NULL
588- */
589- virtual bool getNodeByReference(Item_t& result, const Item* uri) = 0;
590-
591-
592+ /* ----------------------- Node Reference Management -------------------------*/
593+
594+ /**
595+ * Computes the reference of the given node.
596+ *
597+ * @param node XDM node
598+ * @return the identifier as an item of type xs:anyURI
599+ */
600+ virtual bool getReference(Item_t& result, Item* node) = 0;
601+
602+ /**
603+ * Returns whether a reference has already been generated for the given node.
604+ *
605+ * @param item XDM node
606+ * @return whether a reference has already been generated for the given node.
607+ */
608+ virtual bool hasReference(const Item* node) = 0;
609+
610+ /**
611+ * Returns the node which is identified by the given reference.
612+ * If the given reference is not a valid reference, as generated by
613+ * getReference, error ZAPI0028 is raised.
614+ *
615+ * @param reference an xs:anyURI item
616+ * @returns the node identified by the reference, NULL otherwise
617+ */
618+ virtual bool getNodeByReference(store::Item_t& result, const zstring& reference) = 0;
619+
620+
621 /* --------------------------- Node Id Management ---------------------------*/
622
623 /**
624
625=== modified file 'src/store/naive/node_items.cpp'
626--- src/store/naive/node_items.cpp 2011-10-03 08:49:55 +0000
627+++ src/store/naive/node_items.cpp 2011-10-10 10:35:29 +0000
628@@ -234,7 +234,7 @@
629
630 if (theTypesMap == NULL)
631 {
632- theTypesMap = new NodeTypeMap(source->theTypesMap->object_count(), false);
633+ theTypesMap = new NodeTypeMap(source->theTypesMap->size(), false);
634 }
635
636 NodeTypeMap::iterator ite = source->theTypesMap->begin();
637@@ -693,6 +693,9 @@
638 }
639 #endif
640
641+ if (haveReference())
642+ GET_STORE().unregisterNode(this);
643+
644 delete this;
645 }
646
647@@ -1350,7 +1353,7 @@
648 XmlNode* DocumentNode::copyInternal(
649 InternalNode* rootParent,
650 InternalNode* parent,
651- csize pos,
652+ csize pos,
653 const XmlNode* rootCopy,
654 const store::CopyMode& copymode) const
655 {
656
657=== modified file 'src/store/naive/node_items.h'
658--- src/store/naive/node_items.h 2011-09-23 14:26:00 +0000
659+++ src/store/naive/node_items.h 2011-10-10 10:35:29 +0000
660@@ -309,30 +309,31 @@
661 public:
662 enum NodeFlags
663 {
664- NodeKindMask = 0x7,
665- IsId = 0x8,
666- IsIdRefs = 0x10,
667- HaveTypedValue = 0x20, // for element nodes only
668- HaveEmptyValue = 0x40, // for element nodes only
669- IsTyped = 0x80, // for text nodes only
670- HaveListValue = 0x100, // for text and attribute nodes only
671+ NodeKindMask = 0x7,
672+ IsId = 0x8,
673+ IsIdRefs = 0x10,
674+ HaveTypedValue = 0x20, // for element nodes only
675+ HaveEmptyValue = 0x40, // for element nodes only
676+ IsTyped = 0x80, // for text nodes only
677+ HaveListValue = 0x100, // for text and attribute nodes only
678
679- HaveLocalBindings = 0x200, // for element nodes only
680- HaveBaseUri = 0x400, // for element nodes only
681- IsBaseUri = 0x800, // for attribute nodes only
682- IsHidden = 0x1000, // for attribute nodes only
683- IsInSubstGroup = 0x2000, // for element nodes only
684+ HaveLocalBindings = 0x200, // for element nodes only
685+ HaveBaseUri = 0x400, // for element nodes only
686+ IsBaseUri = 0x800, // for attribute nodes only
687+ IsHidden = 0x1000, // for attribute nodes only
688+ IsInSubstGroup = 0x2000, // for element nodes only
689
690 // For element nodes only. The flag is set for a node N if there is another
691 // node M in its subtree such that N and M have the same name.
692- IsRecursive = 0x4000
693+ IsRecursive = 0x4000,
694
695 #ifndef EMBEDED_TYPE
696- ,
697 // For element and attribute nodes only. The flag is set if the node has
698 // a type other than untyped (for elements) or untypedAtomic (for attributes)
699- HaveType = 0x8000
700+ HaveType = 0x8000,
701 #endif
702+
703+ HaveReference = 0x10000
704 };
705
706 protected:
707@@ -495,6 +496,10 @@
708
709 void setFlags(uint32_t flags) { theFlags = flags; }
710
711+ bool haveReference() const { return (theFlags & HaveReference) != 0; }
712+ void setHaveReference() { theFlags |= HaveReference; }
713+ void resetHaveReference() { theFlags &= ~HaveReference; }
714+
715 #ifndef ZORBA_NO_FULL_TEXT
716 FTTokenIterator_t getTokens( TokenizerProvider const&, Tokenizer::Numbers&,
717 locale::iso639_1::type, bool = false ) const;
718
719=== modified file 'src/store/naive/simple_index_value.cpp'
720--- src/store/naive/simple_index_value.cpp 2011-10-03 08:49:55 +0000
721+++ src/store/naive/simple_index_value.cpp 2011-10-10 10:35:29 +0000
722@@ -147,7 +147,7 @@
723 ********************************************************************************/
724 ulong ValueHashIndex::size() const
725 {
726- return theMap.object_count();
727+ return theMap.size();
728 }
729
730
731
732=== modified file 'src/store/naive/simple_store.cpp'
733--- src/store/naive/simple_store.cpp 2011-10-03 08:49:55 +0000
734+++ src/store/naive/simple_store.cpp 2011-10-10 10:35:29 +0000
735@@ -57,6 +57,8 @@
736 #include "store/naive/pul_primitive_factory.h"
737
738 #include "util/cxx_util.h"
739+#include "util/uuid/uuid.h"
740+#include "zorbautils/string_util.h"
741
742 #ifndef ZORBA_NO_FULL_TEXT
743 #include "runtime/full_text/default_tokenizer.h"
744@@ -104,7 +106,8 @@
745 theIndices(0, NULL, CollectionSet::DEFAULT_COLLECTION_MAP_SIZE, true),
746 theICs(0, NULL, CollectionSet::DEFAULT_COLLECTION_MAP_SIZE, true),
747 theHashMaps(0, NULL, CollectionSet::DEFAULT_COLLECTION_MAP_SIZE, true),
748- theTraceLevel(0)
749+ theTraceLevel(0),
750+ theNodeToReferencesMap(128, true)
751 #ifndef ZORBA_NO_FULL_TEXT
752 , theStemmerProvider( nullptr )
753 , theTokenizerProvider( nullptr )
754@@ -334,6 +337,32 @@
755 theNodeFactory = NULL;
756 }
757
758+ if (theNodeToReferencesMap.size() > 0)
759+ {
760+ NodeRefMap::iterator iter = theNodeToReferencesMap.begin();
761+ NodeRefMap::iterator end = theNodeToReferencesMap.end();
762+ for (; iter != end; ++iter)
763+ {
764+ std::cerr << "Reference: " << (*iter).second
765+ << "is still in the nodes to references map" << std::endl;
766+ }
767+ ZORBA_FATAL(0, theNodeToReferencesMap.size() +
768+ " node references still in the nodes to references map");
769+ }
770+
771+ if (theReferencesToNodeMap.size() > 0)
772+ {
773+ RefNodeMap::iterator iter = theReferencesToNodeMap.begin();
774+ RefNodeMap::iterator end = theReferencesToNodeMap.end();
775+ for (; iter != end; ++iter)
776+ {
777+ std::cerr << "Reference: " << (*iter).first
778+ << "is still in the references to nodes map" << std::endl;
779+ }
780+ ZORBA_FATAL(0, theReferencesToNodeMap.size() +
781+ " node references still in the references to nodes map");
782+ }
783+
784 // do cleanup of the libxml2 library
785 // however, after that, a user will have to call
786 // LIBXML_TEST_VERSION if he wants to use libxml2
787@@ -1314,359 +1343,104 @@
788
789
790 /*******************************************************************************
791- Computes the URI for the given node.
792-********************************************************************************/
793-bool SimpleStore::getReference(store::Item_t& result, const store::Item* node)
794-{
795- std::ostringstream stream;
796-
797- const OrdPathNode* n = static_cast<const OrdPathNode*>(node);
798- stream << "zorba:"
799- << n->getCollectionId() << "."
800- << n->getTreeId() << "."
801- << n->getTree()->getPosition() + 1;
802-
803-#ifdef TEXT_ORDPATH
804-
805- if (n->getNodeKind() == store::StoreConsts::attributeNode)
806- {
807- stream << ".a."
808- }
809- else
810- {
811- stream << ".c."
812- }
813- stream << n->getOrdPath().serialize();
814-
815-#else
816-
817- if (n->getNodeKind() == store::StoreConsts::attributeNode)
818- {
819- stream << ".a."
820- << static_cast<const OrdPathNode*>(n)->getOrdPath().serialize();
821- }
822- else if (n->getNodeKind() == store::StoreConsts::textNode)
823- {
824- stream << ".a."
825- << static_cast<const OrdPathNode*>(n->getParent())->getOrdPath().serialize();
826- }
827- else
828- {
829- stream << ".c."
830- << static_cast<const OrdPathNode*>(n)->getOrdPath().serialize();
831- }
832-#endif
833-
834- zstring str(stream.str());
835-
836- return theItemFactory->createAnyURI(result, str);
837-}
838-
839-
840-/*******************************************************************************
841- Returns Item which is identified by a reference
842-
843- @param uri Has to be an xs:URI item
844- @returns referenced item if it exists, otherwise NULL
845-********************************************************************************/
846-bool SimpleStore::getNodeByReference(store::Item_t& result, const store::Item* uri)
847-{
848- const zstring& str = uri->getString();
849-
850- ulong prefixlen = (ulong)strlen("zorba:");
851-
852- if (strncmp(str.c_str(), "zorba:", prefixlen))
853- throw ZORBA_EXCEPTION(
854- zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS( str )
855- );
856-
857- const char* start;
858- long tmp = 0;
859-
860- //
861- // Decode collection id
862- //
863- start = str.c_str() + prefixlen;
864- char* next = const_cast<char*>(start);
865-
866- tmp = strtol(start, &next, 10);
867-
868- if (tmp < 0 || tmp == LONG_MAX)
869- throw ZORBA_EXCEPTION(
870- zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS( str )
871- );
872-
873- start = next;
874-
875- if (*start != '.')
876- throw ZORBA_EXCEPTION(
877- zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS( str )
878- );
879-
880- ++start;
881-
882- ulong collectionId = (ulong)tmp;
883-
884- //
885- // Decode tree id
886- //
887- tmp = strtol(start, &next, 10);
888-
889- if (tmp <= 0 || tmp == LONG_MAX)
890- throw ZORBA_EXCEPTION(
891- zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS( str )
892- );
893-
894- start = next;
895-
896- if (*start != '.')
897- throw ZORBA_EXCEPTION(
898- zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS( str )
899- );
900-
901- ++start;
902-
903- ulong treeId = (ulong)tmp;
904-
905- //
906- // Decode tree position within collection
907- //
908- tmp = strtol(start, &next, 10);
909-
910- if (tmp <= 0 || tmp == LONG_MAX)
911- throw ZORBA_EXCEPTION(
912- zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS( str )
913- );
914-
915- start = next;
916-
917- if (*start != '.')
918- throw ZORBA_EXCEPTION(
919- zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS( str )
920- );
921-
922- ++start;
923-
924- ulong treePos = (ulong)tmp;
925-
926- //
927- // Check if the uri specifies attribute node or not
928- //
929- bool attributeNode;
930-
931- if (*start == 'a')
932- attributeNode = true;
933- else if (*start == 'c')
934- attributeNode = false;
935- else
936- throw ZORBA_EXCEPTION(
937- zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS( str )
938- );
939-
940- ++start;
941- if (*start != '.')
942- throw ZORBA_EXCEPTION(
943- zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS( str )
944- );
945-
946- ++start;
947-
948- //
949- // Search for the tree
950- //
951- XmlNode* rootNode = NULL;
952-
953- if (collectionId == 0)
954- {
955- DocumentSet::iterator it = theDocuments.begin();
956- DocumentSet::iterator end = theDocuments.end();
957-
958- for (; it != end; ++it)
959- {
960- rootNode = (*it).second.getp();
961-
962- if (rootNode->getTreeId() == treeId)
963- break;
964- }
965-
966- if (it == end)
967- rootNode = NULL;
968- }
969- else
970- {
971- // Look for the collection
972- SimpleCollection* collection;
973-
974- CollectionIterator_t lIter = theCollections->collections();
975- lIter->open();
976-
977- store::Collection_t lCollection;
978- bool lFound = false;
979-
980- // search the collection
981- while (lIter->next(lCollection))
982- {
983- collection = static_cast<SimpleCollection*>(lCollection.getp());
984-
985- if (collection->getId() == collectionId) {
986- lFound = true;
987- break;
988- }
989- }
990-
991- if (!lFound)
992- {
993- lIter = theCollections->collections(true);
994- lIter->open();
995-
996- // search the collection
997- while (lIter->next(lCollection))
998- {
999- collection = static_cast<SimpleCollection*>(lCollection.getp());
1000-
1001- if (collection->getId() == collectionId) {
1002- lFound = true;
1003- break;
1004- }
1005- }
1006- }
1007-
1008- // If collection found, look for the tree
1009- if (lFound)
1010- {
1011- store::Item_t rootItem = collection->nodeAt(treePos);
1012-
1013- rootNode = BASE_NODE(rootItem);
1014-
1015- if (rootNode == NULL || rootNode->getTreeId() != treeId)
1016- {
1017- store::Iterator_t treeIter = collection->getIterator();
1018-
1019- treeIter->open();
1020-
1021- while (treeIter->next(rootItem))
1022- {
1023- rootNode = BASE_NODE(rootItem);
1024- if (rootNode->getTreeId() == treeId)
1025- break;
1026- }
1027-
1028- treeIter->close();
1029-
1030- rootNode = BASE_NODE(rootItem);
1031- }
1032- }
1033- }
1034-
1035- if (rootNode == NULL)
1036- {
1037- result = NULL;
1038- return false;
1039- }
1040-
1041- //
1042- // Search for node in the tree
1043- //
1044-
1045- OrdPath op((unsigned char*)start, (ulong)strlen(start));
1046-
1047-#ifdef TEXT_ORDPATH
1048- if (static_cast<OrdPathNode*>(rootNode)->getOrdPath() == op)
1049- {
1050- result = rootNode;
1051- return true;
1052- }
1053-#else
1054- if (rootNode->getNodeKind() == store::StoreConsts::textNode)
1055- {
1056- result = NULL;
1057- return false;
1058- }
1059- else if (static_cast<OrdPathNode*>(rootNode)->getOrdPath() == op)
1060- {
1061- result = rootNode;
1062- return true;
1063- }
1064-#endif
1065-
1066- XmlNode* parent = rootNode;
1067-
1068- while (1)
1069- {
1070- ulong i;
1071-
1072- if (parent->getNodeKind() != store::StoreConsts::documentNode &&
1073- parent->getNodeKind() != store::StoreConsts::elementNode)
1074- {
1075- result = NULL;
1076- return false;
1077- }
1078-
1079- if (attributeNode && parent->getNodeKind() == store::StoreConsts::elementNode)
1080- {
1081- ElementNode* elemParent = reinterpret_cast<ElementNode*>(parent);
1082-
1083- ulong numAttrs = elemParent->numAttrs();
1084- for (i = 0; i < numAttrs; i++)
1085- {
1086- AttributeNode* child = elemParent->getAttr(i);
1087-
1088- OrdPath::RelativePosition pos = child->getOrdPath().getRelativePosition(op);
1089-
1090- if (pos == OrdPath::SELF)
1091- {
1092- result = child;
1093- return true;
1094- }
1095- else if (pos != OrdPath::FOLLOWING)
1096- {
1097- result = NULL;
1098- return false;
1099- }
1100- }
1101- }
1102-
1103- InternalNode* parent2 = reinterpret_cast<InternalNode*>(parent);
1104-
1105- ulong numChildren = parent2->numChildren();
1106- for (i = 0; i < numChildren; i++)
1107- {
1108-#ifdef TEXT_ORDPATH
1109- OrdPathNode* child = static_cast<OrdPathNode*>(parent2->getChild(i));
1110-#else
1111- XmlNode* c = parent2->getChild(i);
1112-
1113- if (c->getNodeKind() == store::StoreConsts::textNode)
1114- continue;
1115-
1116- OrdPathNode* child = static_cast<OrdPathNode*>(c);
1117-#endif
1118-
1119- OrdPath::RelativePosition pos = child->getOrdPath().getRelativePosition(op);
1120-
1121- if (pos == OrdPath::SELF)
1122- {
1123- result = child;
1124- return true;
1125- }
1126- else if (pos == OrdPath::DESCENDANT)
1127- {
1128- parent = child;
1129- break;
1130- }
1131- else if (pos != OrdPath::FOLLOWING)
1132- {
1133- result = NULL;
1134- return false;
1135- }
1136- }
1137-
1138- if (i == numChildren)
1139- {
1140- result = NULL;
1141- return false;
1142- }
1143- }
1144+ Computes the reference of the given node.
1145+
1146+ @param node XDM node
1147+ @return the identifier as an item of type xs:anyURI
1148+********************************************************************************/
1149+bool SimpleStore::getReference(store::Item_t& result, store::Item* node)
1150+{
1151+ XmlNode* xmlNode = static_cast<XmlNode*>(node);
1152+
1153+ if (xmlNode->haveReference())
1154+ {
1155+ NodeRefMap::iterator resIt = theNodeToReferencesMap.find(xmlNode);
1156+
1157+ ZORBA_FATAL(resIt != theNodeToReferencesMap.end(),"Node reference cannot be found");
1158+
1159+ zstring id = (*resIt).second;
1160+ return theItemFactory->createAnyURI(result, id);
1161+ }
1162+
1163+ uuid_t uuid;
1164+ uuid_create(&uuid);
1165+ zstring uuidStr = uuidToURI(uuid);
1166+
1167+ xmlNode->setHaveReference();
1168+
1169+ theNodeToReferencesMap.insert(xmlNode, uuidStr);
1170+ theReferencesToNodeMap[uuidStr] = node;
1171+
1172+ return theItemFactory->createAnyURI(result, uuidStr);
1173+}
1174+
1175+
1176+/*******************************************************************************
1177+ Returns the node which is identified by the given reference.
1178+
1179+ @param reference an xs:anyURI item
1180+ @result the node identified by the reference, or NULL if no node with the given
1181+ reference exists
1182+ @return false if no node with the given reference exists; true otherwise.
1183+********************************************************************************/
1184+bool SimpleStore::getNodeByReference(store::Item_t& result, const zstring& reference)
1185+{
1186+ if (reference.length() != 45 ||
1187+ !utf8::match_whole(reference, "urn:uuid:[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"))
1188+ {
1189+ throw ZORBA_EXCEPTION(zerr::ZAPI0028_INVALID_NODE_URI, ERROR_PARAMS(reference));
1190+ }
1191+
1192+ RefNodeMap::iterator resIt;
1193+
1194+ if ((resIt = theReferencesToNodeMap.find(reference)) != theReferencesToNodeMap.end())
1195+ {
1196+ result = resIt->second;
1197+ return true;
1198+ }
1199+
1200+ result = NULL;
1201+ return false;
1202+}
1203+
1204+
1205+/*******************************************************************************
1206+ Returns whether a reference has already been generated for the given node.
1207+
1208+ @param item XDM node
1209+ @return whether a reference has already been generated for the given node.
1210+********************************************************************************/
1211+bool SimpleStore::hasReference(const store::Item* node)
1212+{
1213+ return static_cast<const XmlNode*>(node)->haveReference();
1214+}
1215+
1216+
1217+/*******************************************************************************
1218+ Removes a node from the reference-to-nodes and nodes-to-references maps.
1219+
1220+ @param node XDM node
1221+ @return whether the node was registered or not.
1222+********************************************************************************/
1223+bool SimpleStore::unregisterNode(XmlNode* node)
1224+{
1225+ if (!node->haveReference())
1226+ return false;
1227+
1228+ NodeRefMap::iterator resIt;
1229+
1230+ if ((resIt = theNodeToReferencesMap.find(node)) != theNodeToReferencesMap.end())
1231+ {
1232+ zstring value = (*resIt).second;
1233+ theNodeToReferencesMap.erase(resIt);
1234+ node->resetHaveReference();
1235+
1236+ theReferencesToNodeMap.erase(value);
1237+
1238+ return true;
1239+ }
1240+ else
1241+ return false;
1242 }
1243
1244
1245
1246=== modified file 'src/store/naive/simple_store.h'
1247--- src/store/naive/simple_store.h 2011-09-26 22:49:54 +0000
1248+++ src/store/naive/simple_store.h 2011-10-10 10:35:29 +0000
1249@@ -18,6 +18,7 @@
1250
1251 #include "store/naive/shared_types.h"
1252 #include "store/naive/store_defs.h"
1253+#include "store/naive/hashmap_nodep.h"
1254
1255 #if (defined (WIN32) || defined (WINCE))
1256 #include "store/naive/node_items.h"
1257@@ -66,35 +67,42 @@
1258
1259
1260 /*******************************************************************************
1261- theSchemaTypeNames : Maps each enum value from SchemaTypeNames (see
1262- store_defs.h) to its associated QName item.
1263-
1264- theCollectionCounter : Incremented every time a new collection is created. The
1265- current value of the counter is then assigned as the
1266- id of the new collection.
1267-
1268- theNamespacePool :
1269- theQNamePool :
1270-
1271- theItemFactory : Factory to create items.
1272- theIteratorFactory : Factory to create iterators.
1273- theNodeFactory : Factory to create node items.
1274-
1275- theDocuments : A hashmap that for each xml tree that does not belong
1276- to any collection, maps the URI of the tree to the root
1277- node of the tree.
1278- theCollections : Container which contains the collections of the store.
1279- It includes a map that maps the qname of each collection
1280- to the collection's container object.
1281- theIndices : A hashmap that for each index, maps the qname of the
1282- index to the index container object.
1283- theICs : A hashmap the for each integrity constraint, maps the
1284- qname of the ic to the ic's container object.
1285+ theSchemaTypeNames : Maps each enum value from SchemaTypeNames (see
1286+ store_defs.h) to its associated QName item.
1287+
1288+ theCollectionCounter : Incremented every time a new collection is created. The
1289+ current value of the counter is then assigned as the
1290+ id of the new collection.
1291+
1292+ theNamespacePool :
1293+ theQNamePool :
1294+
1295+ theItemFactory : Factory to create items.
1296+ theIteratorFactory : Factory to create iterators.
1297+ theNodeFactory : Factory to create node items.
1298+
1299+ theDocuments : A hashmap that for each xml tree that does not belong
1300+ to any collection, maps the URI of the tree to the root
1301+ node of the tree.
1302+ theCollections : Container which contains the collections of the store.
1303+ It includes a map that maps the qname of each collection
1304+ to the collection's container object.
1305+ theIndices : A hashmap that for each index, maps the qname of the
1306+ index to the index container object.
1307+ theICs : A hashmap the for each integrity constraint, maps the
1308+ qname of the ic to the ic's container object.
1309+ theReferencesToNodeMap : A hashmap that maps node references to the referenced
1310+ nodes
1311+ theNodeToReferencesMap : A hashmap that maps nodes into their references
1312+
1313 ********************************************************************************/
1314 class SimpleStore : public store::Store
1315 {
1316 friend class zorba::StoreManager;
1317
1318+ typedef std::map<const zstring, const store::Item*> RefNodeMap;
1319+ typedef NodePointerHashMap<zstring> NodeRefMap;
1320+
1321 public:
1322 static const char* XS_URI;
1323 static const char* XML_URI;
1324@@ -142,25 +150,15 @@
1325
1326 long theTraceLevel;
1327
1328+ RefNodeMap theReferencesToNodeMap;
1329+ NodeRefMap theNodeToReferencesMap;
1330+
1331 #ifndef ZORBA_NO_FULL_TEXT
1332 internal::StemmerProvider const * theStemmerProvider;
1333 TokenizerProvider const * theTokenizerProvider;
1334 #endif /* ZORBA_NO_FULL_TEXT */
1335
1336 public:
1337- // needs to be virtual to allow implementation of additional stores
1338- virtual void populateValueIndex(
1339- const store::Index_t& index,
1340- store::Iterator* sourceIter,
1341- ulong numColumns);
1342-
1343- // needs to be virtual to allow implementation of additional stores
1344- virtual void populateGeneralIndex(
1345- const store::Index_t& index,
1346- store::Iterator* sourceIter,
1347- ulong numColumns);
1348-
1349-public:
1350 void shutdown(bool soft = true);
1351
1352 store::ItemFactory* getItemFactory() const;
1353@@ -179,7 +177,9 @@
1354
1355 long getTraceLevel() const { return theTraceLevel; }
1356
1357- XmlLoader* getXmlLoader(XQueryDiagnostics*, const store::LoadProperties& loadProperties);
1358+ XmlLoader* getXmlLoader(
1359+ XQueryDiagnostics*,
1360+ const store::LoadProperties& loadProperties);
1361
1362 ulong createCollectionId();
1363
1364@@ -204,16 +204,30 @@
1365 store::Iterator_t listCollectionNames(bool aDynamicCollections = false);
1366
1367 store::Index_t createIndex(
1368- const store::Item_t& qname,
1369- const store::IndexSpecification& spec,
1370- store::Iterator* sourceIter);
1371-
1372- // needs to be virtual to allow implementation of additional stores
1373- virtual
1374- store::Index_t refreshIndex(
1375- const store::Item_t& qname,
1376- const store::IndexSpecification& spec,
1377- store::Iterator* sourceIter);
1378+ const store::Item_t& qname,
1379+ const store::IndexSpecification& spec,
1380+ store::Iterator* sourceIter);
1381+
1382+ // needs to be virtual to allow implementation of additional stores
1383+ virtual void populateValueIndex(
1384+ const store::Index_t& index,
1385+ store::Iterator* sourceIter,
1386+ ulong numColumns);
1387+
1388+ // needs to be virtual to allow implementation of additional stores
1389+ virtual void populateGeneralIndex(
1390+ const store::Index_t& index,
1391+ store::Iterator* sourceIter,
1392+ ulong numColumns);
1393+
1394+ // needs to be virtual to allow implementation of additional stores
1395+ virtual store::Index_t refreshIndex(
1396+ const store::Item_t& qname,
1397+ const store::IndexSpecification& spec,
1398+ store::Iterator* sourceIter);
1399+
1400+ // needs to be virtual to allow implementation of additional stores
1401+ virtual const IndexSet& getIndices() const { return theIndices; }
1402
1403 void addIndex(store::Index_t& index);
1404
1405@@ -223,23 +237,20 @@
1406
1407 store::Iterator_t listIndexNames();
1408
1409- // needs to be virtual to allow implementation of additional stores
1410- virtual
1411- const IndexSet& getIndices() const { return theIndices; }
1412-
1413 store::IC_t activateIC(
1414- const store::Item_t& icQName,
1415- const store::Item_t& collectionQName,
1416- bool& isApplied);
1417-
1418+ const store::Item_t& icQName,
1419+ const store::Item_t& collectionQName,
1420+ bool& isApplied);
1421+
1422 store::IC_t activateForeignKeyIC(
1423- const store::Item_t& icQName,
1424- const store::Item_t& fromCollectionQName,
1425- const store::Item_t& toCollectionQName,
1426- bool& isApplied);
1427+ const store::Item_t& icQName,
1428+ const store::Item_t& fromCollectionQName,
1429+ const store::Item_t& toCollectionQName,
1430+ bool& isApplied);
1431
1432- store::IC_t deactivateIC(const store::Item_t& icQName,
1433- bool& isApplied);
1434+ store::IC_t deactivateIC(
1435+ const store::Item_t& icQName,
1436+ bool& isApplied);
1437
1438 store::Iterator_t listActiveICNames();
1439
1440@@ -328,9 +339,17 @@
1441 bool& found,
1442 bool& unique);
1443
1444- bool getReference(store::Item_t& result, const store::Item* node);
1445-
1446- bool getNodeByReference(store::Item_t& result, const store::Item* uri);
1447+ /* ------------------------ Node Reference Management ---------------------------*/
1448+
1449+ bool getReference(store::Item_t& result, store::Item* node);
1450+
1451+ bool hasReference(const store::Item* node);
1452+
1453+ bool getNodeByReference(store::Item_t& result, const zstring& reference);
1454+
1455+ bool unregisterNode(XmlNode* node);
1456+
1457+ /* ------------------------ Temp Sequence Management ---------------------------*/
1458
1459 store::TempSeq_t createTempSeq(bool lazy);
1460
1461
1462=== modified file 'src/util/uuid/uuid.cpp'
1463--- src/util/uuid/uuid.cpp 2011-09-02 21:41:55 +0000
1464+++ src/util/uuid/uuid.cpp 2011-10-10 10:35:29 +0000
1465@@ -235,6 +235,18 @@
1466 return lResult;
1467 }
1468
1469+/* uuidToString -- transform a UUID to a uri*/
1470+zstring uuidToURI(const uuid_t& u)
1471+{
1472+ char lBuffer[200];
1473+ sprintf(lBuffer, "urn:uuid:%8.8x-%4.4x-%4.4x-%2.2x%2.2x-9300a64ac3cd", u.time_low, u.time_mid,
1474+ u.time_hi_and_version, u.clock_seq_hi_and_reserved,
1475+ u.clock_seq_low);
1476+
1477+ zstring lResult = lBuffer;
1478+ return lResult;
1479+}
1480+
1481 /*
1482 //This appendix lists the name space IDs for some potentially
1483 //interesting namespaces, as initialized C structures and in the
1484
1485=== modified file 'src/util/uuid/uuid.h'
1486--- src/util/uuid/uuid.h 2011-09-02 21:41:55 +0000
1487+++ src/util/uuid/uuid.h 2011-10-10 10:35:29 +0000
1488@@ -36,6 +36,9 @@
1489 /* uuidToString -- transform a UUID to a string */
1490 zstring uuidToString(const uuid_t& uuid);
1491
1492+/* uuidToURI -- transform a UUID to a URI-formatted string */
1493+zstring uuidToURI(const uuid_t& uuid);
1494+
1495 } // namespace zorba
1496 #endif /* ZORBA_UTIL_UUID_H */
1497 /* vim:set et sw=2 ts=2: */
1498
1499=== modified file 'src/zorbautils/hashmap.h'
1500--- src/zorbautils/hashmap.h 2011-10-03 08:49:55 +0000
1501+++ src/zorbautils/hashmap.h 2011-10-10 10:35:29 +0000
1502@@ -416,14 +416,25 @@
1503 return (theNumEntries == 0);
1504 }
1505
1506+
1507 /*******************************************************************************
1508
1509 ********************************************************************************/
1510-ulong object_count() const
1511+ulong size() const
1512 {
1513 return theNumEntries;
1514 }
1515
1516+
1517+/*******************************************************************************
1518+
1519+********************************************************************************/
1520+size_t capacity() const
1521+{
1522+ return theHashTab.size();
1523+}
1524+
1525+
1526 /*******************************************************************************
1527
1528 ********************************************************************************/
1529@@ -432,14 +443,6 @@
1530 return theCompareFunction;
1531 }
1532
1533-/*******************************************************************************
1534-
1535-********************************************************************************/
1536-size_t capacity() const
1537-{
1538- return theHashTab.size();
1539-}
1540-
1541
1542 /*******************************************************************************
1543
1544@@ -566,6 +569,30 @@
1545 /******************************************************************************
1546 If the set does not already contain an item I that is "equal" to the given
1547 item, make a copy of the given item and its associated value and place the
1548+ new (item, value) pair in the map; then return true. Otherwise, return false.
1549+********************************************************************************/
1550+bool insert(const std::pair<const T, V>& pair)
1551+{
1552+ bool found;
1553+ ulong hval = hash(pair.first);
1554+
1555+ SYNC_CODE(AutoMutex lock(theMutexp);)
1556+
1557+ HASHENTRY<T, V>* entry = hashInsert(pair.first, hval, found);
1558+
1559+ if (!found)
1560+ {
1561+ entry->theItem = pair.first;
1562+ entry->theValue = pair.second;
1563+ }
1564+
1565+ return !found;
1566+}
1567+
1568+
1569+/******************************************************************************
1570+ If the set does not already contain an item I that is "equal" to the given
1571+ item, make a copy of the given item and its associated value and place the
1572 new (item, value) pair in the map; then return true. Otherwise, return false,
1573 as well as a copy of the value associated with the found item I.
1574 ********************************************************************************/
1575
1576=== added file 'test/rbkt/ExpQueryResults/zorba/paths/ref1.xml.res'
1577--- test/rbkt/ExpQueryResults/zorba/paths/ref1.xml.res 1970-01-01 00:00:00 +0000
1578+++ test/rbkt/ExpQueryResults/zorba/paths/ref1.xml.res 2011-10-10 10:35:29 +0000
1579@@ -0,0 +1,387 @@
1580+<?xml version="1.0" encoding="UTF-8"?>
1581+<people>
1582+<person id="person0">
1583+<name>Huei Demke</name>
1584+<emailaddress>mailto:Demke@uu.se</emailaddress>
1585+<address>
1586+<street>95 Grinter St</street>
1587+<city>Macon</city>
1588+<country>United States</country>
1589+<zipcode>32</zipcode>
1590+</address>
1591+<creditcard>8182 1228 4493 3873</creditcard>
1592+<profile income="55386.86">
1593+<education>High School</education>
1594+<gender>male</gender>
1595+<business>No</business>
1596+<age>37</age>
1597+</profile>
1598+</person>
1599+<person id="person1">
1600+<name>Daishiro Juric</name>
1601+<emailaddress>mailto:Juric@rwth-aachen.de</emailaddress>
1602+<phone>+0 (692) 53964736</phone>
1603+<address>
1604+<street>5 Pinet St</street>
1605+<city>Athens</city>
1606+<country>United States</country>
1607+<province>Vermont</province>
1608+<zipcode>13</zipcode>
1609+</address>
1610+<homepage>http://www.rwth-aachen.de/~Juric</homepage>
1611+<creditcard>7833 6950 5399 8913</creditcard>
1612+<watches>
1613+<watch open_auction="open_auction2"/>
1614+<watch open_auction="open_auction4"/>
1615+<watch open_auction="open_auction5"/>
1616+<watch open_auction="open_auction6"/>
1617+<watch open_auction="open_auction9"/>
1618+<watch open_auction="open_auction0"/>
1619+</watches>
1620+</person>
1621+<person id="person2">
1622+<name>Kawon Unni</name>
1623+<emailaddress>mailto:Unni@llnl.gov</emailaddress>
1624+<phone>+0 (866) 58076283</phone>
1625+<watches>
1626+<watch open_auction="open_auction0"/>
1627+<watch open_auction="open_auction7"/>
1628+<watch open_auction="open_auction2"/>
1629+<watch open_auction="open_auction4"/>
1630+</watches>
1631+</person>
1632+<person id="person3">
1633+<name>Ewing Andrade</name>
1634+<emailaddress>mailto:Andrade@fsu.edu</emailaddress>
1635+<profile income="41889.41">
1636+<interest category="category0"/>
1637+<interest category="category0"/>
1638+<education>Graduate School</education>
1639+<gender>female</gender>
1640+<business>Yes</business>
1641+<age>18</age>
1642+</profile>
1643+<watches>
1644+<watch open_auction="open_auction6"/>
1645+<watch open_auction="open_auction10"/>
1646+<watch open_auction="open_auction2"/>
1647+<watch open_auction="open_auction6"/>
1648+<watch open_auction="open_auction5"/>
1649+</watches>
1650+</person>
1651+<person id="person4">
1652+<name>Jamaludin Kleiser</name>
1653+<emailaddress>mailto:Kleiser@edu.hk</emailaddress>
1654+<phone>+0 (400) 25499686</phone>
1655+<homepage>http://www.edu.hk/~Kleiser</homepage>
1656+<profile income="9876.00">
1657+<interest category="category0"/>
1658+<interest category="category0"/>
1659+<interest category="category0"/>
1660+<interest category="category0"/>
1661+<interest category="category0"/>
1662+<interest category="category0"/>
1663+<education>High School</education>
1664+<business>No</business>
1665+<age>34</age>
1666+</profile>
1667+</person>
1668+<person id="person5">
1669+<name>Eliana Ruemmler</name>
1670+<emailaddress>mailto:Ruemmler@forth.gr</emailaddress>
1671+<phone>+0 (361) 10427629</phone>
1672+<homepage>http://www.forth.gr/~Ruemmler</homepage>
1673+<watches>
1674+</watches>
1675+</person>
1676+<person id="person6">
1677+<name>Bassem Nagasaki</name>
1678+<emailaddress>mailto:Nagasaki@panasonic.com</emailaddress>
1679+<phone>+0 (182) 62129440</phone>
1680+<homepage>http://www.panasonic.com/~Nagasaki</homepage>
1681+<creditcard>6012 3708 3300 9328</creditcard>
1682+</person>
1683+<person id="person7">
1684+<name>Mehrdad McCay</name>
1685+<emailaddress>mailto:McCay@acm.org</emailaddress>
1686+<address>
1687+<street>40 Kipper St</street>
1688+<city>Lyon</city>
1689+<country>United States</country>
1690+<zipcode>33</zipcode>
1691+</address>
1692+<homepage>http://www.acm.org/~McCay</homepage>
1693+<watches>
1694+<watch open_auction="open_auction10"/>
1695+<watch open_auction="open_auction6"/>
1696+<watch open_auction="open_auction7"/>
1697+<watch open_auction="open_auction6"/>
1698+<watch open_auction="open_auction10"/>
1699+</watches>
1700+</person>
1701+<person id="person8">
1702+<name>Bassem Manderick</name>
1703+<emailaddress>mailto:Manderick@uiuc.edu</emailaddress>
1704+<phone>+0 (18) 14026838</phone>
1705+<address>
1706+<street>45 Ratnaker St</street>
1707+<city>Zihuatenejo</city>
1708+<country>United States</country>
1709+<province>Illinois</province>
1710+<zipcode>4</zipcode>
1711+</address>
1712+<creditcard>8940 7694 6616 2527</creditcard>
1713+<watches>
1714+<watch open_auction="open_auction2"/>
1715+<watch open_auction="open_auction7"/>
1716+<watch open_auction="open_auction8"/>
1717+<watch open_auction="open_auction8"/>
1718+<watch open_auction="open_auction2"/>
1719+</watches>
1720+</person>
1721+<person id="person9">
1722+<name>Jarkko Nozawa</name>
1723+<emailaddress>mailto:Nozawa@concordia.ca</emailaddress>
1724+<phone>+0 (835) 5433372</phone>
1725+<homepage>http://www.concordia.ca/~Nozawa</homepage>
1726+<creditcard>2447 4672 2532 3021</creditcard>
1727+<profile income="57878.50">
1728+<interest category="category0"/>
1729+<interest category="category0"/>
1730+<interest category="category0"/>
1731+<interest category="category0"/>
1732+<interest category="category0"/>
1733+<interest category="category0"/>
1734+<interest category="category0"/>
1735+<interest category="category0"/>
1736+<interest category="category0"/>
1737+<interest category="category0"/>
1738+<interest category="category0"/>
1739+<interest category="category0"/>
1740+<business>No</business>
1741+<age>33</age>
1742+</profile>
1743+</person>
1744+<person id="person10">
1745+<name>Masanao Marsiglia</name>
1746+<emailaddress>mailto:Marsiglia@cas.cz</emailaddress>
1747+<address>
1748+<street>22 Caticha St</street>
1749+<city>Phoenix</city>
1750+<country>United States</country>
1751+<province>Alaska</province>
1752+<zipcode>31</zipcode>
1753+</address>
1754+<creditcard>8543 4364 4394 3142</creditcard>
1755+<profile income="44300.88">
1756+<interest category="category0"/>
1757+<interest category="category0"/>
1758+<education>Other</education>
1759+<gender>female</gender>
1760+<business>Yes</business>
1761+<age>48</age>
1762+</profile>
1763+<watches>
1764+<watch open_auction="open_auction0"/>
1765+<watch open_auction="open_auction9"/>
1766+</watches>
1767+</person>
1768+<person id="person11">
1769+<name>Saul Schaap</name>
1770+<emailaddress>mailto:Schaap@forth.gr</emailaddress>
1771+<phone>+0 (255) 85051213</phone>
1772+<address>
1773+<street>11 Gumm St</street>
1774+<city>Cody</city>
1775+<country>United States</country>
1776+<province>Montana</province>
1777+<zipcode>28</zipcode>
1778+</address>
1779+<profile income="33731.14">
1780+<interest category="category0"/>
1781+<education>College</education>
1782+<business>Yes</business>
1783+<age>23</age>
1784+</profile>
1785+<watches>
1786+<watch open_auction="open_auction3"/>
1787+<watch open_auction="open_auction7"/>
1788+<watch open_auction="open_auction0"/>
1789+<watch open_auction="open_auction1"/>
1790+<watch open_auction="open_auction8"/>
1791+<watch open_auction="open_auction0"/>
1792+<watch open_auction="open_auction9"/>
1793+</watches>
1794+</person>
1795+<person id="person12">
1796+<name>Kishor Monkewich</name>
1797+<emailaddress>mailto:Monkewich@llnl.gov</emailaddress>
1798+<phone>+0 (254) 26597439</phone>
1799+<address>
1800+<street>6 Thiria St</street>
1801+<city>Denver</city>
1802+<country>United States</country>
1803+<province>Mississipi</province>
1804+<zipcode>20</zipcode>
1805+</address>
1806+<homepage>http://www.llnl.gov/~Monkewich</homepage>
1807+<creditcard>7036 1307 7693 1072</creditcard>
1808+<profile income="43552.04">
1809+<interest category="category0"/>
1810+<gender>female</gender>
1811+<business>Yes</business>
1812+</profile>
1813+</person>
1814+<person id="person13">
1815+<name>Martti Halgason</name>
1816+<emailaddress>mailto:Halgason@bell-labs.com</emailaddress>
1817+<phone>+0 (778) 41220156</phone>
1818+<profile income="41407.27">
1819+<interest category="category0"/>
1820+<interest category="category0"/>
1821+<interest category="category0"/>
1822+<interest category="category0"/>
1823+<gender>female</gender>
1824+<business>Yes</business>
1825+<age>20</age>
1826+</profile>
1827+<watches>
1828+<watch open_auction="open_auction7"/>
1829+</watches>
1830+</person>
1831+<person id="person14">
1832+<name>Laurian Grass</name>
1833+<emailaddress>mailto:Grass@yorku.ca</emailaddress>
1834+<phone>+0 (486) 33977729</phone>
1835+<address>
1836+<street>44 Wergeland St</street>
1837+<city>Mobile</city>
1838+<country>United States</country>
1839+<zipcode>29</zipcode>
1840+</address>
1841+<creditcard>1021 8216 1485 5908</creditcard>
1842+<profile income="53231.89">
1843+<interest category="category0"/>
1844+<gender>male</gender>
1845+<business>Yes</business>
1846+<age>28</age>
1847+</profile>
1848+</person>
1849+<person id="person15">
1850+<name>Shooichi Oerlemans</name>
1851+<emailaddress>mailto:Oerlemans@ac.jp</emailaddress>
1852+<address>
1853+<street>7 Rein St</street>
1854+<city>Alexandria</city>
1855+<country>Cook Islands</country>
1856+<zipcode>13</zipcode>
1857+</address>
1858+<creditcard>1796 7353 7134 5098</creditcard>
1859+<watches>
1860+<watch open_auction="open_auction9"/>
1861+<watch open_auction="open_auction1"/>
1862+<watch open_auction="open_auction2"/>
1863+<watch open_auction="open_auction6"/>
1864+<watch open_auction="open_auction8"/>
1865+<watch open_auction="open_auction8"/>
1866+</watches>
1867+</person>
1868+<person id="person16">
1869+<name>Uzi Atrawala</name>
1870+<emailaddress>mailto:Atrawala@cwru.edu</emailaddress>
1871+<phone>+49 (161) 95788409</phone>
1872+<address>
1873+<street>77 Coyle St</street>
1874+<city>Great</city>
1875+<country>United States</country>
1876+<province>Oklahoma</province>
1877+<zipcode>14</zipcode>
1878+</address>
1879+<profile income="26302.86">
1880+<interest category="category0"/>
1881+<interest category="category0"/>
1882+<interest category="category0"/>
1883+<gender>male</gender>
1884+<business>Yes</business>
1885+</profile>
1886+</person>
1887+<person id="person17">
1888+<name>Aloys Singleton</name>
1889+<emailaddress>mailto:Singleton@berkeley.edu</emailaddress>
1890+<phone>+0 (735) 97531072</phone>
1891+</person>
1892+<person id="person18">
1893+<name>Maha DuBourdieux</name>
1894+<emailaddress>mailto:DuBourdieux@clustra.com</emailaddress>
1895+<phone>+0 (43) 57060411</phone>
1896+<homepage>http://www.clustra.com/~DuBourdieux</homepage>
1897+<profile income="32624.17">
1898+<interest category="category0"/>
1899+<business>Yes</business>
1900+</profile>
1901+<watches>
1902+</watches>
1903+</person>
1904+<person id="person19">
1905+<name>Masaski Carrere</name>
1906+<emailaddress>mailto:Carrere@lri.fr</emailaddress>
1907+<phone>+0 (155) 68703448</phone>
1908+<address>
1909+<street>51 Bedard St</street>
1910+<city>Copenhagen</city>
1911+<country>United States</country>
1912+<zipcode>29</zipcode>
1913+</address>
1914+<homepage>http://www.lri.fr/~Carrere</homepage>
1915+<watches>
1916+<watch open_auction="open_auction8"/>
1917+</watches>
1918+</person>
1919+<person id="person20">
1920+<name>Nestoras Gausemeier</name>
1921+<emailaddress>mailto:Gausemeier@versata.com</emailaddress>
1922+<phone>+0 (864) 72833728</phone>
1923+<address>
1924+<street>80 Melter St</street>
1925+<city>Ciudad</city>
1926+<country>Greenland</country>
1927+<zipcode>23</zipcode>
1928+</address>
1929+<creditcard>4586 2519 6227 6395</creditcard>
1930+</person>
1931+<person id="person21">
1932+<name>Yechezkel Calmet</name>
1933+<emailaddress>mailto:Calmet@yorku.ca</emailaddress>
1934+<watches>
1935+<watch open_auction="open_auction3"/>
1936+<watch open_auction="open_auction9"/>
1937+<watch open_auction="open_auction0"/>
1938+<watch open_auction="open_auction6"/>
1939+<watch open_auction="open_auction6"/>
1940+<watch open_auction="open_auction2"/>
1941+</watches>
1942+</person>
1943+<person id="person22">
1944+<name>Slavian Usery</name>
1945+<emailaddress>mailto:Usery@rutgers.edu</emailaddress>
1946+<creditcard>7501 3122 6462 7866</creditcard>
1947+<watches>
1948+</watches>
1949+</person>
1950+<person id="person23">
1951+<name>Piere Schiex</name>
1952+<emailaddress>mailto:Schiex@sfu.ca</emailaddress>
1953+<homepage>http://www.sfu.ca/~Schiex</homepage>
1954+<creditcard>1536 3643 2092 5012</creditcard>
1955+<watches>
1956+<watch open_auction="open_auction6"/>
1957+<watch open_auction="open_auction4"/>
1958+</watches>
1959+</person>
1960+<person id="person24">
1961+<name>Shaoyun Morreau</name>
1962+<emailaddress>mailto:Morreau@ucsb.edu</emailaddress>
1963+<phone>+83 (890) 82752371</phone>
1964+<creditcard>6926 3703 6920 9765</creditcard>
1965+</person>
1966+</people>
1967\ No newline at end of file
1968
1969=== added file 'test/rbkt/ExpQueryResults/zorba/reference/reference_1.xml.res'
1970--- test/rbkt/ExpQueryResults/zorba/reference/reference_1.xml.res 1970-01-01 00:00:00 +0000
1971+++ test/rbkt/ExpQueryResults/zorba/reference/reference_1.xml.res 2011-10-10 10:35:29 +0000
1972@@ -0,0 +1,2 @@
1973+<?xml version="1.0" encoding="UTF-8"?>
1974+<result><before>45</before><after>45</after><stable>true</stable></result>
1975\ No newline at end of file
1976
1977=== added file 'test/rbkt/ExpQueryResults/zorba/reference/reference_2.xml.res'
1978--- test/rbkt/ExpQueryResults/zorba/reference/reference_2.xml.res 1970-01-01 00:00:00 +0000
1979+++ test/rbkt/ExpQueryResults/zorba/reference/reference_2.xml.res 2011-10-10 10:35:29 +0000
1980@@ -0,0 +1,2 @@
1981+<?xml version="1.0" encoding="UTF-8"?>
1982+<elem>elem</elem><attr attr="attr"/><?pi pi?><!--comment-->document
1983\ No newline at end of file
1984
1985=== added file 'test/rbkt/ExpQueryResults/zorba/reference/reference_3.xml.res'
1986--- test/rbkt/ExpQueryResults/zorba/reference/reference_3.xml.res 1970-01-01 00:00:00 +0000
1987+++ test/rbkt/ExpQueryResults/zorba/reference/reference_3.xml.res 2011-10-10 10:35:29 +0000
1988@@ -0,0 +1,2 @@
1989+<?xml version="1.0" encoding="UTF-8"?>
1990+<result><out-of-module-global><root>reference.xqlib</root></out-of-module-global><put-doc><root>doc</root></put-doc><in-scope><root>global</root></in-scope><temporary-variable-out-of-scope/><temporary-variable-in-scope><root>1</root><root>2</root><root>3</root></temporary-variable-in-scope><temporary-variable-in-scope><root>temp</root></temporary-variable-in-scope><in-map><a>1</a></in-map></result>
1991\ No newline at end of file
1992
1993=== added file 'test/rbkt/ExpQueryResults/zorba/reference/reference_4.xml.res'
1994--- test/rbkt/ExpQueryResults/zorba/reference/reference_4.xml.res 1970-01-01 00:00:00 +0000
1995+++ test/rbkt/ExpQueryResults/zorba/reference/reference_4.xml.res 2011-10-10 10:35:29 +0000
1996@@ -0,0 +1,1 @@
1997+<?xml version="1.0" encoding="UTF-8"?>
1998
1999=== added file 'test/rbkt/ExpQueryResults/zorba/reference/reference_5.xml.res'
2000--- test/rbkt/ExpQueryResults/zorba/reference/reference_5.xml.res 1970-01-01 00:00:00 +0000
2001+++ test/rbkt/ExpQueryResults/zorba/reference/reference_5.xml.res 2011-10-10 10:35:29 +0000
2002@@ -0,0 +1,2 @@
2003+<?xml version="1.0" encoding="UTF-8"?>
2004+<result><temporary-variable-in-scope><root>temp</root></temporary-variable-in-scope><temporary-variable-in-scope><root>temp</root></temporary-variable-in-scope><temporary-variable-in-scope><root>temp</root><root>temp</root><root>temp</root></temporary-variable-in-scope><temporary-variable-in-scope><root>temp</root></temporary-variable-in-scope></result>
2005
2006=== modified file 'test/rbkt/ExpQueryResults/zorba/reference/reference_coll_1.xml.res'
2007--- test/rbkt/ExpQueryResults/zorba/reference/reference_coll_1.xml.res 2011-06-24 19:58:33 +0000
2008+++ test/rbkt/ExpQueryResults/zorba/reference/reference_coll_1.xml.res 2011-10-10 10:35:29 +0000
2009@@ -1,1 +1,2 @@
2010-<b><z/></b>
2011+<?xml version="1.0" encoding="UTF-8"?>
2012+<b><z/></b>
2013\ No newline at end of file
2014
2015=== modified file 'test/rbkt/ExpQueryResults/zorba/reference/reference_coll_2.xml.res'
2016--- test/rbkt/ExpQueryResults/zorba/reference/reference_coll_2.xml.res 2011-06-24 19:58:33 +0000
2017+++ test/rbkt/ExpQueryResults/zorba/reference/reference_coll_2.xml.res 2011-10-10 10:35:29 +0000
2018@@ -1,1 +1,2 @@
2019-<z/>
2020+<?xml version="1.0" encoding="UTF-8"?>
2021+<z/>
2022\ No newline at end of file
2023
2024=== modified file 'test/rbkt/ExpQueryResults/zorba/reference/reference_coll_3.xml.res'
2025--- test/rbkt/ExpQueryResults/zorba/reference/reference_coll_3.xml.res 2011-06-24 19:58:33 +0000
2026+++ test/rbkt/ExpQueryResults/zorba/reference/reference_coll_3.xml.res 2011-10-10 10:35:29 +0000
2027@@ -1,1 +1,2 @@
2028-e
2029+<?xml version="1.0" encoding="UTF-8"?>
2030+e
2031\ No newline at end of file
2032
2033=== modified file 'test/rbkt/Queries/CMakeLists.txt'
2034--- test/rbkt/Queries/CMakeLists.txt 2011-10-09 16:27:19 +0000
2035+++ test/rbkt/Queries/CMakeLists.txt 2011-10-10 10:35:29 +0000
2036@@ -286,3 +286,6 @@
2037
2038 EXPECTED_FAILURE(test/rbkt/zorba/http-client/put/put3_binary_element 3391756)
2039 EXPECTED_FAILURE(test/rbkt/zorba/http-client/post/post3_binary_element 3391756)
2040+
2041+EXPECTED_FAILURE(test/rbkt/zorba/reference/reference_5 868640)
2042+
2043
2044=== modified file 'test/rbkt/Queries/zorba/paths/ref1.spec'
2045--- test/rbkt/Queries/zorba/paths/ref1.spec 2011-08-04 02:39:56 +0000
2046+++ test/rbkt/Queries/zorba/paths/ref1.spec 2011-10-10 10:35:29 +0000
2047@@ -1,4 +1,3 @@
2048 Args:
2049 -x
2050 input-context:=xs:string($RBKT_SRC_DIR/Queries/zorba/xmark/auction.xml)
2051-Error: http://www.zorba-xquery.com/errors:ZAPI0080
2052
2053=== removed file 'test/rbkt/Queries/zorba/reference/error.spec'
2054--- test/rbkt/Queries/zorba/reference/error.spec 2011-06-09 12:58:16 +0000
2055+++ test/rbkt/Queries/zorba/reference/error.spec 1970-01-01 00:00:00 +0000
2056@@ -1,4 +0,0 @@
2057-Args:
2058--x
2059-input-context:=xs:string($RBKT_SRC_DIR/Queries/zorba/reference/books.xml)
2060-Error: http://www.w3.org/2005/xqt-errors:XPST0017
2061
2062=== removed file 'test/rbkt/Queries/zorba/reference/error.xq'
2063--- test/rbkt/Queries/zorba/reference/error.xq 2010-11-09 22:35:09 +0000
2064+++ test/rbkt/Queries/zorba/reference/error.xq 1970-01-01 00:00:00 +0000
2065@@ -1,6 +0,0 @@
2066-declare namespace ref = "http://www.zorba-xquery.com/modules/node-reference";
2067-
2068-declare variable $input-context external;
2069-
2070-let $book := doc($input-context)/bib/book[1]
2071-return ref:node-reference($book)
2072
2073=== added file 'test/rbkt/Queries/zorba/reference/reference.xqlib'
2074--- test/rbkt/Queries/zorba/reference/reference.xqlib 1970-01-01 00:00:00 +0000
2075+++ test/rbkt/Queries/zorba/reference/reference.xqlib 2011-10-10 10:35:29 +0000
2076@@ -0,0 +1,3 @@
2077+module namespace idd= "http://www.zorba-xquery.com/reference";
2078+
2079+declare variable $idd:node:=<root>reference.xqlib</root>;
2080
2081=== added file 'test/rbkt/Queries/zorba/reference/reference_1.xq'
2082--- test/rbkt/Queries/zorba/reference/reference_1.xq 1970-01-01 00:00:00 +0000
2083+++ test/rbkt/Queries/zorba/reference/reference_1.xq 2011-10-10 10:35:29 +0000
2084@@ -0,0 +1,13 @@
2085+import module namespace id = "http://www.zorba-xquery.com/modules/node-reference";
2086+
2087+variable $node:=<root><child>text</child></root>;
2088+
2089+variable $before-currentid:=id:node-reference($node);
2090+variable $got:=id:node-reference($node);
2091+variable $after:=id:node-reference($node);
2092+
2093+<result>
2094+<before>{fn:string-length($before-currentid)}</before>
2095+<after>{fn:string-length($got)}</after>
2096+<stable>{$got eq $after}</stable>
2097+</result>
2098\ No newline at end of file
2099
2100=== added file 'test/rbkt/Queries/zorba/reference/reference_2.xq'
2101--- test/rbkt/Queries/zorba/reference/reference_2.xq 1970-01-01 00:00:00 +0000
2102+++ test/rbkt/Queries/zorba/reference/reference_2.xq 2011-10-10 10:35:29 +0000
2103@@ -0,0 +1,14 @@
2104+import module namespace id = "http://www.zorba-xquery.com/modules/node-reference";
2105+
2106+variable $el:=element {"elem"}{"elem"};
2107+variable $attr:=attribute{"attr"}{"attr"};
2108+variable $pi:=processing-instruction {"pi"}{"pi"};
2109+variable $comm:=comment {"comment"};
2110+variable $doc:=document {"document"};
2111+
2112+
2113+id:node-by-reference(id:node-reference($el)),
2114+element {"attr"}{id:node-by-reference(id:node-reference($attr))},
2115+id:node-by-reference(id:node-reference($pi)),
2116+id:node-by-reference(id:node-reference($comm)),
2117+id:node-by-reference(id:node-reference($doc))
2118\ No newline at end of file
2119
2120=== added file 'test/rbkt/Queries/zorba/reference/reference_3.xq'
2121--- test/rbkt/Queries/zorba/reference/reference_3.xq 1970-01-01 00:00:00 +0000
2122+++ test/rbkt/Queries/zorba/reference/reference_3.xq 2011-10-10 10:35:29 +0000
2123@@ -0,0 +1,33 @@
2124+import module namespace idd = "http://www.zorba-xquery.com/reference" at "reference.xqlib";
2125+import module namespace id = "http://www.zorba-xquery.com/modules/node-reference";
2126+import module namespace doc = "http://www.zorba-xquery.com/modules/store/dynamic/documents";
2127+import module namespace map = "http://www.zorba-xquery.com/modules/store/data-structures/unordered-map";
2128+
2129+variable $node:=<root>global</root>;
2130+variable $x := <a>1</a>;
2131+fn:put(<root>doc</root>,"doc");
2132+
2133+map:create(xs:QName("local:bar"), xs:QName("xs:integer"));
2134+map:insert(xs:QName("local:bar"), id:node-reference($x), 1);
2135+
2136+
2137+
2138+<result>
2139+<out-of-module-global>{id:node-by-reference(id:node-reference($idd:node))}</out-of-module-global>
2140+<put-doc>{id:node-by-reference(id:node-reference(doc:document("doc")))}</put-doc>
2141+<in-scope>{id:node-by-reference(id:node-reference($node))}</in-scope>
2142+
2143+<temporary-variable-out-of-scope>{id:node-by-reference(id:node-reference(<root>temp</root>))}</temporary-variable-out-of-scope>
2144+<temporary-variable-in-scope>{
2145+for $i in (1 to 3)
2146+let $temp:=<root>{$i}</root>
2147+where string($temp) = string($i)
2148+let $ref:=id:node-reference($temp)
2149+return
2150+id:node-by-reference($ref)
2151+}</temporary-variable-in-scope>
2152+<temporary-variable-in-scope>{variable $temp:=<root>temp</root>; id:node-by-reference(id:node-reference($temp))}</temporary-variable-in-scope>
2153+<in-map>
2154+{id:node-by-reference(map:get(xs:QName("local:bar"), 1))}
2155+</in-map>
2156+</result>
2157\ No newline at end of file
2158
2159=== added file 'test/rbkt/Queries/zorba/reference/reference_4.spec'
2160--- test/rbkt/Queries/zorba/reference/reference_4.spec 1970-01-01 00:00:00 +0000
2161+++ test/rbkt/Queries/zorba/reference/reference_4.spec 2011-10-10 10:35:29 +0000
2162@@ -0,0 +1,1 @@
2163+Error: http://www.zorba-xquery.com/errors:ZAPI0028
2164
2165=== added file 'test/rbkt/Queries/zorba/reference/reference_4.xq'
2166--- test/rbkt/Queries/zorba/reference/reference_4.xq 1970-01-01 00:00:00 +0000
2167+++ test/rbkt/Queries/zorba/reference/reference_4.xq 2011-10-10 10:35:29 +0000
2168@@ -0,0 +1,3 @@
2169+import module namespace id = "http://www.zorba-xquery.com/modules/node-reference";
2170+
2171+id:node-by-reference(xs:anyURI("this:is-not-a-reference"))
2172\ No newline at end of file
2173
2174=== added file 'test/rbkt/Queries/zorba/reference/reference_5.xq'
2175--- test/rbkt/Queries/zorba/reference/reference_5.xq 1970-01-01 00:00:00 +0000
2176+++ test/rbkt/Queries/zorba/reference/reference_5.xq 2011-10-10 10:35:29 +0000
2177@@ -0,0 +1,29 @@
2178+import module namespace idd = "http://www.zorba-xquery.com/reference" at "reference.xqlib";
2179+import module namespace id = "http://www.zorba-xquery.com/modules/node-reference";
2180+import module namespace doc = "http://www.zorba-xquery.com/modules/store/dynamic/documents";
2181+
2182+variable $node:=<root>global</root>;
2183+
2184+fn:put(<root>doc</root>,"doc");
2185+
2186+
2187+<result>
2188+<temporary-variable-in-scope>{let $temp:=<root>temp</root> return id:node-by-reference(id:node-reference($temp))}</temporary-variable-in-scope>
2189+<temporary-variable-in-scope>{
2190+let $temp:=<root>temp</root>
2191+return
2192+let $ref:=id:node-reference($temp)
2193+return
2194+id:node-by-reference($ref)
2195+}</temporary-variable-in-scope>
2196+<temporary-variable-in-scope>{
2197+for $i in (1 to 3)
2198+let $temp:=<root>temp</root>
2199+let $ref:=id:node-reference($temp)
2200+return
2201+id:node-by-reference($ref)
2202+}</temporary-variable-in-scope>
2203+
2204+<temporary-variable-in-scope>{let $temp:=<root>temp</root> return id:node-by-reference(id:node-reference($temp))}</temporary-variable-in-scope>
2205+
2206+</result>
2207
2208=== removed file 'test/rbkt/Queries/zorba/reference/reference_doc_example_01.spec'
2209--- test/rbkt/Queries/zorba/reference/reference_doc_example_01.spec 2011-08-04 02:39:56 +0000
2210+++ test/rbkt/Queries/zorba/reference/reference_doc_example_01.spec 1970-01-01 00:00:00 +0000
2211@@ -1,4 +0,0 @@
2212-Args:
2213--x
2214-input-context:=xs:string($RBKT_SRC_DIR/Queries/zorba/reference/books.xml)
2215-Error: http://www.zorba-xquery.com/errors:ZAPI0080
2216
2217=== removed file 'test/rbkt/Queries/zorba/reference/reference_doc_example_01.xq'
2218--- test/rbkt/Queries/zorba/reference/reference_doc_example_01.xq 2011-06-24 19:58:33 +0000
2219+++ test/rbkt/Queries/zorba/reference/reference_doc_example_01.xq 1970-01-01 00:00:00 +0000
2220@@ -1,7 +0,0 @@
2221-import module namespace ref =
2222- "http://www.zorba-xquery.com/modules/node-reference";
2223-
2224-declare variable $input-context external;
2225-
2226-let $book := doc($input-context)/bib/book[1]
2227-return ref:node-reference($book)
2228
2229=== removed file 'test/rbkt/Queries/zorba/reference/reference_doc_example_02.spec'
2230--- test/rbkt/Queries/zorba/reference/reference_doc_example_02.spec 2011-08-04 02:39:56 +0000
2231+++ test/rbkt/Queries/zorba/reference/reference_doc_example_02.spec 1970-01-01 00:00:00 +0000
2232@@ -1,4 +0,0 @@
2233-Args:
2234--x
2235-input-context:=xs:string($RBKT_SRC_DIR/Queries/zorba/reference/books.xml)
2236-Error: http://www.zorba-xquery.com/errors:ZAPI0080
2237
2238=== removed file 'test/rbkt/Queries/zorba/reference/reference_doc_example_02.xq'
2239--- test/rbkt/Queries/zorba/reference/reference_doc_example_02.xq 2011-06-24 19:58:33 +0000
2240+++ test/rbkt/Queries/zorba/reference/reference_doc_example_02.xq 1970-01-01 00:00:00 +0000
2241@@ -1,8 +0,0 @@
2242-import module namespace ref =
2243- "http://www.zorba-xquery.com/modules/node-reference";
2244-
2245-declare variable $input-context external;
2246-
2247-let $book := doc($input-context)/bib/book[1]
2248-let $bookref := ref:node-reference($book)
2249-return ref:node-by-reference($bookref)

Subscribers

People subscribed via source and target branches