Merge lp:~zorba-coders/zorba/bug-1005995 into lp:zorba

Proposed by Till Westmann
Status: Superseded
Proposed branch: lp:~zorba-coders/zorba/bug-1005995
Merge into: lp:zorba
Diff against target: 152 lines (+42/-49)
2 files modified
ChangeLog (+1/-0)
src/runtime/nodes/nodes_impl.cpp (+41/-49)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-1005995
Reviewer Review Type Date Requested Status
Matthias Brantner Needs Fixing
Till Westmann Approve
Juan Zacarias Pending
Review via email: mp+112461@code.launchpad.net

This proposal has been superseded by a proposal from 2012-06-28.

Commit message

modify fn:path to add support for fragments

Description of the change

modify fn:path to add support for fragments

To post a comment you must log in.
Revision history for this message
Till Westmann (tillw) :
review: Approve
Revision history for this message
Till Westmann (tillw) wrote :

Since I needed this, I've added the fragment support to fn:path.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1005995-2012-06-28T00-06-57.561Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

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

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

looks good but addition to ChangeLog is missing

review: Needs Fixing
lp:~zorba-coders/zorba/bug-1005995 updated
10899. By Till Westmann

update change log

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-06-27 14:07:46 +0000
3+++ ChangeLog 2012-06-28 04:24:22 +0000
4@@ -8,6 +8,7 @@
5 * New XQuery 3.0 functions
6 - fn:parse-xml-fragment#1
7 * Added support for transient maps to the http://www.zorba-xquery.com/modules/store/data-structures/unordered-map module.
8+ * Added support for fragments to fn:path
9
10 Optimizations:
11 * Small optimization of comparison operations.
12
13=== modified file 'src/runtime/nodes/nodes_impl.cpp'
14--- src/runtime/nodes/nodes_impl.cpp 2012-06-18 10:06:47 +0000
15+++ src/runtime/nodes/nodes_impl.cpp 2012-06-28 04:24:22 +0000
16@@ -653,95 +653,87 @@
17 bool FnPathIterator::nextImpl(store::Item_t& result, PlanState& planState) const
18 {
19 store::Item_t inNode;
20+ store::Item_t swap;
21 store::Item_t nodeName;
22- store::NsBindings nsBindings;
23 zstring path;
24 zstring temp;
25 zstring zNamespace;
26 zstring zLocalName;
27 zstring zPosition;
28- bool rootIsDocument = false;
29
30 PlanIteratorState* state;
31 DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
32
33 if (consumeNext(inNode, theChildren[0], planState))
34 {
35- do
36- {
37+ while (inNode->getParent())
38+ {
39+ temp = path;
40+ path = "/";
41+
42 switch (inNode->getNodeKind())
43 {
44- case store::StoreConsts::documentNode:
45- temp = path;
46- path = "/";
47- path += temp;
48- rootIsDocument = true;
49- break;
50 case store::StoreConsts::elementNode:
51 nodeName = inNode->getNodeName();
52 zNamespace = nodeName->getNamespace();
53 zLocalName = nodeName->getLocalName();
54 zPosition = ztd::to_string(getNodePosition(inNode));
55- temp = path;
56- path = "\""+zNamespace+"\":"+zLocalName+"["+zPosition.c_str()+"]";
57- path += temp;
58+ path += "\""+zNamespace+"\":"+zLocalName+"["+zPosition+"]";
59 break;
60 case store::StoreConsts::attributeNode:
61 nodeName = inNode->getNodeName();
62 zNamespace =nodeName->getNamespace();
63 zLocalName = nodeName->getLocalName();
64+ path += "@";
65 if(zNamespace != "")
66 {
67- temp = path;
68- path = "@\""+zNamespace+"\":"+zLocalName;
69- path += temp;
70- }
71- else
72- {
73- temp = path;
74- path = "@"+zLocalName;
75- path += temp;
76- }
77+ path += "\""+zNamespace+"\":";
78+ }
79+ path += zLocalName;
80 break;
81 case store::StoreConsts::textNode:
82 zPosition = ztd::to_string(getNodePosition(inNode));
83- temp = path;
84- path = "text()["+zPosition+"]";
85- path += temp;
86+ path += "text()["+zPosition+"]";
87 break;
88 case store::StoreConsts::commentNode:
89 zPosition = ztd::to_string(getNodePosition(inNode));
90- temp = path;
91- path = "comment()["+zPosition+"]";
92- path += temp;
93+ path += "comment()["+zPosition+"]";
94+ break;
95+ case store::StoreConsts::piNode:
96+ nodeName = inNode->getNodeName();
97+ zLocalName = nodeName->getLocalName();
98+ zPosition = ztd::to_string(getNodePosition(inNode));
99+ path += "processing-instruction("+zLocalName+")["+zPosition+"]";
100 break;
101 default:
102- if(inNode->isProcessingInstruction())
103- {
104- nodeName = inNode->getNodeName();
105- zLocalName = nodeName->getLocalName();
106- zPosition = ztd::to_string(getNodePosition(inNode));
107- temp = path;
108- path = "processing-instruction("+zLocalName+")["+zPosition+"]";
109- path += temp;
110- }
111+ // this is either a documentNode which should always be a root
112+ // node (and not end up here) or it is something very strange
113+ ZORBA_ASSERT(false);
114 break;
115 }
116- inNode = inNode->getParent();
117-
118- if(inNode && inNode->getNodeKind() != store::StoreConsts::documentNode)
119+ path += temp;
120+
121+ swap = inNode->getParent();
122+ inNode = swap;
123+ }
124+
125+ // only the root node is left and there we've got some special
126+ // cases in the spec
127+ if (inNode->getNodeKind() == store::StoreConsts::documentNode)
128+ {
129+ if (path.empty())
130 {
131- temp = path;
132 path = "/";
133- path += temp;
134 }
135-
136- } while (inNode);
137-
138- if(rootIsDocument)
139- STACK_PUSH(GENV_ITEMFACTORY->createString(result, path), state);
140+ }
141 else
142- throw XQUERY_EXCEPTION(err::FODC0001, ERROR_PARAMS("fn:path"), ERROR_LOC(loc));
143+ {
144+ temp = path;
145+ path = "\"http://www.w3.org/2005/xpath-functions\":root()";
146+ path += temp;
147+ }
148+
149+ STACK_PUSH(GENV_ITEMFACTORY->createString(result, path), state);
150 }
151
152 STACK_END (state);

Subscribers

People subscribed via source and target branches