Sorin Marian Nasoi has proposed merging lp:~zorba-coders/zorba/my_stack into 
lp:zorba/stack-module.

Requested reviews:
  Zorba Coders (zorba-coders)
  Sorin Marian Nasoi (sorin.marian.nasoi)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/my_stack/+merge/95132

- the names of the stacks are now xs:QNames instead of xs:string
- the module was moved inside 'src' folder
- corrected some typos inside the module
-- 
https://code.launchpad.net/~zorba-coders/zorba/my_stack/+merge/95132
Your team Zorba Coders is requested to review the proposed merge of 
lp:~zorba-coders/zorba/my_stack into lp:zorba/stack-module.
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2012-01-19 17:32:41 +0000
+++ CMakeLists.txt	2012-02-29 09:07:21 +0000
@@ -22,6 +22,6 @@
 INCLUDE ("${Zorba_USE_FILE}")
 
 
-ADD_SUBDIRECTORY("src/com/zorba-xquery/www/modules/store/data-structures")
+ADD_SUBDIRECTORY("src")
 
 DONE_DECLARING_ZORBA_URIS()

=== added file 'src/CMakeLists.txt'
--- src/CMakeLists.txt	1970-01-01 00:00:00 +0000
+++ src/CMakeLists.txt	2012-02-29 09:07:21 +0000
@@ -0,0 +1,20 @@
+# Copyright 2006-2008 The FLWOR Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+##### Stack data structure
+
+DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/store/data-structures/stack"; VERSION 1.0 FILE "stack.xq")
+
+ADD_TEST_DIRECTORY("${PROJECT_SOURCE_DIR}/test")

=== removed directory 'src/com'
=== removed directory 'src/com/zorba-xquery'
=== removed directory 'src/com/zorba-xquery/www'
=== removed directory 'src/com/zorba-xquery/www/modules'
=== removed directory 'src/com/zorba-xquery/www/modules/store'
=== removed directory 'src/com/zorba-xquery/www/modules/store/data-structures'
=== removed file 'src/com/zorba-xquery/www/modules/store/data-structures/CMakeLists.txt'
--- src/com/zorba-xquery/www/modules/store/data-structures/CMakeLists.txt	2012-01-19 17:32:41 +0000
+++ src/com/zorba-xquery/www/modules/store/data-structures/CMakeLists.txt	1970-01-01 00:00:00 +0000
@@ -1,20 +0,0 @@
-# Copyright 2006-2008 The FLWOR Foundation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-##### Stack data structure
-
-DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/store/data-structures/stack"; VERSION 1.0 FILE "stack.xq")
-
-ADD_TEST_DIRECTORY("${PROJECT_SOURCE_DIR}/test")

