Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch 
into lp:zorba.

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/112790

Fixed bug #1018673 + renamed misleading isXXXNode() methods.
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/112790
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/runtime/nodes/node_position_impl.cpp'
--- src/runtime/nodes/node_position_impl.cpp	2012-06-28 04:14:03 +0000
+++ src/runtime/nodes/node_position_impl.cpp	2012-06-29 14:45:27 +0000
@@ -464,14 +464,14 @@
 {
   store::Item_t lUri;
 
-  PlanIteratorState *state;
+  PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
 
   consumeNext(lUri, theChildren[0].getp(), planState);
 
   try
   {
-    GENV_ITEMFACTORY->createBoolean(result, lUri->isAttribute());
+    GENV_ITEMFACTORY->createBoolean(result, lUri->isAttributeRef());
   }
   catch (ZorbaException& e)
   {
@@ -493,14 +493,14 @@
 {
   store::Item_t lUri;
 
-  PlanIteratorState *state;
+  PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
 
   consumeNext(lUri, theChildren[0].getp(), planState);
 
   try
   {
-    GENV_ITEMFACTORY->createBoolean(result, lUri->isComment());
+    GENV_ITEMFACTORY->createBoolean(result, lUri->isCommentRef());
   }
   catch (ZorbaException& e)
   {
@@ -522,14 +522,14 @@
 {
   store::Item_t lUri;
 
-  PlanIteratorState *state;
+  PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
 
   consumeNext(lUri, theChildren[0].getp(), planState);
 
   try
   {
-    GENV_ITEMFACTORY->createBoolean(result, lUri->isDocument());
+    GENV_ITEMFACTORY->createBoolean(result, lUri->isDocumentRef());
   }
   catch (ZorbaException& e)
   {
@@ -551,14 +551,14 @@
 {
   store::Item_t lUri;
 
-  PlanIteratorState *state;
+  PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
 
   consumeNext(lUri, theChildren[0].getp(), planState);
 
   try
   {
-    GENV_ITEMFACTORY->createBoolean(result, lUri->isElement());
+    GENV_ITEMFACTORY->createBoolean(result, lUri->isElementRef());
   }
   catch (ZorbaException& e)
   {
@@ -580,14 +580,14 @@
 {
   store::Item_t lUri;
 
-  PlanIteratorState *state;
+  PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
 
   consumeNext(lUri, theChildren[0].getp(), planState);
 
   try
   {
-    GENV_ITEMFACTORY->createBoolean(result, lUri->isProcessingInstruction());
+    GENV_ITEMFACTORY->createBoolean(result, lUri->isProcessingInstructionRef());
   }
   catch (ZorbaException& e)
   {
@@ -609,14 +609,14 @@
 {
   store::Item_t lUri;
 
-  PlanIteratorState *state;
+  PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
 
   consumeNext(lUri, theChildren[0].getp(), planState);
 
   try
   {
-    GENV_ITEMFACTORY->createBoolean(result, lUri->isText());
+    GENV_ITEMFACTORY->createBoolean(result, lUri->isTextRef());
   }
   catch (ZorbaException& e)
   {

=== modified file 'src/runtime/nodes/nodes_impl.cpp'
--- src/runtime/nodes/nodes_impl.cpp	2012-06-28 21:54:08 +0000
+++ src/runtime/nodes/nodes_impl.cpp	2012-06-29 14:45:27 +0000
@@ -703,87 +703,101 @@
 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))
   {
-    while (inNode->getParent())
-    {
-      temp = path;
-      path = "/";
-
+    do
+    { 
       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));
-          path += "\""+zNamespace+"\":"+zLocalName+"["+zPosition+"]";
+          temp = path;
+          path = "\""+zNamespace+"\":"+zLocalName+"["+zPosition.c_str()+"]";
+          path += temp;
           break;
+
         case store::StoreConsts::attributeNode:
           nodeName = inNode->getNodeName();
           zNamespace =nodeName->getNamespace();
           zLocalName = nodeName->getLocalName();
-          path += "@";
           if(zNamespace != "")
           {
-            path += "\""+zNamespace+"\":";
-          }
-          path += zLocalName;
+            temp = path;
+            path = "@\""+zNamespace+"\":"+zLocalName;
+            path += temp;
+          }
+          else
+          {
+            temp = path;
+            path = "@"+zLocalName;
+            path += temp;
+          }
           break;
+
         case store::StoreConsts::textNode:
           zPosition = ztd::to_string(getNodePosition(inNode));
-          path += "text()["+zPosition+"]";
+          temp = path;
+          path = "text()["+zPosition+"]";
+          path += temp;
           break;
+
         case store::StoreConsts::commentNode:
           zPosition = ztd::to_string(getNodePosition(inNode));
-          path += "comment()["+zPosition+"]";
+          temp = path;
+          path = "comment()["+zPosition+"]";
+          path += temp;
           break;
-        case store::StoreConsts::piNode:
+
+        case store::StoreConsts::piNode: 
           nodeName = inNode->getNodeName();
           zLocalName = nodeName->getLocalName();
           zPosition = ztd::to_string(getNodePosition(inNode));
-          path += "processing-instruction("+zLocalName+")["+zPosition+"]";
+          temp = path;
+          path = "processing-instruction("+zLocalName+")["+zPosition+"]";
+          path += temp;
           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;
       }
-      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() == store::StoreConsts::documentNode)
-    {
-      if (path.empty())
+
+      inNode = inNode->getParent();
+      
+      if (inNode && inNode->getNodeKind() != store::StoreConsts::documentNode)
       {
+        temp = path;
         path = "/";
+        path += temp;
       }
-    }
+
+    } while (inNode);
+
+    if(rootIsDocument)
+      STACK_PUSH(GENV_ITEMFACTORY->createString(result, path), state);
     else
-    {
-      temp = path;
-      path = "\"http://www.w3.org/2005/xpath-functions\":root()";
-      path += temp;
-    }
-
-    STACK_PUSH(GENV_ITEMFACTORY->createString(result, path), state);
+      throw XQUERY_EXCEPTION(err::FODC0001, ERROR_PARAMS("fn:path"), ERROR_LOC(loc));
   }
 
   STACK_END (state);

=== modified file 'src/store/api/item.h'
--- src/store/api/item.h	2012-06-28 04:14:03 +0000
+++ src/store/api/item.h	2012-06-29 14:45:27 +0000
@@ -470,6 +470,43 @@
    */
   virtual bool
   isPosOrNegInf() const;
+
+  /**
+   *
+   */
+  virtual bool
+  isAttributeRef() const;
+
+  /**
+   *
+   */
+  virtual bool
+  isCommentRef() const;
+
+  /**
+   *
+   */
+  virtual bool
+  isDocumentRef() const;
+
+  /**
+   *
+   */
+  virtual bool
+  isElementRef() const;
+
+  /**
+   *
+   */
+  virtual bool
+  isProcessingInstructionRef() const;
+
+  /**
+   *
+   */
+  virtual bool
+  isTextRef() const;
+
   
   /* -------------------  Methods for Nodes ------------------------------------- */
 
@@ -758,42 +795,6 @@
    *
    */
   virtual bool
-  isAttribute() const;
-
-  /**
-   *
-   */
-  virtual bool
-  isComment() const;
-
-  /**
-   *
-   */
-  virtual bool
-  isDocument() const;
-
-  /**
-   *
-   */
-  virtual bool
-  isElement() const;
-
-  /**
-   *
-   */
-  virtual bool
-  isProcessingInstruction() const;
-
-  /**
-   *
-   */
-  virtual bool
-  isText() const;
-
-  /**
-   *
-   */
-  virtual bool
   inSameTree(const store::Item_t&) const;
 
   /**

=== modified file 'src/store/naive/atomic_items.cpp'
--- src/store/naive/atomic_items.cpp	2012-06-28 04:14:03 +0000
+++ src/store/naive/atomic_items.cpp	2012-06-29 14:45:27 +0000
@@ -987,57 +987,57 @@
 }
 
 
-bool AnyUriItem::isAttribute() const
-{
-  store::Item_t lThisUri;
-  zstring tempValue=theValue;
-  GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
-  return lThisUri->isAttribute();
-}
-
-
-bool AnyUriItem::isComment() const
-{
-  store::Item_t lThisUri;
-  zstring tempValue=theValue;
-  GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
-  return lThisUri->isComment();
-}
-
-
-bool AnyUriItem::isDocument() const
-{
-  store::Item_t lThisUri;
-  zstring tempValue=theValue;
-  GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
-  return lThisUri->isDocument();
-}
-
-
-bool AnyUriItem::isElement() const
-{
-  store::Item_t lThisUri;
-  zstring tempValue=theValue;
-  GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
-  return lThisUri->isElement();
-}
-
-
-bool AnyUriItem::isProcessingInstruction() const
-{
-  store::Item_t lThisUri;
-  zstring tempValue=theValue;
-  GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
-  return lThisUri->isProcessingInstruction();
-}
-
-
-bool AnyUriItem::isText() const
-{
-  store::Item_t lThisUri;
-  zstring tempValue=theValue;
-  GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
-  return lThisUri->isText();
+bool AnyUriItem::isAttributeRef() const
+{
+  store::Item_t lThisUri;
+  zstring tempValue = theValue;
+  GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+  return lThisUri->isAttributeRef();
+}
+
+
+bool AnyUriItem::isCommentRef() const
+{
+  store::Item_t lThisUri;
+  zstring tempValue = theValue;
+  GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+  return lThisUri->isCommentRef();
+}
+
+
+bool AnyUriItem::isDocumentRef() const
+{
+  store::Item_t lThisUri;
+  zstring tempValue = theValue;
+  GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+  return lThisUri->isDocumentRef();
+}
+
+
+bool AnyUriItem::isElementRef() const
+{
+  store::Item_t lThisUri;
+  zstring tempValue = theValue;
+  GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+  return lThisUri->isElementRef();
+}
+
+
+bool AnyUriItem::isProcessingInstructionRef() const
+{
+  store::Item_t lThisUri;
+  zstring tempValue = theValue;
+  GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+  return lThisUri->isProcessingInstructionRef();
+}
+
+
+bool AnyUriItem::isTextRef() const
+{
+  store::Item_t lThisUri;
+  zstring tempValue = theValue;
+  GET_FACTORY().createStructuralAnyURI(lThisUri, tempValue);
+  return lThisUri->isTextRef();
 }
 
 
@@ -1477,37 +1477,37 @@
 }
 
 
-bool StructuralAnyUriItem::isAttribute() const
+bool StructuralAnyUriItem::isAttributeRef() const
 {
   return theNodeKind == store::StoreConsts::attributeNode;
 }
 
 
-bool StructuralAnyUriItem::isComment() const
+bool StructuralAnyUriItem::isCommentRef() const
 {
   return theNodeKind == store::StoreConsts::commentNode;
 }
 
 
-bool StructuralAnyUriItem::isDocument() const
+bool StructuralAnyUriItem::isDocumentRef() const
 {
   return theNodeKind == store::StoreConsts::documentNode;
 }
 
 
-bool StructuralAnyUriItem::isElement() const
+bool StructuralAnyUriItem::isElementRef() const
 {
   return theNodeKind == store::StoreConsts::elementNode;
 }
 
 
-bool StructuralAnyUriItem::isProcessingInstruction() const
+bool StructuralAnyUriItem::isProcessingInstructionRef() const
 {
   return theNodeKind == store::StoreConsts::piNode;
 }
 
 
-bool StructuralAnyUriItem::isText() const
+bool StructuralAnyUriItem::isTextRef() const
 {
   return theNodeKind == store::StoreConsts::textNode;
 }

=== modified file 'src/store/naive/atomic_items.h'
--- src/store/naive/atomic_items.h	2012-06-28 04:14:03 +0000
+++ src/store/naive/atomic_items.h	2012-06-29 14:45:27 +0000
@@ -668,22 +668,22 @@
   getLevel() const;
 
   virtual bool
-  isAttribute() const;
-
-  virtual bool
-  isComment() const;
-
-  virtual bool
-  isDocument() const;
-
-  virtual bool
-  isElement() const;
-
-  virtual bool
-  isProcessingInstruction() const;
-
-  virtual bool
-  isText() const;
+  isAttributeRef() const;
+
+  virtual bool
+  isCommentRef() const;
+
+  virtual bool
+  isDocumentRef() const;
+
+  virtual bool
+  isElementRef() const;
+
+  virtual bool
+  isProcessingInstructionRef() const;
+
+  virtual bool
+  isTextRef() const;
 
   virtual bool
   isSibling(const store::Item_t&) const;
@@ -770,22 +770,22 @@
   getLevel() const;
 
   bool
-  isAttribute() const;
-
-  bool
-  isComment() const;
-
-  bool
-  isDocument() const;
-
-  bool
-  isElement() const;
-
-  bool
-  isProcessingInstruction() const;
-
-  bool
-  isText() const;
+  isAttributeRef() const;
+
+  bool
+  isCommentRef() const;
+
+  bool
+  isDocumentRef() const;
+
+  bool
+  isElementRef() const;
+
+  bool
+  isProcessingInstructionRef() const;
+
+  bool
+  isTextRef() const;
 
   bool
   isSibling(const store::Item_t&) const;

=== modified file 'src/store/naive/item.cpp'
--- src/store/naive/item.cpp	2012-06-28 04:14:03 +0000
+++ src/store/naive/item.cpp	2012-06-29 14:45:27 +0000
@@ -1272,53 +1272,53 @@
 }
 
 bool
-Item::isAttribute() const
-{
-  throw ZORBA_EXCEPTION(
-    zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
-    ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
-  );
-}
-
-bool
-Item::isComment() const
-{
-  throw ZORBA_EXCEPTION(
-    zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
-    ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
-  );
-}
-
-bool
-Item::isDocument() const
-{
-  throw ZORBA_EXCEPTION(
-    zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
-    ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
-  );
-}
-
-
-bool
-Item::isElement() const
-{
-  throw ZORBA_EXCEPTION(
-    zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
-    ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
-  );
-}
-
-bool
-Item::isProcessingInstruction() const
-{
-  throw ZORBA_EXCEPTION(
-    zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
-    ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
-  );
-}
-
-bool
-Item::isText() const
+Item::isAttributeRef() const
+{
+  throw ZORBA_EXCEPTION(
+    zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+    ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+  );
+}
+
+bool
+Item::isCommentRef() const
+{
+  throw ZORBA_EXCEPTION(
+    zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+    ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+  );
+}
+
+bool
+Item::isDocumentRef() const
+{
+  throw ZORBA_EXCEPTION(
+    zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+    ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+  );
+}
+
+
+bool
+Item::isElementRef() const
+{
+  throw ZORBA_EXCEPTION(
+    zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+    ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+  );
+}
+
+bool
+Item::isProcessingInstructionRef() const
+{
+  throw ZORBA_EXCEPTION(
+    zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
+    ERROR_PARAMS( __FUNCTION__, getType()->getStringValue() )
+  );
+}
+
+bool
+Item::isTextRef() const
 {
   throw ZORBA_EXCEPTION(
     zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,

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

Reply via email to