[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-14 Thread noreply
The proposal to merge lp:~zorba-coders/zorba/fix-fn-path into lp:zorba has been 
updated.

Status: Approved => Merged

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-14 Thread Zorba Build Bot
Validation queue job fix-fn-path-2012-07-14T20-08-55.2Z is finished. The final 
status was:

All tests succeeded!
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-14 Thread Zorba Build Bot
Validation queue starting for merge proposal.
Log at: 
http://zorbatest.lambda.nu:8080/remotequeue/fix-fn-path-2012-07-14T20-08-55.2Z/log.html
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-14 Thread Matthias Brantner
The proposal to merge lp:~zorba-coders/zorba/fix-fn-path into lp:zorba has been 
updated.

Status: Needs review => Approved

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
Your team Zorba Coders is subscribed to branch lp:zorba.

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


Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-14 Thread Markos Zaharioudakis
Review: Approve


-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
Your team Zorba Coders is subscribed to branch lp:zorba.

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


Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-13 Thread Matthias Brantner
Review: Approve


-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-13 Thread Zorba Build Bot
The proposal to merge lp:~zorba-coders/zorba/fix-fn-path into lp:zorba has been 
updated.

Status: Approved => Needs review

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
Your team Zorba Coders is subscribed to branch lp:zorba.

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


Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-13 Thread Zorba Build Bot
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, 
Needs Fixing < 1, Pending < 1. Got: 3 Pending.
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-13 Thread Zorba Build Bot
Validation queue job fix-fn-path-2012-07-13T19-06-57.88Z is finished. The final 
status was:

All tests succeeded!
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-13 Thread Zorba Build Bot
Validation queue starting for merge proposal.
Log at: 
http://zorbatest.lambda.nu:8080/remotequeue/fix-fn-path-2012-07-13T19-06-57.88Z/log.html
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-13 Thread Till Westmann
The proposal to merge lp:~zorba-coders/zorba/fix-fn-path into lp:zorba has been 
updated.

Commit Message changed to:

fix position for elements and processing-instructions in fn:path

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-13 Thread Till Westmann
The proposal to merge lp:~zorba-coders/zorba/fix-fn-path into lp:zorba has been 
updated.

Status: Needs review => Approved

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
Your team Zorba Coders is subscribed to branch lp:zorba.

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


Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-13 Thread Till Westmann
Resubmitted proposal and added Matthias as reviewer.
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-13 Thread Till Westmann
Till Westmann has proposed merging lp:~zorba-coders/zorba/fix-fn-path into 
lp:zorba.

Requested reviews:
  Matthias Brantner (matthias-brantner)
  Markos Zaharioudakis (markos-za)
Related bugs:
  Bug #1024123 in Zorba: "Un-revert r10899"
  https://bugs.launchpad.net/zorba/+bug/1024123
  Bug #1024279 in Zorba: "fn:path seg faults"
  https://bugs.launchpad.net/zorba/+bug/1024279

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922

fix position for elements and processing-instructions in fn:path
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114922
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/runtime/nodes/nodes_impl.cpp'
--- src/runtime/nodes/nodes_impl.cpp	2012-07-12 17:29:55 +
+++ src/runtime/nodes/nodes_impl.cpp	2012-07-13 18:59:22 +
@@ -680,7 +680,7 @@
 
 /***
 /
-int getNodePosition(store::Item_t aNode)
+int getNodePosition(store::Item_t aNode, store::Item_t aNodeName)
 {
   int count = 1;
   store::Iterator_t lIterator = aNode->getParent()->getChildren();
@@ -692,7 +692,7 @@
 {
   if(lItem->equals(aNode))
 break;
-  else
+  else if (aNodeName.isNull() || aNodeName->equals(lItem->getNodeName()))
 count++;
 }
   }
@@ -703,101 +703,87 @@
 bool FnPathIterator::nextImpl(store::Item_t& result, PlanState& planState) const
 {
   store::Item_t inNode;
+  store::Item_t swap;
   store::Item_t nodeName;
-  store::NsBindings nsBindings;
   zstring path;
   zstring temp;
   zstring zNamespace;
   zstring zLocalName;
   zstring zPosition;
-  bool rootIsDocument = false;
 
   PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
 
   if (consumeNext(inNode, theChildren[0], planState))
   {
-do
-{ 
+while (inNode->getParent())
+{
+  temp = path;
+  path = "/";
+
   switch (inNode->getNodeKind())
   {
-case store::StoreConsts::documentNode:
-  temp = path;
-  path = "/";
-  path += temp;
-  rootIsDocument = true;
-  break;
-
 case store::StoreConsts::elementNode:
   nodeName = inNode->getNodeName();
   zNamespace = nodeName->getNamespace();
   zLocalName = nodeName->getLocalName();
-  zPosition = ztd::to_string(getNodePosition(inNode));
-  temp = path;
-  path = "Q{"+zNamespace+"}"+zLocalName+"["+zPosition.c_str()+"]";
-  path += temp;
+  zPosition = ztd::to_string(getNodePosition(inNode, nodeName));
+  path += "Q{" + zNamespace + "}" + zLocalName + "[" + zPosition + "]";
   break;
-
 case store::StoreConsts::attributeNode:
   nodeName = inNode->getNodeName();
   zNamespace =nodeName->getNamespace();
   zLocalName = nodeName->getLocalName();
+  path += "@";
   if(zNamespace != "")
   {
-temp = path;
-path = "@Q{"+zNamespace+"}"+zLocalName;
-path += temp;
-  }
-  else
-  {
-temp = path;
-path = "@"+zLocalName;
-path += temp;
-  }
+path += "Q{" + zNamespace + "}";
+  }
+  path += zLocalName;
   break;
-
 case store::StoreConsts::textNode:
-  zPosition = ztd::to_string(getNodePosition(inNode));
-  temp = path;
-  path = "text()["+zPosition+"]";
-  path += temp;
+  zPosition = ztd::to_string(getNodePosition(inNode, NULL));
+  path += "text()[" + zPosition + "]";
   break;
-
 case store::StoreConsts::commentNode:
-  zPosition = ztd::to_string(getNodePosition(inNode));
-  temp = path;
-  path = "comment()["+zPosition+"]";
-  path += temp;
+  zPosition = ztd::to_string(getNodePosition(inNode, NULL));
+  path += "comment()[" + zPosition + "]";
   break;
-
-case store::StoreConsts::piNode: 
+case store::StoreConsts::piNode:
   nodeName = inNode->getNodeName();
   zLocalName = nodeName->getLocalName();
-  zPosition = ztd::to_string(getNodePosition(inNode));
-  temp = path;
-  path = "processing-instruction("+zLocalName+")["+zPosition+"]";
-  path += temp;
+  zPosition = ztd::to_string(getNodePosition(inNode, nodeName));
+  path += "processing-instruction(" + zLocalName + ")[" + zPosition + "]";
   break;
-
 default:
+  // this is either a documentNode which should always be a root
+  // node (and not end up here) or it is something very strange
   ZORBA_ASSERT(false);
+  break;
   }
-
-  inNode = inNode->getParent();
-  
-  if (inNode && inNode->getNodeKind() != store::StoreCo

Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-13 Thread Till Westmann
> Hi Till, I noticed after approving that the diff seems to replace the new
> EQName syntax with the old one. Is this the intent?

No, it isn't. Thanks!
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114739
Your team Zorba Coders is subscribed to branch lp:zorba.

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


Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-13 Thread Ghislain Fourny
Review: Needs Fixing

Hi Till, I noticed after approving that the diff seems to replace the new 
EQName syntax with the old one. Is this the intent?

-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114739
Your team Zorba Coders is subscribed to branch lp:zorba.

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


Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-13 Thread Ghislain Fourny
Review: Approve


-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114739
Your team Zorba Coders is subscribed to branch lp:zorba.

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


Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-12 Thread Markos Zaharioudakis
Review: Approve

Till, did you really have a case where the "swap" local var was needed? I think 
I can see why it is needed, but I think the code in item_handle should be 
changed (call addReference() before remveReference()) to make "swap" 
unecessary. Do you agree?
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114739
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-12 Thread Zorba Build Bot
The proposal to merge lp:~zorba-coders/zorba/fix-fn-path into lp:zorba has been 
updated.

Status: Approved => Needs review

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114739
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114739
Your team Zorba Coders is subscribed to branch lp:zorba.

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


Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-12 Thread Zorba Build Bot
Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, 
Needs Fixing < 1, Pending < 1. Got: 3 Pending.
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114739
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-12 Thread Zorba Build Bot
Validation queue job fix-fn-path-2012-07-12T21-27-07.506Z is finished. The 
final status was:

All tests succeeded!
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114739
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-12 Thread Zorba Build Bot
Validation queue starting for merge proposal.
Log at: 
http://zorbatest.lambda.nu:8080/remotequeue/fix-fn-path-2012-07-12T21-27-07.506Z/log.html
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114739
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-12 Thread Till Westmann
The proposal to merge lp:~zorba-coders/zorba/fix-fn-path into lp:zorba has been 
updated.

Status: Needs review => Approved

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114739
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114739
Your team Zorba Coders is subscribed to branch lp:zorba.

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


[Zorba-coders] [Merge] lp:~zorba-coders/zorba/fix-fn-path into lp:zorba

2012-07-12 Thread Till Westmann
Till Westmann has proposed merging lp:~zorba-coders/zorba/fix-fn-path into 
lp:zorba.

Requested reviews:
  Ghislain Fourny (gislenius)
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114739

fix position for elements and processing-instructions in fn:path
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix-fn-path/+merge/114739
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/runtime/nodes/nodes_impl.cpp'
--- src/runtime/nodes/nodes_impl.cpp	2012-07-12 17:29:55 +
+++ src/runtime/nodes/nodes_impl.cpp	2012-07-12 21:21:38 +
@@ -680,7 +680,7 @@
 
 /***
 /
-int getNodePosition(store::Item_t aNode)
+int getNodePosition(store::Item_t aNode, store::Item_t aNodeName)
 {
   int count = 1;
   store::Iterator_t lIterator = aNode->getParent()->getChildren();
@@ -692,7 +692,7 @@
 {
   if(lItem->equals(aNode))
 break;
-  else
+  else if (aNodeName.isNull() || aNodeName->equals(lItem->getNodeName()))
 count++;
 }
   }
@@ -703,101 +703,87 @@
 bool FnPathIterator::nextImpl(store::Item_t& result, PlanState& planState) const
 {
   store::Item_t inNode;
+  store::Item_t swap;
   store::Item_t nodeName;
-  store::NsBindings nsBindings;
   zstring path;
   zstring temp;
   zstring zNamespace;
   zstring zLocalName;
   zstring zPosition;
-  bool rootIsDocument = false;
 
   PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
 
   if (consumeNext(inNode, theChildren[0], planState))
   {
-do
-{ 
+while (inNode->getParent())
+{
+  temp = path;
+  path = "/";
+
   switch (inNode->getNodeKind())
   {
-case store::StoreConsts::documentNode:
-  temp = path;
-  path = "/";
-  path += temp;
-  rootIsDocument = true;
-  break;
-
 case store::StoreConsts::elementNode:
   nodeName = inNode->getNodeName();
   zNamespace = nodeName->getNamespace();
   zLocalName = nodeName->getLocalName();
-  zPosition = ztd::to_string(getNodePosition(inNode));
-  temp = path;
-  path = "Q{"+zNamespace+"}"+zLocalName+"["+zPosition.c_str()+"]";
-  path += temp;
+  zPosition = ztd::to_string(getNodePosition(inNode, nodeName));
+  path += "\""+zNamespace+"\":"+zLocalName+"["+zPosition+"]";
   break;
-
 case store::StoreConsts::attributeNode:
   nodeName = inNode->getNodeName();
   zNamespace =nodeName->getNamespace();
   zLocalName = nodeName->getLocalName();
+  path += "@";
   if(zNamespace != "")
   {
-temp = path;
-path = "@Q{"+zNamespace+"}"+zLocalName;
-path += temp;
-  }
-  else
-  {
-temp = path;
-path = "@"+zLocalName;
-path += temp;
-  }
+path += "\""+zNamespace+"\":";
+  }
+  path += zLocalName;
   break;
-
 case store::StoreConsts::textNode:
-  zPosition = ztd::to_string(getNodePosition(inNode));
-  temp = path;
-  path = "text()["+zPosition+"]";
-  path += temp;
+  zPosition = ztd::to_string(getNodePosition(inNode, NULL));
+  path += "text()["+zPosition+"]";
   break;
-
 case store::StoreConsts::commentNode:
-  zPosition = ztd::to_string(getNodePosition(inNode));
-  temp = path;
-  path = "comment()["+zPosition+"]";
-  path += temp;
+  zPosition = ztd::to_string(getNodePosition(inNode, NULL));
+  path += "comment()["+zPosition+"]";
   break;
-
-case store::StoreConsts::piNode: 
+case store::StoreConsts::piNode:
   nodeName = inNode->getNodeName();
   zLocalName = nodeName->getLocalName();
-  zPosition = ztd::to_string(getNodePosition(inNode));
-  temp = path;
-  path = "processing-instruction("+zLocalName+")["+zPosition+"]";
-  path += temp;
+  zPosition = ztd::to_string(getNodePosition(inNode, nodeName));
+  path += "processing-instruction("+zLocalName+")["+zPosition+"]";
   break;
-
 default:
+  // this is either a documentNode which should always be a root
+  // node (and not end up here) or it is something very strange
   ZORBA_ASSERT(false);
+  break;
   }
-
-  inNode = inNode->getParent();
-  
-  if (inNode && inNode->getNodeKind() != store::StoreConsts::documentNode)
+  path += temp;
+
+  swap = inNode->getParent();
+  inNode = swap;
+}
+
+// only the root node is left and there we've got some special
+// cases in the spec
+if (inNode->getNodeKind() == s