=== removed file 'src/com/zorba-xquery/www/modules/store/data-structures/stack.xq'
--- src/com/zorba-xquery/www/modules/store/data-structures/stack.xq	2012-02-07 10:24:11 +0000
+++ src/com/zorba-xquery/www/modules/store/data-structures/stack.xq	1970-01-01 00:00:00 +0000
@@ -1,179 +0,0 @@
-xquery version "3.0";
-
-(:
- : Copyright 2006-2012 The FLWOR Foundation.
- :
- : Licensed under the Apache License, Version 2.0 (the "License");
- : you may not use this file except in compliance with the License.
- : You may obtain a copy of the License at
- :
- : http://www.apache.org/licenses/LICENSE-2.0
- :
- : Unless required by applicable law or agreed to in writing, software
- : distributed under the License is distributed on an "AS IS" BASIS,
- : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- : See the License for the specific language governing permissions and
- : limitations under the License.
-:)
-
-(:~
- : Implementation of stack for node items, using collections data structures.<br />
- : Stacks are created at first node insert.
- :
- : @author Daniel Turcanu
- : @project store/data structures
- :)
-module namespace stack = "http://www.zorba-xquery.com/modules/store/data-structures/stack";;
-
-import module namespace collections-ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
-import module namespace collections-dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
-
-declare namespace ann = "http://www.zorba-xquery.com/annotations";;
-declare namespace ver = "http://www.zorba-xquery.com/options/versioning";;
-declare option ver:module-version "1.0";
-
-(:~
- : URI for all collections QNames. Stack names are combined with this URI to construct QNames used by collection api.
- : The URI is "http://www.zorba-xquery.com/modules/store/data-structures/stack";.
- :)
-declare variable $stack:global-uri := "http://www.zorba-xquery.com/modules/store/data-structures/stack";;
-
-(:~
- : Create a stack with this name. <br /> If stack exists, it is deleted first.
- : @param $name string name of the new stack
-:)
-declare %ann:sequential function stack:create($name as xs:string)
-{
-  variable $stname := fn:QName($stack:global-uri, $name);
-  stack:delete($name);
-  collections-ddl:create($stname);
-};
-
-(:~
- : Return a list of string names for available stacks.
- : @return the list of created stack names
- : @example test/Queries/available1.xq
-:)
-declare function stack:available-stacks() as xs:string*
-{
-  for $coll-qname in collections-ddl:available-collections()
-  where fn:namespace-uri-from-QName($coll-qname) eq $stack:global-uri
-  return fn:local-name-from-QName($coll-qname)
-};
-
-(:~
- : Return the top node in the stack, without removing it.
- : @param $name string name of the stack
- : @return the top node, or empty sequence if stack is empty
- : @example test/Queries/top1.xq
-:)
-declare function stack:top($name as xs:string) as node()?
-{
-  let $stname := fn:QName($stack:global-uri, $name)
-  let $stack-content := collections-dml:collection($stname)
-  return
-      if(fn:not(fn:empty($stack-content))) then
-        $stack-content[1]
-      else 
-        ()
-};
-                                 
-(:~
- : Return the top node in the stack, and remove it.
- : @param $name string name of the stack
- : @return the top node, or empty sequence if stack is empty
- : @example test/Queries/pop2.xq
-:)
-declare %ann:sequential function stack:pop($name as xs:string) as node()?
-{
-  let $stname := fn:QName($stack:global-uri, $name)
-  let $stack-content := collections-dml:collection($stname)
-  return 
-      if(fn:not(fn:empty($stack-content))) then
-      {
-        variable $top-node := $stack-content[1];
-        collections-dml:delete-node-first($stname);
-        $top-node
-      }
-      else 
-        ()
-};
-
-(:~
- : Add a new node to the stack.
- : @param $name string name of the stack
- : @param $value the node to be added
- : @example test/Queries/push1.xq
-:)
-declare %ann:sequential function stack:push($name as xs:string, $value as node())
-{
-  variable $stname := fn:QName($stack:global-uri, $name);
-  collections-dml:apply-insert-nodes-first($stname, $value);
-};
-
-(:~
- : Checks if a stack exists and is empty.
- : @param $name string name of the stack
- : @return true is the stack is empty or does not exist
- : @example test/Queries/empty1.xq
-:)
-declare function stack:empty($name as xs:string) as xs:boolean
-{
-  let $stname := fn:QName($stack:global-uri, $name)
-  return
-      if(collections-ddl:is-available-collection($stname)) then
-        fn:empty(collections-dml:collection($stname))
-      else 
-        fn:true()
-};
-
-(:~
- : Get the count of nodes in the stack.
- : @param $name string name of the stack
- : @return the count of nodes
- : @example test/Queries/size1.xq
-:)
-declare function stack:size($name as xs:string) as xs:integer
-{
-  let $stname := fn:QName($stack:global-uri, $name)
-  return
-    fn:count(collections-dml:collection($stname))
-};
-
-(:~
- : Remove the stack with all the nodes in it.
- : @param $name string name of the stack
- : @example test/Queries/delete1.xq
-:)
-declare %ann:sequential function stack:delete($name as xs:string)
-{
-  let $stname := fn:QName($stack:global-uri, $name)
-  return
-      if(collections-ddl:is-available-collection($stname)) then
-      {
-        collections-dml:delete-nodes-first($stname, stack:size($name));
-        collections-ddl:delete($stname);
-        ()
-      }
-      else
-        ()
-};
-
-(:~
- : Copy all nodes from source stack to a destination stack.<br />
- : If destination stack does not exist, it is created first.<br />
- : If destination stack is not empty, the nodes are appended on top.
- : @param $destname string name of the destination stack
- : @param $sourcename string name of the source stack
- : @example test/Queries/copy1.xq
-:)
-declare %ann:sequential function stack:copy($destname as xs:string, $sourcename as xs:string)
-{
-  variable $destqname := fn:QName($stack:global-uri, $destname);
-  if(fn:not(collections-ddl:is-available-collection($destqname))) then
-    collections-ddl:create($destqname);
-  else
-    ();
-  variable $sourceqname := fn:QName($stack:global-uri, $sourcename);
-  collections-dml:insert-nodes-first($destqname, collections-dml:collection($sourceqname));
-};

