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
=== modified file 'ChangeLog'
--- ChangeLog 2012-06-27 14:07:46 +0000
+++ ChangeLog 2012-06-28 04:24:22 +0000
@@ -8,6 +8,7 @@
8 * New XQuery 3.0 functions8 * New XQuery 3.0 functions
9 - fn:parse-xml-fragment#19 - fn:parse-xml-fragment#1
10 * Added support for transient maps to the http://www.zorba-xquery.com/modules/store/data-structures/unordered-map module.10 * Added support for transient maps to the http://www.zorba-xquery.com/modules/store/data-structures/unordered-map module.
11 * Added support for fragments to fn:path
1112
12Optimizations:13Optimizations:
13 * Small optimization of comparison operations.14 * Small optimization of comparison operations.
1415
=== modified file 'src/runtime/nodes/nodes_impl.cpp'
--- src/runtime/nodes/nodes_impl.cpp 2012-06-18 10:06:47 +0000
+++ src/runtime/nodes/nodes_impl.cpp 2012-06-28 04:24:22 +0000
@@ -653,95 +653,87 @@
653bool FnPathIterator::nextImpl(store::Item_t& result, PlanState& planState) const653bool FnPathIterator::nextImpl(store::Item_t& result, PlanState& planState) const
654{654{
655 store::Item_t inNode;655 store::Item_t inNode;
656 store::Item_t swap;
656 store::Item_t nodeName;657 store::Item_t nodeName;
657 store::NsBindings nsBindings;
658 zstring path;658 zstring path;
659 zstring temp;659 zstring temp;
660 zstring zNamespace;660 zstring zNamespace;
661 zstring zLocalName;661 zstring zLocalName;
662 zstring zPosition;662 zstring zPosition;
663 bool rootIsDocument = false;
664663
665 PlanIteratorState* state;664 PlanIteratorState* state;
666 DEFAULT_STACK_INIT(PlanIteratorState, state, planState);665 DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
667666
668 if (consumeNext(inNode, theChildren[0], planState))667 if (consumeNext(inNode, theChildren[0], planState))
669 {668 {
670 do669 while (inNode->getParent())
671 { 670 {
671 temp = path;
672 path = "/";
673
672 switch (inNode->getNodeKind())674 switch (inNode->getNodeKind())
673 {675 {
674 case store::StoreConsts::documentNode:
675 temp = path;
676 path = "/";
677 path += temp;
678 rootIsDocument = true;
679 break;
680 case store::StoreConsts::elementNode:676 case store::StoreConsts::elementNode:
681 nodeName = inNode->getNodeName();677 nodeName = inNode->getNodeName();
682 zNamespace = nodeName->getNamespace();678 zNamespace = nodeName->getNamespace();
683 zLocalName = nodeName->getLocalName();679 zLocalName = nodeName->getLocalName();
684 zPosition = ztd::to_string(getNodePosition(inNode));680 zPosition = ztd::to_string(getNodePosition(inNode));
685 temp = path;681 path += "\""+zNamespace+"\":"+zLocalName+"["+zPosition+"]";
686 path = "\""+zNamespace+"\":"+zLocalName+"["+zPosition.c_str()+"]";
687 path += temp;
688 break;682 break;
689 case store::StoreConsts::attributeNode:683 case store::StoreConsts::attributeNode:
690 nodeName = inNode->getNodeName();684 nodeName = inNode->getNodeName();
691 zNamespace =nodeName->getNamespace();685 zNamespace =nodeName->getNamespace();
692 zLocalName = nodeName->getLocalName();686 zLocalName = nodeName->getLocalName();
687 path += "@";
693 if(zNamespace != "")688 if(zNamespace != "")
694 {689 {
695 temp = path;690 path += "\""+zNamespace+"\":";
696 path = "@\""+zNamespace+"\":"+zLocalName;691 }
697 path += temp;692 path += zLocalName;
698 }
699 else
700 {
701 temp = path;
702 path = "@"+zLocalName;
703 path += temp;
704 }
705 break;693 break;
706 case store::StoreConsts::textNode:694 case store::StoreConsts::textNode:
707 zPosition = ztd::to_string(getNodePosition(inNode));695 zPosition = ztd::to_string(getNodePosition(inNode));
708 temp = path;696 path += "text()["+zPosition+"]";
709 path = "text()["+zPosition+"]";
710 path += temp;
711 break;697 break;
712 case store::StoreConsts::commentNode:698 case store::StoreConsts::commentNode:
713 zPosition = ztd::to_string(getNodePosition(inNode));699 zPosition = ztd::to_string(getNodePosition(inNode));
714 temp = path;700 path += "comment()["+zPosition+"]";
715 path = "comment()["+zPosition+"]";701 break;
716 path += temp;702 case store::StoreConsts::piNode:
703 nodeName = inNode->getNodeName();
704 zLocalName = nodeName->getLocalName();
705 zPosition = ztd::to_string(getNodePosition(inNode));
706 path += "processing-instruction("+zLocalName+")["+zPosition+"]";
717 break;707 break;
718 default:708 default:
719 if(inNode->isProcessingInstruction())709 // this is either a documentNode which should always be a root
720 {710 // node (and not end up here) or it is something very strange
721 nodeName = inNode->getNodeName();711 ZORBA_ASSERT(false);
722 zLocalName = nodeName->getLocalName();
723 zPosition = ztd::to_string(getNodePosition(inNode));
724 temp = path;
725 path = "processing-instruction("+zLocalName+")["+zPosition+"]";
726 path += temp;
727 }
728 break;712 break;
729 }713 }
730 inNode = inNode->getParent();714 path += temp;
731 715
732 if(inNode && inNode->getNodeKind() != store::StoreConsts::documentNode)716 swap = inNode->getParent();
717 inNode = swap;
718 }
719
720 // only the root node is left and there we've got some special
721 // cases in the spec
722 if (inNode->getNodeKind() == store::StoreConsts::documentNode)
723 {
724 if (path.empty())
733 {725 {
734 temp = path;
735 path = "/";726 path = "/";
736 path += temp;
737 }727 }
738728 }
739 } while (inNode);
740
741 if(rootIsDocument)
742 STACK_PUSH(GENV_ITEMFACTORY->createString(result, path), state);
743 else729 else
744 throw XQUERY_EXCEPTION(err::FODC0001, ERROR_PARAMS("fn:path"), ERROR_LOC(loc));730 {
731 temp = path;
732 path = "\"http://www.w3.org/2005/xpath-functions\":root()";
733 path += temp;
734 }
735
736 STACK_PUSH(GENV_ITEMFACTORY->createString(result, path), state);
745 }737 }
746738
747 STACK_END (state);739 STACK_END (state);

Subscribers

People subscribed via source and target branches