=== added file 'src/stack.xq'
--- src/stack.xq	1970-01-01 00:00:00 +0000
+++ src/stack.xq	2012-02-29 09:07:21 +0000
@@ -0,0 +1,160 @@
+xquery version "3.0";
+
+(:
+ : Copyright 2006-2012 The FLWOR Foundation.
+ :
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+:)
+
+(:~
+ : Implementation of stack for node items, using collections data structures.<br />
+ : Stacks are created at first node insert.
+ :
+ : @author Daniel Turcanu
+ : @project store/data structures
+ :)
+module namespace stack = "http://www.zorba-xquery.com/modules/store/data-structures/stack";;
+
+import module namespace collections-ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
+import module namespace collections-dml = "http://www.zorba-xquery.com/modules/store/dynamic/collections/dml";;
+
+declare namespace ann = "http://www.zorba-xquery.com/annotations";;
+declare namespace ver = "http://www.zorba-xquery.com/options/versioning";;
+declare option ver:module-version "1.0";
+
+(:~
+ : Create a stack with this name. <br /> If stack exists, it is deleted first.
+ : @param $name name of the new stack.
+:)
+declare %ann:sequential function stack:create($name as xs:QName)
+{
+  stack:delete($name);
+  collections-ddl:create($name);
+};
+
+(:~
+ : Return a list of names for available stacks.
+ : @return the list of created stack names.
+ : @example test/Queries/available1.xq
+:)
+declare function stack:available-stacks() as xs:QName*
+{
+  for $collQName in collections-ddl:available-collections()
+  return $collQName
+};
+
+(:~
+ : Return the top node in the stack, without removing it.
+ : @param $name name of the stack.
+ : @return the top node, or empty sequence if stack is empty.
+ : @example test/Queries/top1.xq
+:)
+declare function stack:top($name as xs:QName) as node()?
+{
+  let $stackContent := collections-dml:collection($name)
+  return
+    if(fn:not(fn:empty($stackContent))) then
+      $stackContent[1]
+    else 
+      ()
+};
+                                 
+(:~
+ : Return the top node in the stack, and remove it.
+ : @param $name name of the stack.
+ : @return the top node, or empty sequence if stack is empty.
+ : @example test/Queries/pop2.xq
+:)
+declare %ann:sequential function stack:pop($name as xs:QName) as node()?
+{
+  let $stackContent := collections-dml:collection($name)
+  return 
+    if(fn:not(fn:empty($stackContent))) then
+    {
+      variable $topNode := $stackContent[1];
+      collections-dml:delete-node-first($name);
+      $topNode
+    }
+    else 
+      ()
+};
+
+(:~
+ : Add a new node to the stack.
+ : @param $name name of the stack.
+ : @param $value the node to be added.
+ : @example test/Queries/push1.xq
+:)
+declare %ann:sequential function stack:push($name as xs:QName, $value as node())
+{
+  collections-dml:apply-insert-nodes-first($name, $value);
+};
+
+(:~
+ : Checks if a stack exists and is empty.
+ : @param $name name of the stack.
+ : @return true is the stack is empty or does not exist.
+ : @example test/Queries/empty1.xq
+:)
+declare function stack:empty($name as xs:QName) as xs:boolean
+{
+  if(collections-ddl:is-available-collection($name)) then
+    fn:empty(collections-dml:collection($name))
+  else 
+    fn:true()
+};
+
+(:~
+ : Count of nodes in the stack.
+ : @param $name name of the stack.
+ : @return the count of nodes.
+ : @example test/Queries/size1.xq
+:)
+declare function stack:size($name as xs:QName) as xs:integer
+{
+  fn:count(collections-dml:collection($name))
+};
+
+(:~
+ : Remove the stack with all the nodes in it.
+ : @param $name name of the stack.
+ : @example test/Queries/delete1.xq
+:)
+declare %ann:sequential function stack:delete($name as xs:QName)
+{
+  if(collections-ddl:is-available-collection($name)) then
+  {
+    collections-dml:delete-nodes-first($name, stack:size($name));
+    collections-ddl:delete($name);
+    ()
+  }
+  else
+    ()
+};
+
+(:~
+ : Copy all nodes from source stack to a destination stack.<br />
+ : If destination stack does not exist, it is created first.<br />
+ : If destination stack is not empty, the nodes are appended on top.
+ : @param $destName name of the destination stack.
+ : @param $sourceName name of the source stack.
+ : @example test/Queries/copy1.xq
+:)
+declare %ann:sequential function stack:copy($destName as xs:QName, $sourceName as xs:QName)
+{
+  if(fn:not(collections-ddl:is-available-collection($destName))) then
+    collections-ddl:create($destName);
+  else
+    ();
+  collections-dml:insert-nodes-first($destName, collections-dml:collection($sourceName));
+};

=== modified file 'test/ExpQueryResults/available1.xml.res'
--- test/ExpQueryResults/available1.xml.res	2012-02-02 18:47:52 +0000
+++ test/ExpQueryResults/available1.xml.res	2012-02-29 09:07:21 +0000
@@ -1,2 +1,1 @@
-<?xml version="1.0" encoding="UTF-8"?>
-stack1
\ No newline at end of file
+stack12 stack1

=== modified file 'test/Queries/available1.xq'
--- test/Queries/available1.xq	2012-02-02 18:47:52 +0000
+++ test/Queries/available1.xq	2012-02-29 09:07:21 +0000
@@ -1,7 +1,9 @@
 import module namespace stack = "http://www.zorba-xquery.com/modules/store/data-structures/stack";;
 import module namespace collections-ddl = "http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";;
 
-collections-ddl:create(fn:QName("http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";, "stack12"));
+variable $name := fn:QName("http://www.zorba-xquery.com/modules/store/dynamic/collections/ddl";, "stack12");
+variable $stName := fn:QName("", "stack1");
+collections-ddl:create($name);
 
-stack:create("stack1");
+stack:create($stName);
 stack:available-stacks()

=== modified file 'test/Queries/copy1.xq'
--- test/Queries/copy1.xq	2012-02-02 18:47:52 +0000
+++ test/Queries/copy1.xq	2012-02-29 09:07:21 +0000
@@ -1,9 +1,11 @@
 import module namespace stack = "http://www.zorba-xquery.com/modules/store/data-structures/stack";;
 
-stack:create("stack1");
-stack:push("stack1", <a/>);
-stack:push("stack1", <b/>);
-stack:push("stack1", <c/>);
-stack:copy("stackcopy", "stack1");
-(stack:top("stack1"),
-stack:top("stackcopy"))
+variable $stName := fn:QName("", "stack1");
+variable $stCopy := fn:QName("", "stackcopy");
+stack:create($stName);
+stack:push($stName, <a/>);
+stack:push($stName, <b/>);
+stack:push($stName, <c/>);
+stack:copy($stCopy, $stName);
+(stack:top($stName),
+stack:top($stCopy))

=== modified file 'test/Queries/create1.xq'
--- test/Queries/create1.xq	2012-02-02 18:47:52 +0000
+++ test/Queries/create1.xq	2012-02-29 09:07:21 +0000
@@ -1,9 +1,10 @@
 import module namespace stack = "http://www.zorba-xquery.com/modules/store/data-structures/stack";;
 
+variable $stName := fn:QName("", "stack1");
 (
-stack:create("stack1"),
-stack:push("stack1", <z/>),
-stack:push("stack1", <a/>),
-stack:create("stack1"),
-stack:top("stack1")
-)
\ No newline at end of file
+  stack:create($stName),
+  stack:push($stName, <z/>),
+  stack:push($stName, <a/>),
+  stack:create($stName),
+  stack:top($stName)
+)

=== modified file 'test/Queries/delete1.xq'
--- test/Queries/delete1.xq	2012-02-02 18:47:52 +0000
+++ test/Queries/delete1.xq	2012-02-29 09:07:21 +0000
@@ -1,6 +1,7 @@
 import module namespace stack = "http://www.zorba-xquery.com/modules/store/data-structures/stack";;
 
-stack:create("stack1");
-stack:push("stack1", <a/>);
-stack:delete("stack1");
+variable $stName := fn:QName("", "stack1");
+stack:create($stName);
+stack:push($stName, <a/>);
+stack:delete($stName);
 stack:available-stacks()

=== modified file 'test/Queries/delete2.xq'
--- test/Queries/delete2.xq	2012-02-02 18:47:52 +0000
+++ test/Queries/delete2.xq	2012-02-29 09:07:21 +0000
@@ -1,4 +1,5 @@
 import module namespace stack = "http://www.zorba-xquery.com/modules/store/data-structures/stack";;
 
-stack:delete("stack1");
-stack:empty("stack1")
+variable $stName := fn:QName("", "stack1");
+stack:delete($stName);
+stack:empty($stName)

=== modified file 'test/Queries/empty1.xq'
--- test/Queries/empty1.xq	2012-02-02 18:47:52 +0000
+++ test/Queries/empty1.xq	2012-02-29 09:07:21 +0000
@@ -1,12 +1,13 @@
 import module namespace stack = "http://www.zorba-xquery.com/modules/store/data-structures/stack";;
 
+variable $stName := fn:QName("", "stack1");
 (
-stack:create("stack1"),
-stack:push("stack1", <a/>),
-stack:top("stack1"),
-stack:empty("stack1"),
-stack:pop("stack1"),
-stack:pop("stack1"),
-stack:top("stack1"),
-stack:empty("stack1")
-)
\ No newline at end of file
+  stack:create($stName),
+  stack:push($stName, <a/>),
+  stack:top($stName),
+  stack:empty($stName),
+  stack:pop($stName),
+  stack:pop($stName),
+  stack:top($stName),
+  stack:empty($stName)
+)

=== modified file 'test/Queries/pop1.xq'
--- test/Queries/pop1.xq	2012-02-02 18:47:52 +0000
+++ test/Queries/pop1.xq	2012-02-29 09:07:21 +0000
@@ -1,4 +1,5 @@
 import module namespace stack = "http://www.zorba-xquery.com/modules/store/data-structures/stack";;
 
-stack:create("stack1");
-stack:pop("stack1")
\ No newline at end of file
+variable $stName := fn:QName("", "stack1");
+stack:create($stName);
+stack:pop($stName)

=== modified file 'test/Queries/pop2.xq'
--- test/Queries/pop2.xq	2012-02-02 18:47:52 +0000
+++ test/Queries/pop2.xq	2012-02-29 09:07:21 +0000
@@ -1,6 +1,7 @@
 import module namespace stack = "http://www.zorba-xquery.com/modules/store/data-structures/stack";;
 
-stack:create("stack1");
-stack:push("stack1", <b/>);
-stack:push("stack1", <a/>);
-stack:pop("stack1")
\ No newline at end of file
+variable $stName := fn:QName("", "stack1");
+stack:create($stName);
+stack:push($stName, <b/>);
+stack:push($stName, <a/>);
+stack:pop($stName)

=== modified file 'test/Queries/push1.xq'
--- test/Queries/push1.xq	2012-02-02 18:47:52 +0000
+++ test/Queries/push1.xq	2012-02-29 09:07:21 +0000
@@ -1,4 +1,5 @@
 import module namespace stack = "http://www.zorba-xquery.com/modules/store/data-structures/stack";;
 
-stack:create("stack1");
-stack:push("stack1", <a/>)
\ No newline at end of file
+variable $stName := fn:QName("", "stack1");
+stack:create($stName);
+stack:push($stName, <a/>)

=== modified file 'test/Queries/size1.xq'
--- test/Queries/size1.xq	2012-02-02 18:47:52 +0000
+++ test/Queries/size1.xq	2012-02-29 09:07:21 +0000
@@ -1,13 +1,14 @@
 import module namespace stack = "http://www.zorba-xquery.com/modules/store/data-structures/stack";;
 
+variable $stName := fn:QName("", "stack1");
 (
-stack:create("stack1"),
-stack:size("stack1"),
-stack:push("stack1", <a/>),
-stack:top("stack1"),
-stack:size("stack1"),
-stack:pop("stack1"),
-stack:pop("stack1"),
-stack:top("stack1"),
-stack:size("stack1")
-)
\ No newline at end of file
+  stack:create($stName),
+  stack:size($stName),
+  stack:push($stName, <a/>),
+  stack:top($stName),
+  stack:size($stName),
+  stack:pop($stName),
+  stack:pop($stName),
+  stack:top($stName),
+  stack:size($stName)
+)

=== modified file 'test/Queries/top1.xq'
--- test/Queries/top1.xq	2012-02-02 18:47:52 +0000
+++ test/Queries/top1.xq	2012-02-29 09:07:21 +0000
@@ -1,11 +1,12 @@
 import module namespace stack = "http://www.zorba-xquery.com/modules/store/data-structures/stack";;
 
+variable $stName := fn:QName("", "stack1");
 (
-stack:create("stack1"),
-stack:push("stack1", <z/>),
-stack:push("stack1", <a/>),
-stack:top("stack1"),
-stack:pop("stack1"),
-stack:pop("stack1"),
-stack:top("stack1")
-)
\ No newline at end of file
+  stack:create($stName),
+  stack:push($stName, <z/>),
+  stack:push($stName, <a/>),
+  stack:top($stName),
+  stack:pop($stName),
+  stack:pop($stName),
+  stack:top($stName)
+)

-- 
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