Merge lp:~zorba-coders/zorba/bug931580 into lp:zorba

Proposed by Rodolfo Ochoa
Status: Merged
Approved by: Rodolfo Ochoa
Approved revision: 10674
Merged at revision: 10733
Proposed branch: lp:~zorba-coders/zorba/bug931580
Merge into: lp:zorba
Diff against target: 5310 lines (+3914/-530)
80 files modified
ChangeLog (+6/-1)
doc/php/examples/CMakeLists.txt (+5/-1)
doc/php/examples/zorba_api.php (+1/-1)
doc/ruby/examples/CMakeLists.txt (+6/-1)
swig/Collection.h (+47/-0)
swig/Collection.i (+91/-0)
swig/CollectionManager.h (+37/-0)
swig/CollectionManager.i (+47/-0)
swig/DocumentManager.h (+36/-0)
swig/DocumentManager.i (+46/-0)
swig/DynamicContext.h (+45/-0)
swig/DynamicContext.i (+59/-0)
swig/Item.h (+68/-0)
swig/Item.i (+114/-0)
swig/ItemFactory.h (+34/-5)
swig/ItemFactory.i (+44/-10)
swig/ItemSequence.h (+32/-0)
swig/ItemSequence.i (+26/-0)
swig/Iterator.h (+57/-0)
swig/Iterator.i (+69/-0)
swig/SerializationOptions.h (+114/-0)
swig/SerializationOptions.i (+125/-0)
swig/StaticContext.h (+122/-47)
swig/StaticContext.i (+224/-70)
swig/Store.i (+2/-0)
swig/TypeIdentifier.h (+97/-0)
swig/TypeIdentifier.i (+197/-0)
swig/XQuery.h (+47/-0)
swig/XQuery.i (+23/-295)
swig/XmlDataManager.h (+35/-0)
swig/XmlDataManager.i (+12/-67)
swig/Zorba.i (+40/-8)
swig/java/CMakeLists.txt (+15/-2)
swig/java/zorba_api.i (+2/-1)
swig/php/CMakeLists.txt (+14/-0)
swig/php/tests/CMakeLists.txt (+90/-0)
swig/php/tests/books.xml (+11/-0)
swig/php/tests/compilerHints.xq (+4/-0)
swig/php/tests/php.ini.in (+3/-0)
swig/php/tests/test01.php (+29/-0)
swig/php/tests/test02.php (+44/-0)
swig/php/tests/test03.php (+48/-0)
swig/php/tests/test04.php (+43/-0)
swig/php/tests/test04.xq (+4/-0)
swig/php/tests/test05.php (+43/-0)
swig/php/tests/test05.xq (+7/-0)
swig/php/tests/test06.php (+43/-0)
swig/php/tests/test06.xq (+7/-0)
swig/php/tests/test07.php (+56/-0)
swig/php/tests/test08.php (+120/-0)
swig/php/tests/test09.php (+92/-0)
swig/php/tests/test10.php (+55/-0)
swig/php/tests/test11.php (+52/-0)
swig/php/tests/test12.php (+52/-0)
swig/php/tests/test13.php (+53/-0)
swig/php/tests/test14.php (+53/-0)
swig/php/tests/zorba_api.php (+178/-0)
swig/python/CMakeLists.txt (+19/-9)
swig/ruby/CMakeLists.txt (+16/-2)
swig/ruby/tests/CMakeLists.txt (+83/-0)
swig/ruby/tests/books.xml (+11/-0)
swig/ruby/tests/compilerHints.xq (+4/-0)
swig/ruby/tests/test01.rb (+24/-0)
swig/ruby/tests/test02.rb (+39/-0)
swig/ruby/tests/test03.rb (+43/-0)
swig/ruby/tests/test04.rb (+35/-0)
swig/ruby/tests/test04.xq (+4/-0)
swig/ruby/tests/test05.rb (+35/-0)
swig/ruby/tests/test05.xq (+7/-0)
swig/ruby/tests/test06.rb (+35/-0)
swig/ruby/tests/test06.xq (+7/-0)
swig/ruby/tests/test07.rb (+48/-0)
swig/ruby/tests/test08.rb (+108/-0)
swig/ruby/tests/test09.rb (+81/-0)
swig/ruby/tests/test10.rb (+46/-0)
swig/ruby/tests/test11.rb (+49/-0)
swig/ruby/tests/test12.rb (+49/-0)
swig/ruby/tests/test13.rb (+50/-0)
swig/ruby/tests/test14.rb (+50/-0)
swig/zorba_api.i (+45/-10)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug931580
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Rodolfo Ochoa Approve
Cezar Andrei Approve
Review via email: mp+92818@code.launchpad.net

Commit message

This upgrade supply the required objects and methods for basic XQJ support.

Description of the change

This upgrade supply the required objects and methods for basic XQJ support.

To post a comment you must log in.
Revision history for this message
Cezar Andrei (cezar-andrei) wrote :

Looks good.

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

The attempt to merge lp:~zorba-coders/zorba/bug931580 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job bug931580-2012-02-16T19-01-07.77Z is finished. The
  final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

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

The attempt to merge lp:~zorba-coders/zorba/bug931580 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job bug931580-2012-02-17T00-45-00.129Z is finished. The
  final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

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

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Cezar Andrei (cezar-andrei) :
review: Approve
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 bug931580-2012-02-17T23-30-02.51Z 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. Got: 1 Approve, 2 Pending.

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

The change provides a great extension to all of Zorba's language bindings.

Two things:
- it currently doesn't build on my machine (Ubuntu 11.04 with gcc 4.5.2)

[ 97%] Building CXX object swig/python/CMakeFiles/_zorba_api_python.dir/zorba_apiPYTHON_wrap.cxx.o
In file included from /usr/include/python2.7/Python.h:8:0,
                 from /home/mbrantner/zorba/build/swig/python/zorba_apiPYTHON_wrap.cxx:158:
/usr/include/python2.7/pyconfig.h:1155:0: warning: "_POSIX_C_SOURCE" redefined
/usr/include/features.h:163:0: note: this is the location of the previous definition
/usr/include/python2.7/pyconfig.h:1177:0: warning: "_XOPEN_SOURCE" redefined
/usr/include/features.h:165:0: note: this is the location of the previous definition
/home/mbrantner/zorba/build/swig/python/zorba_apiPYTHON_wrap.cxx: In function ‘PyTypeObject* _PySwigObject_type()’:
/home/mbrantner/zorba/build/swig/python/zorba_apiPYTHON_wrap.cxx:1855:7: warning: missing initializer for member ‘_typeobject::tp_version_tag’
/home/mbrantner/zorba/build/swig/python/zorba_apiPYTHON_wrap.cxx: In function ‘PyTypeObject* _PySwigPacked_type()’:
/home/mbrantner/zorba/build/swig/python/zorba_apiPYTHON_wrap.cxx:2030:7: warning: missing initializer for member ‘_typeobject::tp_version_tag’
/home/mbrantner/zorba/build/swig/python/zorba_apiPYTHON_wrap.cxx: In member function ‘int SAX2Attributes::getIndex(const char*, const char*) const’:
/home/mbrantner/zorba/build/swig/python/zorba_apiPYTHON_wrap.cxx:2894:14: warning: converting to non-pointer type ‘int’ from NULL
/home/mbrantner/zorba/build/swig/python/zorba_apiPYTHON_wrap.cxx: In member function ‘int SAX2Attributes::getIndex(const char*) const’:
/home/mbrantner/zorba/build/swig/python/zorba_apiPYTHON_wrap.cxx:2902:14: warning: converting to non-pointer type ‘int’ from NULL
In file included from /home/mbrantner/zorba/build/swig/python/zorba_apiPYTHON_wrap.cxx:3471:0:
/home/mbrantner/zorba/build/swig/python/StaticContext.h: At global scope:
/home/mbrantner/zorba/build/swig/python/StaticContext.h:116:3: error: ‘TypeIdentifier’ does not name a type
/home/mbrantner/zorba/build/swig/python/StaticContext.h:117:3: error: ‘TypeIdentifier’ does not name a type
/home/mbrantner/zorba/build/swig/python/StaticContext.h:118:3: error: ‘TypeIdentifier’ does not name a type
/home/mbrantner/zorba/build/swig/python/StaticContext.h:120:39: error: ‘TypeIdentifier’ does not name a type
/home/mbrantner/zorba/build/swig/python/StaticContext.h:120:55: error: ISO C++ forbids declaration of ‘aType’ with no type

- Also, I'm a little bit worried about the absence of tests for the language bindings other than Java. We should at least have some testing for them (e.g. PHP, Python, and Ruby).

review: Needs Fixing
Revision history for this message
Rodolfo Ochoa (rodolfo-ochoa) wrote :

- Ruby, PHP and Python tests are working
- Python error is fixed

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

The attempt to merge lp:~zorba-coders/zorba/bug931580 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job bug931580-2012-03-21T14-20-18.368Z is finished. The
  final status was:

  8 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

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 bug931580-2012-03-21T22-11-04.21Z 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: 2 Approve, 1 Needs Fixing.

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

- Why does the CollectionManager exist? It doesn't seem to be accessible from anywhere?
- The ChangeLog needs to be updated to reflect the new features.

review: Needs Fixing
Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Attempt to merge into lp:zorba failed due to conflicts:

text conflict in ChangeLog

lp:~zorba-coders/zorba/bug931580 updated
10674. By Rodolfo Ochoa

-Solved conflict with Changelog

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 bug931580-2012-03-26T20-17-59.753Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2012-03-26 19:41:44 +0000
+++ ChangeLog 2012-03-26 20:16:18 +0000
@@ -1,10 +1,15 @@
1Zorba - The XQuery Processor1Zorba - The XQuery Processor
22
3version 2.53version 2.5
4
5New Features:
6 * Extended API for Python, Java, PHP and Ruby.
7
8Bug Fixes/Other Changes:
4 * Fixed bug in window iterator9 * Fixed bug in window iterator
5 * Fixed bug #872234 (prevent a rewritting to take place in case of sequential expr)10 * Fixed bug #872234 (prevent a rewritting to take place in case of sequential expr)
611
7 12
8version 2.213version 2.2
914
10New Features:15New Features:
1116
=== modified file 'doc/php/examples/CMakeLists.txt'
--- doc/php/examples/CMakeLists.txt 2012-03-23 17:32:07 +0000
+++ doc/php/examples/CMakeLists.txt 2012-03-26 20:16:18 +0000
@@ -18,7 +18,11 @@
1818
19 SET(phpPath ${CMAKE_BINARY_DIR}/swig/php)19 SET(phpPath ${CMAKE_BINARY_DIR}/swig/php)
20 MESSAGE(STATUS "PHP Path:" ${phpPath})20 MESSAGE(STATUS "PHP Path:" ${phpPath})
21 SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php)21 IF (MSVC_IDE)
22 SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php/@CMAKE_BUILD_TYPE@)
23 ELSE (MSVC_IDE)
24 SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php)
25 ENDIF (MSVC_IDE)
22 MESSAGE(STATUS "PHP Extension Path: " ${phpExtensionPath})26 MESSAGE(STATUS "PHP Extension Path: " ${phpExtensionPath})
23 SET(phpIncludePath ${CMAKE_BINARY_DIR}/swig/php)27 SET(phpIncludePath ${CMAKE_BINARY_DIR}/swig/php)
24 MESSAGE(STATUS "PHP Include Path: " ${phpExtensionPath})28 MESSAGE(STATUS "PHP Include Path: " ${phpExtensionPath})
2529
=== modified file 'doc/php/examples/zorba_api.php'
--- doc/php/examples/zorba_api.php 2012-03-23 17:32:07 +0000
+++ doc/php/examples/zorba_api.php 2012-03-26 20:16:18 +0000
@@ -18,7 +18,7 @@
18// Try to load our extension if it's not already loaded.18// Try to load our extension if it's not already loaded.
19if (!extension_loaded("zorba_api")) {19if (!extension_loaded("zorba_api")) {
20 if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {20 if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
21 if (!dl('php_zorba_api.dll')) return;21 if (!dl('zorba_api.dll')) return;
22 } else {22 } else {
23 // PHP_SHLIB_SUFFIX is available as of PHP 4.3.0, for older PHP assume 'so'.23 // PHP_SHLIB_SUFFIX is available as of PHP 4.3.0, for older PHP assume 'so'.
24 // It gives 'dylib' on MacOS X which is for libraries, modules are 'so'.24 // It gives 'dylib' on MacOS X which is for libraries, modules are 'so'.
2525
=== modified file 'doc/ruby/examples/CMakeLists.txt'
--- doc/ruby/examples/CMakeLists.txt 2012-03-23 17:32:07 +0000
+++ doc/ruby/examples/CMakeLists.txt 2012-03-26 20:16:18 +0000
@@ -18,7 +18,12 @@
18 IF (NOT RUBY_EXECUTABLE)18 IF (NOT RUBY_EXECUTABLE)
19 MESSAGE(STATUS "Ruby test not added because Ruby Interpreter not found.")19 MESSAGE(STATUS "Ruby test not added because Ruby Interpreter not found.")
20 ELSE (NOT RUBY_EXECUTABLE)20 ELSE (NOT RUBY_EXECUTABLE)
21 SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby)21 MESSAGE(STATUS "RUBY_EXECUTABLE: " ${RUBY_EXECUTABLE})
22 IF (MSVC_IDE)
23 SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby/@CMAKE_BUILD_TYPE@)
24 ELSE (MSVC_IDE)
25 SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby)
26 ENDIF (MSVC_IDE)
22 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/ruby_test.rb.in ${CMAKE_CURRENT_BINARY_DIR}/ruby_test.rb)27 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/ruby_test.rb.in ${CMAKE_CURRENT_BINARY_DIR}/ruby_test.rb)
23 ADD_TEST("ruby" ${RUBY_EXECUTABLE} ruby_test.rb)28 ADD_TEST("ruby" ${RUBY_EXECUTABLE} ruby_test.rb)
24 ENDIF(NOT RUBY_EXECUTABLE)29 ENDIF(NOT RUBY_EXECUTABLE)
2530
=== added file 'swig/Collection.h'
--- swig/Collection.h 1970-01-01 00:00:00 +0000
+++ swig/Collection.h 2012-03-26 20:16:18 +0000
@@ -0,0 +1,47 @@
1/*
2 * Copyright 2006-2012 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef API_COLLECTION_H
17#define API_COLLECTION_H
18
19class Collection
20{
21private:
22 zorba::Collection* theCollection;
23
24public:
25 Collection() : theCollection(0) {}
26 Collection(const Collection& aMgr) : theCollection(aMgr.theCollection) {}
27 Collection(zorba::Collection* aMgr) : theCollection(aMgr) {}
28
29 ItemSequence contents();
30 void deleteNodeFirst();
31 void deleteNodeLast();
32 void deleteNodes(const ItemSequence &aNodes );
33 void deleteNodesFirst(unsigned long aNumNodes );
34 void deleteNodesLast(unsigned long aNumNodes );
35 //std::vector< Annotation > getAnnotations():
36 Item getName();
37 TypeIdentifier getType();
38 long long indexOf(const Item &aNode );
39 void insertNodesAfter(const Item &aTarget, const ItemSequence &aNodes );
40 void insertNodesBefore(const Item &aTarget, const ItemSequence &aNodes );
41 void insertNodesFirst(const ItemSequence &aNodes );
42 void insertNodesLast(const ItemSequence &aNodes );
43 bool isStatic();
44 //void registerDiagnosticHandler(DiagnosticHandler *aDiagnosticHandler );
45};
46
47#endif
0\ No newline at end of file48\ No newline at end of file
149
=== added file 'swig/Collection.i'
--- swig/Collection.i 1970-01-01 00:00:00 +0000
+++ swig/Collection.i 2012-03-26 20:16:18 +0000
@@ -0,0 +1,91 @@
1/*
2 * Copyright 2006-2012 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17%{ // start Implementation
18
19 ItemSequence Collection::contents()
20 {
21 return ItemSequence( theCollection->contents() );
22 }
23
24 void Collection::deleteNodeFirst()
25 {
26 theCollection->deleteNodeFirst();
27 }
28
29 void Collection::deleteNodeLast()
30 {
31 theCollection->deleteNodeLast();
32 }
33
34 void Collection::deleteNodes(const ItemSequence &aNodes )
35 {
36 theCollection->deleteNodes( aNodes.theItemSequence );
37 }
38
39 void Collection::deleteNodesFirst(unsigned long aNumNodes )
40 {
41 theCollection->deleteNodesFirst(aNumNodes);
42 }
43
44 void Collection::deleteNodesLast(unsigned long aNumNodes )
45 {
46 theCollection->deleteNodesLast(aNumNodes);
47 }
48
49 Item Collection::getName()
50 {
51 return Item( theCollection->getName() );
52 }
53
54 TypeIdentifier Collection::getType()
55 {
56 return TypeIdentifier( theCollection->getType() );
57 }
58
59 long long Collection::indexOf(const Item &aNode )
60 {
61 return theCollection->indexOf( aNode.theItem );
62 }
63
64 void Collection::insertNodesAfter(const Item &aTarget, const ItemSequence &aNodes )
65 {
66 theCollection->insertNodesAfter( aTarget.theItem, aNodes.theItemSequence );
67 }
68
69 void Collection::insertNodesBefore(const Item &aTarget, const ItemSequence &aNodes )
70 {
71 theCollection->insertNodesBefore( aTarget.theItem, aNodes.theItemSequence );
72 }
73
74 void Collection::insertNodesFirst(const ItemSequence &aNodes )
75 {
76 theCollection->insertNodesFirst( aNodes.theItemSequence );
77 }
78
79 void Collection::insertNodesLast(const ItemSequence &aNodes )
80 {
81 theCollection->insertNodesLast( aNodes.theItemSequence );
82 }
83
84 bool Collection::isStatic()
85 {
86 return theCollection->isStatic();
87 }
88
89%} // end Implementation
90
91%include "Collection.h"
092
=== added file 'swig/CollectionManager.h'
--- swig/CollectionManager.h 1970-01-01 00:00:00 +0000
+++ swig/CollectionManager.h 2012-03-26 20:16:18 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright 2006-2012 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef API_COLLECTION_MANAGER_H
17#define API_COLLECTION_MANAGER_H
18
19class CollectionManager
20{
21private:
22 zorba::CollectionManager* theManager;
23
24public:
25 CollectionManager() : theManager(0) {}
26 CollectionManager(const CollectionManager& aMgr) : theManager(aMgr.theManager) {}
27 CollectionManager(zorba::CollectionManager* aMgr) : theManager(aMgr) {}
28
29 ItemSequence availableCollections();
30 void createCollection(const Item &aName );
31 void deleteCollection(const Item &aName );
32 Collection getCollection(const Item &aName );
33 bool isAvailableCollection(const Item &aName );
34 //virtual void registerDiagnosticHandler(DiagnosticHandler *aDiagnosticHandler )
35};
36
37#endif
0\ No newline at end of file38\ No newline at end of file
139
=== added file 'swig/CollectionManager.i'
--- swig/CollectionManager.i 1970-01-01 00:00:00 +0000
+++ swig/CollectionManager.i 2012-03-26 20:16:18 +0000
@@ -0,0 +1,47 @@
1/*
2 * Copyright 2006-2012 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17%{ // start Implementation
18
19 ItemSequence CollectionManager::availableCollections()
20 {
21 return ItemSequence( theManager->availableCollections() );
22 }
23
24 void CollectionManager::createCollection(const Item &aName )
25 {
26 theManager->createCollection(aName.theItem );
27 }
28
29 void CollectionManager::deleteCollection(const Item &aName )
30 {
31 theManager->deleteCollection(aName.theItem );
32 }
33
34 Collection CollectionManager::getCollection(const Item &aName )
35 {
36 return Collection(theManager->getCollection(aName.theItem ));
37 }
38
39 bool CollectionManager::isAvailableCollection(const Item &aName )
40 {
41 return theManager->isAvailableCollection(aName.theItem );
42 }
43
44
45%} // end Implementation
46
47%include "CollectionManager.h"
048
=== added file 'swig/DocumentManager.h'
--- swig/DocumentManager.h 1970-01-01 00:00:00 +0000
+++ swig/DocumentManager.h 2012-03-26 20:16:18 +0000
@@ -0,0 +1,36 @@
1/*
2 * Copyright 2006-2012 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef API_DOCUMENT_MANAGER_H
17#define API_DOCUMENT_MANAGER_H
18
19class DocumentManager
20{
21private:
22 zorba::DocumentManager* theManager;
23
24public:
25 DocumentManager() : theManager(0) {}
26 DocumentManager(const DocumentManager& aMgr) : theManager(aMgr.theManager) {}
27 DocumentManager(zorba::DocumentManager* aMgr) : theManager(aMgr) {}
28
29 void put(const std::string& aName, Item aDoc);
30 void remove(const std::string& aName);
31 Item document(const std::string& aName);
32 bool isAvailableDocument(const std::string& aName);
33 ItemSequence availableDocuments();
34};
35
36#endif
0\ No newline at end of file37\ No newline at end of file
138
=== added file 'swig/DocumentManager.i'
--- swig/DocumentManager.i 1970-01-01 00:00:00 +0000
+++ swig/DocumentManager.i 2012-03-26 20:16:18 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright 2006-2012 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17%{ // start Implementation
18 void DocumentManager::put(const std::string& aName, Item aDoc)
19 {
20 theManager->put(aName, aDoc.theItem);
21 }
22
23 void DocumentManager::remove(const std::string& aName)
24 {
25 theManager->remove(aName);
26 }
27
28 Item DocumentManager::document(const std::string& aName)
29 {
30 return theManager->document(aName);
31 }
32
33 bool DocumentManager::isAvailableDocument(const std::string& aName)
34 {
35 return theManager->isAvailableDocument(aName);
36 }
37
38 ItemSequence DocumentManager::availableDocuments()
39 {
40 return ItemSequence( theManager->availableDocuments() );
41 }
42
43
44%} // end Implementation
45
46%include "DocumentManager.h"
047
=== added file 'swig/DynamicContext.h'
--- swig/DynamicContext.h 1970-01-01 00:00:00 +0000
+++ swig/DynamicContext.h 2012-03-26 20:16:18 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef API_DYNAMIC_CONTEXT_H
17#define API_DYNAMIC_CONTEXT_H
18
19class DynamicContext
20{
21private:
22 zorba::DynamicContext* theContext;
23public:
24
25 DynamicContext():theContext(0) {}
26 DynamicContext(const DynamicContext& aCtx):theContext(aCtx.theContext) {}
27 DynamicContext(zorba::DynamicContext* aCtx):theContext(aCtx) {}
28
29 bool getContextItem (Item& aItem);
30 Item getCurrentDateTime ();
31 Item getDefaultCollection ();
32 int getImplicitTimezone ();
33 bool getVariable (const std::string& aNamespace, const std::string& aLocalname, Item& aItem, Iterator& aIterator);
34
35 bool setContextItem (Item& aItem);
36 bool setCurrentDateTime (Item& aDateTimeItem);
37 bool setDefaultCollection (Item& aCollectionUri);
38 bool setImplicitTimezone (int aTimezone);
39 bool setVariable (const std::string& aNamespace, const std::string& aLocalname, Iterator& aIter);
40 bool setVariable (const std::string& aQName, Item& aItem);
41 bool setVariable (const std::string& aQName, Iterator& aIterator);
42
43};
44
45#endif
0\ No newline at end of file46\ No newline at end of file
147
=== added file 'swig/DynamicContext.i'
--- swig/DynamicContext.i 1970-01-01 00:00:00 +0000
+++ swig/DynamicContext.i 2012-03-26 20:16:18 +0000
@@ -0,0 +1,59 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17%{ // start Implementation
18
19 bool DynamicContext::getContextItem (Item& aItem) {
20 return theContext->getContextItem(aItem.theItem);
21 }
22 Item DynamicContext::getCurrentDateTime (){
23 return Item(theContext->getCurrentDateTime());
24 }
25 Item DynamicContext::getDefaultCollection () {
26 return Item(theContext->getDefaultCollection());
27 }
28 int DynamicContext::getImplicitTimezone (){
29 return theContext->getImplicitTimezone();
30 }
31 bool DynamicContext::getVariable (const std::string& aNamespace, const std::string& aLocalname, Item& aItem, Iterator& aIterator) {
32 return theContext->getVariable(aNamespace, aLocalname, aItem.theItem, aIterator.theIterator);
33 }
34
35 bool DynamicContext::setContextItem (Item& aItem) {
36 return theContext->setContextItem(aItem.theItem);
37 }
38 bool DynamicContext::setCurrentDateTime (Item& aDateTimeItem) {
39 return theContext->setCurrentDateTime(aDateTimeItem.theItem);
40 }
41 bool DynamicContext::setDefaultCollection (Item& aCollectionUri) {
42 return theContext->setDefaultCollection(aCollectionUri.theItem);
43 }
44 bool DynamicContext::setImplicitTimezone (int aTimezone) {
45 return theContext->setImplicitTimezone(aTimezone);
46 }
47 bool DynamicContext::setVariable(const std::string& aNamespace, const std::string& aLocalname, Iterator& aIter) {
48 return theContext->setVariable(aNamespace, aLocalname, aIter.theIterator);
49 }
50 bool DynamicContext::setVariable (const std::string& aQName, Item& aItem) {
51 return theContext->setVariable (aQName, aItem.theItem);
52 }
53 bool DynamicContext::setVariable (const std::string& aQName, Iterator& aIterator) {
54 return theContext->setVariable (aQName, aIterator.theIterator);
55 }
56
57%} // end Implementation
58
59%include "DynamicContext.h"
060
=== added file 'swig/Item.h'
--- swig/Item.h 1970-01-01 00:00:00 +0000
+++ swig/Item.h 2012-03-26 20:16:18 +0000
@@ -0,0 +1,68 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef API_ITEM_H
18#define API_ITEM_H
19
20class Item
21{
22 friend class Iterator;
23 friend class StaticContext;
24 friend class DocumentManager;
25 friend class SingletonIterator;
26 friend class DynamicContext;
27 friend class ItemFactory;
28 friend class Collection;
29 friend class CollectionManager;
30private:
31 zorba::Item theItem;
32
33public:
34 Item() {}
35 Item(const Item& aItem) : theItem(aItem.theItem) {}
36 Item(const zorba::Item& aZItem) : theItem(aZItem) {}
37
38 static Item createEmptyItem();
39 std::string getStringValue() const;
40 std::string serialize() const;
41 std::string serialize(SerializationOptions serOptions) const;
42 Iterator getAtomizationValue () const;
43 Iterator getAttributes () const;
44 bool getBooleanValue () const;
45 Iterator getChildren () const;
46 Item getEBV () const;
47 int getIntValue () const;
48 double getDoubleValue () const;
49 long long getLongValue () const;
50 std::string getLocalName () const;
51 std::string getNamespace () const;
52 bool getNodeName (Item &aNodeName) const;
53 Item getParent () const;
54 std::string getPrefix () const;
55 Item getType () const;
56 unsigned int getUnsignedIntValue () const;
57
58 int getNodeKind() const;
59 bool isAtomic () const;
60 bool isNaN () const;
61 bool isNode () const;
62 bool isNull () const;
63 bool isPosOrNegInf () const;
64
65 void close();
66}; // class Item
67
68#endif
069
=== added file 'swig/Item.i'
--- swig/Item.i 1970-01-01 00:00:00 +0000
+++ swig/Item.i 2012-03-26 20:16:18 +0000
@@ -0,0 +1,114 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17%{ // start Implementation
18
19 Item Item::createEmptyItem()
20 { return Item(); }
21
22 std::string Item::getStringValue() const
23 { return std::string(theItem.getStringValue().c_str()); }
24
25 std::string Item::serialize() const
26 {
27 std::stringstream lStream;
28 Zorba_SerializerOptions_t lOptions;
29 lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
30 zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(lOptions);
31 zorba::SingletonItemSequence lSequence(theItem);
32 lSerializer->serialize(&lSequence, lStream);
33 return lStream.str();
34 }
35 std::string Item::serialize(SerializationOptions serOptions) const
36 {
37 std::stringstream lStream;
38 serOptions.lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
39 zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(serOptions.lOptions);
40 zorba::SingletonItemSequence lSequence(theItem);
41 lSerializer->serialize(&lSequence, lStream);
42 return lStream.str();
43 }
44
45 Iterator Item::getAtomizationValue () const
46 { return Iterator(theItem.getAtomizationValue()); }
47
48 Iterator Item::getAttributes () const
49 { return Iterator(theItem.getAttributes()); }
50
51 bool Item::getBooleanValue () const
52 { return theItem.getBooleanValue(); }
53
54 Iterator Item::getChildren () const
55 { return Iterator(theItem.getChildren()); }
56
57 Item Item::getEBV () const
58 { return Item(theItem.getEBV()); }
59
60 int Item::getIntValue () const
61 { return theItem.getIntValue(); }
62
63 double Item::getDoubleValue () const
64 { return theItem.getDoubleValue(); }
65
66 long long Item::getLongValue () const
67 { return theItem.getLongValue(); }
68
69 std::string Item::getLocalName () const
70 { return std::string(theItem.getLocalName().c_str()); }
71
72 std::string Item::getNamespace () const
73 { return std::string(theItem.getNamespace().c_str()); }
74
75 bool Item::getNodeName (Item &aNodeName) const
76 { return theItem.getNodeName( aNodeName.theItem ); }
77
78 Item Item::getParent () const
79 { return theItem.getParent(); }
80
81 std::string Item::getPrefix () const
82 { return std::string(theItem.getPrefix().c_str()); }
83
84 Item Item::getType () const
85 { return Item( theItem.getType() ); }
86
87 unsigned int Item::getUnsignedIntValue () const
88 { return theItem.getUnsignedIntValue(); }
89
90 bool Item::isAtomic () const
91 { return theItem.isAtomic(); }
92
93 bool Item::isNaN () const
94 { return theItem.isNaN(); }
95
96 bool Item::isNode () const
97 { return theItem.isNode(); }
98
99 bool Item::isNull () const
100 { return theItem.isNull(); }
101
102 bool Item::isPosOrNegInf () const
103 { return theItem.isPosOrNegInf(); }
104
105 int Item::getNodeKind () const
106 { return theItem.getNodeKind(); }
107
108 void Item::close()
109 { theItem.close(); }
110
111%} // end Implementation
112
113
114%include "Item.h"
0115
=== modified file 'swig/ItemFactory.h'
--- swig/ItemFactory.h 2012-03-23 17:32:07 +0000
+++ swig/ItemFactory.h 2012-03-26 20:16:18 +0000
@@ -1,4 +1,21 @@
1// Interface1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef API_ITEM_FACTORY_H
18#define API_ITEM_FACTORY_H
219
3class ItemFactory20class ItemFactory
4{21{
@@ -11,13 +28,16 @@
11 ItemFactory(const ItemFactory& aItemFactory) : theItemFactory(aItemFactory.theItemFactory) {}28 ItemFactory(const ItemFactory& aItemFactory) : theItemFactory(aItemFactory.theItemFactory) {}
1229
13 Item createAnyURI (const std::string &aURI);30 Item createAnyURI (const std::string &aURI);
14 Item createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, Item aTypedValue);31 Item createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, Item& aTypedValue);
15 Item createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, std::vector< Item > aTypedValue);32#ifndef SWIGRUBY
33 Item createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, std::vector< Item > aTypedValue);
34#endif
16 Item createBase64Binary (const char *aBinData, size_t aLength);35 Item createBase64Binary (const char *aBinData, size_t aLength);
17 Item createBase64Binary (std::istream &aStream);36 Item createBase64Binary (std::istream &aStream);
18 Item createBase64Binary (const unsigned char *aBinData, size_t aLength);37 Item createBase64Binary (const unsigned char *aBinData, size_t aLength);
19 Item createBoolean (bool aValue);38 Item createBoolean (bool aValue);
20 Item createByte (char aByte);39 Item createByte (char aByte);
40 Item createCommentNode (Item &aParent, const std::string &aContent);
21 Item createDate (const std::string &aDate);41 Item createDate (const std::string &aDate);
22 Item createDate (short aYear, short aMonth, short aDay);42 Item createDate (short aYear, short aMonth, short aDay);
23 Item createDateTime (const std::string &aDateTimeValue);43 Item createDateTime (const std::string &aDateTimeValue);
@@ -29,7 +49,13 @@
29 Item createDouble (double aValue);49 Item createDouble (double aValue);
30 Item createDuration (const std::string &aValue);50 Item createDuration (const std::string &aValue);
31 Item createDuration (short aYear, short aMonths, short aDays, short aHours, short aMinutes, double aSeconds);51 Item createDuration (short aYear, short aMonths, short aDays, short aHours, short aMinutes, double aSeconds);
32 //Item createElementNode (Item &aParent, Item aNodeName, Item aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings);52 Item createDayTimeDuration (const std::string &aValue);
53 Item createYearMonthDuration (const std::string &aValue);
54 Item createDocumentNode (const std::string &aBaseUri, const std::string &aDocUri);
55#ifndef SWIGRUBY
56 Item createElementNode (Item &aParent, Item &aNodeName, Item &aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings);
57#endif
58 Item createElementNode (Item &aParent, Item &aNodeName, Item &aTypeName, bool aHasTypedValue, bool aHasEmptyValue);
33 Item createFloat (const std::string &aValue);59 Item createFloat (const std::string &aValue);
34 Item createFloat (float aValue);60 Item createFloat (float aValue);
35 Item createGDay (const std::string &aValue);61 Item createGDay (const std::string &aValue);
@@ -51,6 +77,7 @@
51 Item createNegativeInteger (long long aValue);77 Item createNegativeInteger (long long aValue);
52 Item createNonNegativeInteger (unsigned long long aValue);78 Item createNonNegativeInteger (unsigned long long aValue);
53 Item createNonPositiveInteger (long long aValue);79 Item createNonPositiveInteger (long long aValue);
80 Item createPiNode (Item &aParent, const std::string &aTarget, const std::string &aContent, const std::string &aBaseUri);
54 Item createPositiveInteger (unsigned long long aValue);81 Item createPositiveInteger (unsigned long long aValue);
55 Item createQName (const std::string &aNamespace, const std::string &aPrefix, const std::string &aLocalname);82 Item createQName (const std::string &aNamespace, const std::string &aPrefix, const std::string &aLocalname);
56 Item createQName (const std::string &aNamespace, const std::string &aLocalname);83 Item createQName (const std::string &aNamespace, const std::string &aLocalname);
@@ -58,7 +85,7 @@
58 Item createShort (short aShort);85 Item createShort (short aShort);
59 //Item createStreamableString (std::istream &stream, StreamReleaser streamReleaser, bool seekable=false);86 //Item createStreamableString (std::istream &stream, StreamReleaser streamReleaser, bool seekable=false);
60 Item createString (const std::string &aString);87 Item createString (const std::string &aString);
61 Item createTextNode (Item parent, std::string content);88 Item createTextNode (Item &aParent, const std::string &aContent);
62 Item createTime (short aHour, short aMinute, double aSecond, short aTimeZone_hours);89 Item createTime (short aHour, short aMinute, double aSecond, short aTimeZone_hours);
63 Item createTime (short aHour, short aMinute, double aSecond);90 Item createTime (short aHour, short aMinute, double aSecond);
64 Item createTime (const std::string &aValue);91 Item createTime (const std::string &aValue);
@@ -67,3 +94,5 @@
67 Item createUnsignedLong (unsigned long long aValue);94 Item createUnsignedLong (unsigned long long aValue);
68 Item createUnsignedShort (unsigned short aValue);95 Item createUnsignedShort (unsigned short aValue);
69}; // class ItemFactory96}; // class ItemFactory
97
98#endif
70\ No newline at end of file99\ No newline at end of file
71100
=== modified file 'swig/ItemFactory.i'
--- swig/ItemFactory.i 2012-03-23 17:32:07 +0000
+++ swig/ItemFactory.i 2012-03-26 20:16:18 +0000
@@ -7,11 +7,12 @@
7 return Item(theItemFactory->createAnyURI(aURI));7 return Item(theItemFactory->createAnyURI(aURI));
8 }8 }
9 9
10 Item ItemFactory::createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, Item aTypedValue){10 Item ItemFactory::createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, Item& aTypedValue){
11 return Item( theItemFactory->createAttributeNode( aParent.theItem, aNodeName.theItem, aTypeName.theItem, aTypedValue.theItem ));11 return Item( theItemFactory->createAttributeNode( aParent.theItem, aNodeName.theItem, aTypeName.theItem, aTypedValue.theItem ));
12 }12 }
13 13
14 Item ItemFactory::createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, std::vector< Item > aTypedValue){14#ifndef SWIGRUBY
15 Item ItemFactory::createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, std::vector< Item > aTypedValue){
1516
16 std::vector< zorba::Item > typedValue;17 std::vector< zorba::Item > typedValue;
17 typedValue.reserve(aTypedValue.size());18 typedValue.reserve(aTypedValue.size());
@@ -21,6 +22,7 @@
21 }22 }
22 return Item( theItemFactory->createAttributeNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, typedValue ));23 return Item( theItemFactory->createAttributeNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, typedValue ));
23 }24 }
25#endif
24 26
25 Item ItemFactory::createBase64Binary (const char *aBinData, size_t aLength){27 Item ItemFactory::createBase64Binary (const char *aBinData, size_t aLength){
26 return Item( theItemFactory->createBase64Binary(aBinData, aLength));28 return Item( theItemFactory->createBase64Binary(aBinData, aLength));
@@ -37,6 +39,10 @@
37 Item ItemFactory::createByte (char aByte){39 Item ItemFactory::createByte (char aByte){
38 return Item( theItemFactory->createByte(aByte));40 return Item( theItemFactory->createByte(aByte));
39 }41 }
42 Item ItemFactory::createCommentNode (Item &aParent, const std::string &aContent){
43 zorba::String lContent = zorba::String(aContent);
44 return Item( theItemFactory->createCommentNode (aParent.theItem, lContent));
45 }
40 Item ItemFactory::createDate (const std::string &aDate){46 Item ItemFactory::createDate (const std::string &aDate){
41 return Item( theItemFactory->createDate(aDate));47 return Item( theItemFactory->createDate(aDate));
42 }48 }
@@ -70,11 +76,32 @@
70 Item ItemFactory::createDuration (short aYear, short aMonths, short aDays, short aHours, short aMinutes, double aSeconds){76 Item ItemFactory::createDuration (short aYear, short aMonths, short aDays, short aHours, short aMinutes, double aSeconds){
71 return Item( theItemFactory->createDuration (aYear, aMonths, aDays, aHours, aMinutes, aSeconds));77 return Item( theItemFactory->createDuration (aYear, aMonths, aDays, aHours, aMinutes, aSeconds));
72 }78 }
73 /*79 Item ItemFactory::createDayTimeDuration (const std::string &aValue){
74 Item ItemFactory::createElementNode (Item &aParent, Item aNodeName, Item aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings){80 return Item( theItemFactory->createDayTimeDuration (aValue));
75 return Item( theItemFactory->createElementNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, aHasTypedValue, aHasEmptyValue, aNsBindings));81 }
76 }82 Item ItemFactory::createYearMonthDuration (const std::string &aValue){
77 */83 return Item( theItemFactory->createYearMonthDuration (aValue));
84 }
85 Item ItemFactory::createDocumentNode (const std::string &aBaseUri, const std::string &aDocUri){
86 return Item( theItemFactory->createDocumentNode (aBaseUri, aDocUri));
87 }
88#ifndef SWIGRUBY
89 Item ItemFactory::createElementNode (Item &aParent, Item& aNodeName, Item& aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings){
90 std::vector< std::pair< zorba::String, zorba::String > > items;
91 items.reserve(aNsBindings.size());
92 std::vector< std::pair< std::string, std::string > >::iterator iter;
93 for(iter = aNsBindings.begin(); iter != aNsBindings.end(); iter++) {
94 std::pair< zorba::String, zorba::String > pair;
95 pair.first = (*iter).first;
96 pair.second = (*iter).second;
97 items.push_back(pair);
98 }
99 return Item( theItemFactory->createElementNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, aHasTypedValue, aHasEmptyValue, items));
100 }
101#endif
102 Item ItemFactory::createElementNode (Item &aParent, Item& aNodeName, Item& aTypeName, bool aHasTypedValue, bool aHasEmptyValue){
103 return Item( theItemFactory->createElementNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, aHasTypedValue, aHasEmptyValue, std::vector<std::pair<zorba::String, zorba::String> >()));
104 }
78 Item ItemFactory::createFloat (const std::string &aValue){105 Item ItemFactory::createFloat (const std::string &aValue){
79 return Item( theItemFactory->createFloat (aValue));106 return Item( theItemFactory->createFloat (aValue));
80 }107 }
@@ -138,6 +165,12 @@
138 Item ItemFactory::createNonPositiveInteger (long long aValue){165 Item ItemFactory::createNonPositiveInteger (long long aValue){
139 return Item( theItemFactory->createNonPositiveInteger (aValue));166 return Item( theItemFactory->createNonPositiveInteger (aValue));
140 }167 }
168 Item ItemFactory::createPiNode (Item &aParent, const std::string &aTarget, const std::string &aContent, const std::string &aBaseUri){
169 zorba::String lTarget = zorba::String(aTarget);
170 zorba::String lContent = zorba::String(aContent);
171 zorba::String lBaseUri = zorba::String(aBaseUri);
172 return Item( theItemFactory->createPiNode (aParent.theItem, lTarget, lContent, lBaseUri));
173 }
141 Item ItemFactory::createPositiveInteger (unsigned long long aValue){174 Item ItemFactory::createPositiveInteger (unsigned long long aValue){
142 return Item( theItemFactory->createPositiveInteger (aValue));175 return Item( theItemFactory->createPositiveInteger (aValue));
143 }176 }
@@ -161,8 +194,9 @@
161 Item ItemFactory::createString (const std::string &aString){194 Item ItemFactory::createString (const std::string &aString){
162 return Item( theItemFactory->createString (aString));195 return Item( theItemFactory->createString (aString));
163 }196 }
164 Item ItemFactory::createTextNode (Item parent, std::string content){197 Item ItemFactory::createTextNode (Item &aParent, const std::string &aContent){
165 return Item( theItemFactory->createTextNode (parent.theItem, content));198 zorba::String lContent = zorba::String(aContent);
199 return Item( theItemFactory->createTextNode (aParent.theItem, lContent));
166 }200 }
167 Item ItemFactory::createTime (short aHour, short aMinute, double aSecond, short aTimeZone_hours){201 Item ItemFactory::createTime (short aHour, short aMinute, double aSecond, short aTimeZone_hours){
168 return Item( theItemFactory->createTime (aHour, aMinute, aSecond, aTimeZone_hours));202 return Item( theItemFactory->createTime (aHour, aMinute, aSecond, aTimeZone_hours));
@@ -189,4 +223,4 @@
189223
190%} // end Implementation224%} // end Implementation
191225
192%include "ItemFactory.h"
193\ No newline at end of file226\ No newline at end of file
227%include "ItemFactory.h"
194228
=== added file 'swig/ItemSequence.h'
--- swig/ItemSequence.h 1970-01-01 00:00:00 +0000
+++ swig/ItemSequence.h 2012-03-26 20:16:18 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2006-2012 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef API_ITEM_SEQUENCE_H
17#define API_ITEM_SEQUENCE_H
18
19class ItemSequence
20{
21 friend class Collection;
22private:
23 zorba::ItemSequence_t theItemSequence;
24
25public:
26 ItemSequence(const ItemSequence& aItemSequence) : theItemSequence(aItemSequence.theItemSequence) {}
27 ItemSequence(zorba::ItemSequence_t aItemSequence) : theItemSequence(aItemSequence) {}
28 Iterator getIterator();
29
30};
31
32#endif
0\ No newline at end of file33\ No newline at end of file
134
=== added file 'swig/ItemSequence.i'
--- swig/ItemSequence.i 1970-01-01 00:00:00 +0000
+++ swig/ItemSequence.i 2012-03-26 20:16:18 +0000
@@ -0,0 +1,26 @@
1/*
2 * Copyright 2006-2012 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17%{ // start Implementation
18
19 Iterator ItemSequence::getIterator()
20 {
21 return Iterator( theItemSequence->getIterator() );
22 }
23
24%} // end Implementation
25
26%include "ItemSequence.h"
027
=== added file 'swig/Iterator.h'
--- swig/Iterator.h 1970-01-01 00:00:00 +0000
+++ swig/Iterator.h 2012-03-26 20:16:18 +0000
@@ -0,0 +1,57 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef API_ITERATOR_H
17#define API_ITERATOR_H
18
19class Iterator
20{
21protected:
22 friend class DynamicContext;
23 friend class DocumentManager;
24 friend class CollectionManager;
25 friend class Collection;
26 friend class StaticContext;
27 friend class XQuery;
28 friend class ItemSequence;
29 zorba::Iterator_t theIterator;
30 zorba::Item theItem;
31 bool theConsumed;
32public:
33 // constructors
34 Iterator() {}
35 Iterator(const Iterator& anIterator)
36 : theIterator(anIterator.theIterator),
37 theItem(anIterator.theItem),
38 theConsumed(false)
39 {}
40 Iterator(zorba::Iterator_t anIterator)
41 : theIterator(anIterator),
42 theConsumed(false)
43 {}
44 Iterator(zorba::Item& aItem)
45 : theIterator(0),
46 theItem(aItem),
47 theConsumed(false)
48 {}
49
50 void open();
51 bool isOpen();
52 bool next(Item&);
53 void close();
54 void destroy();
55}; // class Iterator
56
57#endif
0\ No newline at end of file58\ No newline at end of file
159
=== added file 'swig/Iterator.i'
--- swig/Iterator.i 1970-01-01 00:00:00 +0000
+++ swig/Iterator.i 2012-03-26 20:16:18 +0000
@@ -0,0 +1,69 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17%{ // start Implementation
18
19 void Iterator::open()
20 {
21 if (theIterator)
22 theIterator->open();
23 theConsumed = false;
24 }
25
26 bool Iterator::isOpen()
27 {
28 if (theIterator)
29 return theIterator->isOpen();
30 else
31 return !theConsumed;
32 }
33
34 void Iterator::close()
35 {
36 if (theIterator)
37 theIterator->close();
38 theConsumed = true;
39 }
40
41 void Iterator::destroy()
42 {
43 theIterator = 0;
44 }
45
46 bool Iterator::next(Item& aItem)
47 {
48 if (theIterator)
49 {
50 return theIterator->next(aItem.theItem);
51 }
52 else
53 {
54 if (!theConsumed)
55 {
56 aItem = theItem;
57 return true;
58 }
59 else
60 {
61 return false;
62 }
63 }
64 }
65
66
67%} // end Implementation
68
69%include "Iterator.h"
070
=== added file 'swig/SerializationOptions.h'
--- swig/SerializationOptions.h 1970-01-01 00:00:00 +0000
+++ swig/SerializationOptions.h 2012-03-26 20:16:18 +0000
@@ -0,0 +1,114 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef API_SERIALIZATION_OPTIONS_H
18#define API_SERIALIZATION_OPTIONS_H
19
20class SerializationOptions
21{
22friend class Item;
23
24public:
25 typedef enum
26 {
27 ZORBA_API_SERIALIZATION_METHOD_XML,
28 ZORBA_API_SERIALIZATION_METHOD_HTML,
29 ZORBA_API_SERIALIZATION_METHOD_XHTML,
30 ZORBA_API_SERIALIZATION_METHOD_TEXT,
31 ZORBA_API_SERIALIZATION_METHOD_BINARY
32 } SerializationMethod;
33
34 typedef enum
35 {
36 ZORBA_API_BYTE_ORDER_MARK_YES,
37 ZORBA_API_BYTE_ORDER_MARK_NO
38 } ByteOrderMark;
39
40
41 typedef enum
42 {
43 ZORBA_API_ESCAPE_URI_ATTRIBUTES_YES,
44 ZORBA_API_ESCAPE_URI_ATTRIBUTES_NO
45 } EscapeUriAttributes;
46
47 typedef enum {
48 ZORBA_API_INCLUDE_CONTENT_TYPE_YES,
49 ZORBA_API_INCLUDE_CONTENT_TYPE_NO
50 } IncludeContentType;
51
52 typedef enum {
53 ZORBA_API_INDENT_YES,
54 ZORBA_API_INDENT_NO
55 } Indent;
56
57 typedef enum {
58 ZORBA_API_NORMALIZATION_FORM_NFC,
59 ZORBA_API_NORMALIZATION_FORM_NFD,
60 ZORBA_API_NORMALIZATION_FORM_NFKC,
61 ZORBA_API_NORMALIZATION_FORM_NFKD,
62 ZORBA_API_NORMALIZATION_FORM_FULLY_normalized,
63 ZORBA_API_NORMALIZATION_FORM_NONE
64 } NormalizationForm;
65
66 typedef enum {
67 ZORBA_API_OMIT_XML_DECLARATION_YES,
68 ZORBA_API_OMIT_XML_DECLARATION_NO
69 } OmitXMLDeclaration;
70
71 typedef enum {
72 ZORBA_API_STANDALONE_YES,
73 ZORBA_API_STANDALONE_NO,
74 ZORBA_API_STANDALONE_OMIT
75 } Standalone;
76
77 typedef enum {
78 ZORBA_API_UNDECLARE_PREFIXES_YES,
79 ZORBA_API_UNDECLARE_PREFIXES_NO
80 } UndeclarePrefixes;
81
82
83private:
84 Zorba_SerializerOptions_t lOptions;
85
86public:
87 /*
88 * Default values:
89 * - serialization method: XML
90 * - byte order mark: NO
91 * - esacpe uri attributes: NO
92 * - include content type: NO
93 * - indent: NO
94 * - normalization form: none
95 * - omit xml declaration: NO
96 * - standalone: omit
97 * - undeclare prefixes: NO
98 */
99
100
101 void setSerializationMethod ( SerializationMethod aSerializationMethod );
102 void setByteOrderMark ( ByteOrderMark aByteOrderMark );
103 void setEscapeUriAttributes ( EscapeUriAttributes aEscapeUriAttributes );
104 void setIncludeContentType ( IncludeContentType aIncludeContentType );
105 void setIndent ( Indent aIndent );
106 void setNormalizationForm ( NormalizationForm aNormalizationForm );
107 void setOmitXMLDeclaration ( OmitXMLDeclaration aOmitXMLDeclaration );
108 void setStandalone ( Standalone aStandalone );
109 void setUndeclarePrefixes ( UndeclarePrefixes aUndeclarePrefixes );
110 void setSerializerOption(const std::string &parameter, const std::string &value);
111
112}; // class SerializationOptions
113
114#endif
0115
=== added file 'swig/SerializationOptions.i'
--- swig/SerializationOptions.i 1970-01-01 00:00:00 +0000
+++ swig/SerializationOptions.i 2012-03-26 20:16:18 +0000
@@ -0,0 +1,125 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17%{ // start Implementation
18
19 void SerializationOptions::setSerializationMethod ( SerializationMethod aSerializationMethod ) {
20 switch (aSerializationMethod) {
21 case ZORBA_API_SERIALIZATION_METHOD_HTML:
22 lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_HTML;
23 break;
24 case ZORBA_API_SERIALIZATION_METHOD_XHTML:
25 lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_XHTML;
26 break;
27 case ZORBA_API_SERIALIZATION_METHOD_TEXT:
28 lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_TEXT;
29 break;
30 case ZORBA_API_SERIALIZATION_METHOD_BINARY:
31 lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_BINARY;
32 break;
33 case ZORBA_API_SERIALIZATION_METHOD_XML:
34 default:
35 lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_XML;
36 break;
37 }
38 }
39 void SerializationOptions::setByteOrderMark ( ByteOrderMark aByteOrderMark ) {
40 if (aByteOrderMark == ZORBA_API_BYTE_ORDER_MARK_YES) {
41 lOptions.byte_order_mark = ZORBA_BYTE_ORDER_MARK_YES;
42 } else {
43 lOptions.byte_order_mark = ZORBA_BYTE_ORDER_MARK_NO;
44 }
45 }
46 void SerializationOptions::setEscapeUriAttributes ( EscapeUriAttributes aEscapeUriAttributes ) {
47 if (aEscapeUriAttributes == ZORBA_API_ESCAPE_URI_ATTRIBUTES_YES) {
48 lOptions.escape_uri_attributes = ZORBA_ESCAPE_URI_ATTRIBUTES_YES;
49 } else {
50 lOptions.escape_uri_attributes = ZORBA_ESCAPE_URI_ATTRIBUTES_NO;
51 }
52 }
53 void SerializationOptions::setIncludeContentType ( IncludeContentType aIncludeContentType ) {
54 if (aIncludeContentType == ZORBA_API_INCLUDE_CONTENT_TYPE_YES) {
55 lOptions.include_content_type = ZORBA_INCLUDE_CONTENT_TYPE_YES;
56 } else {
57 lOptions.include_content_type = ZORBA_INCLUDE_CONTENT_TYPE_NO;
58 }
59 }
60 void SerializationOptions::setIndent ( Indent aIndent ) {
61 if (aIndent == ZORBA_API_INDENT_YES) {
62 lOptions.indent = ZORBA_INDENT_YES;
63 } else {
64 lOptions.indent = ZORBA_INDENT_NO;
65 }
66 }
67 void SerializationOptions::setNormalizationForm ( NormalizationForm aNormalizationForm ) {
68 switch (aNormalizationForm) {
69 case ZORBA_API_NORMALIZATION_FORM_NFC:
70 lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NFC;
71 break;
72 case ZORBA_API_NORMALIZATION_FORM_NFD:
73 lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NFD;
74 break;
75 case ZORBA_API_NORMALIZATION_FORM_NFKC:
76 lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NFKC;
77 break;
78 case ZORBA_API_NORMALIZATION_FORM_NFKD:
79 lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NFKD;
80 break;
81 case ZORBA_API_NORMALIZATION_FORM_FULLY_normalized:
82 lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_FULLY_normalized;
83 break;
84 case ZORBA_API_NORMALIZATION_FORM_NONE:
85 default:
86 lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NONE;
87 break;
88 }
89 }
90 void SerializationOptions::setOmitXMLDeclaration ( OmitXMLDeclaration aOmitXMLDeclaration ) {
91 if (aOmitXMLDeclaration == ZORBA_API_OMIT_XML_DECLARATION_YES) {
92 lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
93 } else {
94 lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_NO;
95 }
96 }
97 void SerializationOptions::setStandalone ( Standalone aStandalone ) {
98 switch (aStandalone) {
99 case ZORBA_API_STANDALONE_YES:
100 lOptions.standalone = ZORBA_STANDALONE_YES;
101 break;
102 case ZORBA_API_STANDALONE_NO:
103 lOptions.standalone = ZORBA_STANDALONE_NO;
104 break;
105 case ZORBA_API_STANDALONE_OMIT:
106 default:
107 lOptions.standalone = ZORBA_STANDALONE_OMIT;
108 break;
109 }
110 }
111 void SerializationOptions::setUndeclarePrefixes ( UndeclarePrefixes aUndeclarePrefixes ) {
112 if (aUndeclarePrefixes == ZORBA_API_UNDECLARE_PREFIXES_YES) {
113 lOptions.undeclare_prefixes = ZORBA_UNDECLARE_PREFIXES_YES;
114 } else {
115 lOptions.undeclare_prefixes = ZORBA_UNDECLARE_PREFIXES_NO;
116 }
117 }
118
119 void SerializationOptions::setSerializerOption(const std::string &parameter, const std::string &value) {
120 lOptions.SetSerializerOption(parameter.c_str(), value.c_str());
121 }
122
123%} // end Implementation
124
125%include "SerializationOptions.h"
0126
=== modified file 'swig/StaticContext.h'
--- swig/StaticContext.h 2012-03-23 17:32:07 +0000
+++ swig/StaticContext.h 2012-03-26 20:16:18 +0000
@@ -1,5 +1,69 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef API_STATIC_CONTEXT_H
17#define API_STATIC_CONTEXT_H
18
1#include <zorba/static_context_consts.h>19#include <zorba/static_context_consts.h>
220
21class ZorbaConstants
22{
23public:
24 typedef enum {
25 PRESERVE,
26 NO_PRESERVE
27 } PreserveMode;
28
29 typedef enum {
30 INHERIT,
31 NO_INHERIT
32 } InheritMode;
33
34 typedef enum {
35 PRESERVE_SPACE,
36 STRIP_SPACE
37 } BoundarySpaceMode;
38
39 typedef enum {
40 PRESERVE_CONSTRUCTION,
41 STRIP_CONSTRUCTION
42 } ConstructionMode;
43
44 typedef enum {
45 EMPTY_GREATEST,
46 EMPTY_LEAST
47 } OrderEmptyMode;
48
49 typedef enum {
50 ORDERED,
51 UNORDERED
52 } OrderingMode;
53
54 typedef enum {
55 VALIDATE_SKIP,
56 VALIDATE_LAX,
57 VALIDATE_STRICT
58 } RevalidationMode;
59
60 typedef enum {
61 XPATH2_0,
62 XPATH1_0
63 } XPath1_0CompatibleMode;
64
65}; // ZorbaConstants
66
3class StaticContext 67class StaticContext
4{68{
5friend class Zorba;69friend class Zorba;
@@ -8,62 +72,73 @@
8private:72private:
9 zorba::StaticContext_t theStaticContext;73 zorba::StaticContext_t theStaticContext;
10public:74public:
11 StaticContext();75
12 StaticContext(const StaticContext& aStaticContext);76 StaticContext(const StaticContext& aStaticContext);
13 StaticContext(zorba::StaticContext_t aStaticContext);77 StaticContext(zorba::StaticContext_t aStaticContext);
14 78
15 virtual void addColation(const std::string& aURI); 79 void addColation(const std::string& aURI);
16 virtual bool addNamespace(const std::string& aPrefix,80 bool addNamespace(const std::string& aPrefix,
17 const std::string& aURI);81 const std::string& aURI);
18 void addReference() const;82
19 virtual bool containsFunction(const std::string &aFnNameUri, 83 bool containsFunction(const std::string &aFnNameUri,
20 const std::string &aFnNameLocal, 84 const std::string &aFnNameLocal,
21 int arity) const;85 int arity) const;
2286
23 virtual StaticContext createChildContext() const;87 StaticContext createChildContext() const;
24 virtual void declareOption(const Item &aQName, 88 void declareOption(const Item &aQName,
25 const std::string &aOptionVal);89 const std::string &aOptionVal);
26 virtual void disableFunction(const Item &aQName, int arity);90 void disableFunction(const Item &aQName, int arity);
2791
28 virtual void free ();92 std::string getBaseURI () const;
29 virtual std::string getBaseURI () const;93
30 virtual zorba::boundary_space_mode_t getBoundarySpacePolicy () const;94 ZorbaConstants::BoundarySpaceMode getBoundarySpacePolicy ();
3195 ZorbaConstants::ConstructionMode getConstructionMode();
32 virtual zorba::construction_mode_t getConstructionMode () const;96 ZorbaConstants::PreserveMode getCopyNamespacesModePreserve();
33 virtual void getCopyNamespacesMode (zorba::preserve_mode_t &aPreserve, zorba::inherit_mode_t &aInherit) const;97 ZorbaConstants::InheritMode getCopyNamespacesModeInherit();
34 virtual std::string getDefaultCollation () const;98 ZorbaConstants::OrderEmptyMode getDefaultOrderForEmptySequences();
35 virtual std::string getDefaultElementAndTypeNamespace () const;99 ZorbaConstants::OrderingMode getOrderingMode();
36 virtual std::string getDefaultFunctionNamespace () const;100 ZorbaConstants::RevalidationMode getRevalidationMode();
37 virtual zorba::order_empty_mode_t getDefaultOrderForEmptySequences () const;101 ZorbaConstants::XPath1_0CompatibleMode getXPath1_0CompatibMode();
38102
39 virtual std::string getNamespaceURIByPrefix(const std::string &aPrefix) const;103 std::string getDefaultCollation () const;
40 virtual bool getOption(const Item &aQName, std::string &aOptionValue) const;104 std::string getDefaultElementAndTypeNamespace () const;
41 virtual zorba::ordering_mode_t getOrderingMode() const;105 std::string getDefaultFunctionNamespace () const;
42 long getRefCount() const;106
43 virtual zorba::validation_mode_t getRevalidationMode();107 std::vector< std::pair< std::string, std::string > > getNamespaceBindings ();
44 virtual zorba::xpath1_0compatib_mode_t getXPath1_0CompatibMode () const;108
45 virtual void loadProlog (const std::string & aProlog, 109 std::string getNamespaceURIByPrefix(const std::string &aPrefix) const;
46 const CompilerHints &hints);110 bool getOption(const Item &aQName, std::string &aOptionValue) const;
47111 void loadProlog (const std::string & aProlog, const CompilerHints &hints);
48 void removeReference ();112
49 virtual void resetTraceStream ();113 void getExternalVariables(Iterator& vars) const;
50 virtual bool setBaseURI (const std::string &aBaseURI);114
51 virtual bool setBoundarySpacePolicy (zorba::boundary_space_mode_t aMode);115 TypeIdentifier getCollectionType(const std::string &aCollectionUri);
52116 TypeIdentifier getDocumentType(const std::string &aDocUri);
53 virtual bool setConstructionMode (zorba::construction_mode_t aMode);117 TypeIdentifier getContextItemStaticType();
54118
55 virtual bool setCopyNamespacesMode (zorba::preserve_mode_t aPreserve, 119 void setContextItemStaticType(const TypeIdentifier &aType);
56 zorba::inherit_mode_t aInherit);120
57 virtual void setDefaultCollation (const std::string &aURI);121 void resetTraceStream ();
58 virtual bool setDefaultElementAndTypeNamespace (const std::string &aURI);122 bool setBaseURI (const std::string &aBaseURI);
59 virtual bool setDefaultFunctionNamespace (const std::string &aURI);123
60 virtual bool setDefaultOrderForEmptySequences (zorba::order_empty_mode_t aMode);124 bool setBoundarySpacePolicy (ZorbaConstants::BoundarySpaceMode aMode);
61125 bool setConstructionMode (ZorbaConstants::ConstructionMode aMode);
62 virtual bool setOrderingMode (zorba::ordering_mode_t aMode);126 bool setCopyNamespacesMode (ZorbaConstants::PreserveMode aPreserve, ZorbaConstants::InheritMode aInherit);
63 virtual void setRevalidationMode (zorba::validation_mode_t aMode);127 bool setDefaultOrderForEmptySequences (ZorbaConstants::OrderEmptyMode aMode);
64128 bool setOrderingMode (ZorbaConstants::OrderingMode aMode);
65 virtual bool setXPath1_0CompatibMode (zorba::xpath1_0compatib_mode_t aMode);129 void setRevalidationMode (ZorbaConstants::RevalidationMode aMode);
130
131 void setURIPath(std::vector< std::string > &aURIPath );
132 void setLIBPath(std::vector< std::string > &aLIBPath );
133 void setModulePath(std::vector< std::string > &aModulePath );
134
135 bool setXPath1_0CompatibMode (ZorbaConstants::XPath1_0CompatibleMode aMode);
136
137 void setDefaultCollation (const std::string &aURI);
138 bool setDefaultElementAndTypeNamespace (const std::string &aURI);
139 bool setDefaultFunctionNamespace (const std::string &aURI);
66140
67 void destroy();141 void destroy();
68}; // class StaticContext142}; // class StaticContext
69143
144#endif
70\ No newline at end of file145\ No newline at end of file
71146
=== modified file 'swig/StaticContext.i'
--- swig/StaticContext.i 2012-03-23 17:32:07 +0000
+++ swig/StaticContext.i 2012-03-26 20:16:18 +0000
@@ -20,8 +20,6 @@
20#include <zorba/static_context_consts.h>20#include <zorba/static_context_consts.h>
2121
2222
23StaticContext::StaticContext() {}
24
25StaticContext::StaticContext(const StaticContext& aStaticContext) : 23StaticContext::StaticContext(const StaticContext& aStaticContext) :
26 theStaticContext(aStaticContext.theStaticContext) {}24 theStaticContext(aStaticContext.theStaticContext) {}
27 25
@@ -31,65 +29,94 @@
31void StaticContext::addColation(const std::string& aURI)29void StaticContext::addColation(const std::string& aURI)
32 { theStaticContext->addCollation(aURI); }30 { theStaticContext->addCollation(aURI); }
3331
34bool StaticContext::addNamespace(const std::string& aPrefix, 32bool StaticContext::addNamespace(const std::string& aPrefix, const std::string& aURI)
35 const std::string& aURI)
36 { return theStaticContext->addNamespace(aPrefix, aURI); }33 { return theStaticContext->addNamespace(aPrefix, aURI); }
3734
38void StaticContext::addReference() const35bool StaticContext::containsFunction(const std::string &aFnNameUri, const std::string &aFnNameLocal, int arity) const
39 { theStaticContext->addReference(); }36 { return theStaticContext->containsFunction(aFnNameUri, aFnNameLocal, arity); }
40
41bool StaticContext::containsFunction(const std::string &aFnNameUri,
42 const std::string &aFnNameLocal,
43 int arity) const
44 { return theStaticContext->containsFunction(aFnNameUri, aFnNameLocal,
45 arity); }
4637
47StaticContext StaticContext::createChildContext() const38StaticContext StaticContext::createChildContext() const
48 { return StaticContext(theStaticContext->createChildContext()); }39 { return StaticContext(theStaticContext->createChildContext()); }
49 40
50void StaticContext::declareOption (const Item &aQName, 41void StaticContext::declareOption (const Item &aQName, const std::string &aOptionVal)
51 const std::string &aOptionVal)
52 { return theStaticContext->declareOption(aQName.theItem, aOptionVal); }42 { return theStaticContext->declareOption(aQName.theItem, aOptionVal); }
5343
54void StaticContext::disableFunction (const Item &aQName, int arity)44void StaticContext::disableFunction (const Item &aQName, int arity)
55 { theStaticContext->disableFunction( aQName.theItem, arity); }45 { theStaticContext->disableFunction( aQName.theItem, arity); }
5646
57void StaticContext::free ()
58 { theStaticContext->free(); }
59
60std::string StaticContext::getBaseURI () const47std::string StaticContext::getBaseURI () const
61 { return std::string(theStaticContext->getBaseURI().c_str()); }48 { return std::string(theStaticContext->getBaseURI().c_str()); }
6249
63zorba::boundary_space_mode_t StaticContext::getBoundarySpacePolicy() const50ZorbaConstants::BoundarySpaceMode StaticContext::getBoundarySpacePolicy()
64 { return theStaticContext->getBoundarySpacePolicy(); }51 {
6552 ZorbaConstants::BoundarySpaceMode result = ZorbaConstants::PRESERVE_SPACE;
66zorba::construction_mode_t StaticContext::getConstructionMode () const 53 zorba::boundary_space_mode_t boundary = theStaticContext->getBoundarySpacePolicy();
67 { return theStaticContext->getConstructionMode(); } 54 if (boundary == zorba::strip_space) {
6855 result = ZorbaConstants::STRIP_SPACE;
69void StaticContext::getCopyNamespacesMode (zorba::preserve_mode_t &aPreserve, zorba::inherit_mode_t &aInherit) const56 }
70 { return theStaticContext->getCopyNamespacesMode(aPreserve, aInherit); } 57 return result;
58 }
59
60ZorbaConstants::ConstructionMode StaticContext::getConstructionMode()
61 {
62 ZorbaConstants::ConstructionMode result = ZorbaConstants::STRIP_CONSTRUCTION;
63 zorba::construction_mode_t construction = theStaticContext->getConstructionMode();
64 if (construction == zorba::preserve_cons) {
65 result = ZorbaConstants::PRESERVE_CONSTRUCTION;
66 }
67 return result;
68 }
69
70ZorbaConstants::PreserveMode StaticContext::getCopyNamespacesModePreserve()
71 {
72 zorba::preserve_mode_t lPreserve;
73 zorba::inherit_mode_t lInherit;
74 ZorbaConstants::PreserveMode aPreserve = ZorbaConstants::NO_PRESERVE;
75 theStaticContext->getCopyNamespacesMode(lPreserve, lInherit);
76 if (lPreserve==zorba::preserve_ns) {
77 aPreserve = ZorbaConstants::PRESERVE;
78 }
79 return aPreserve;
80 }
81
82ZorbaConstants::InheritMode StaticContext::getCopyNamespacesModeInherit()
83 {
84 zorba::preserve_mode_t lPreserve;
85 zorba::inherit_mode_t lInherit;
86 ZorbaConstants::InheritMode aInherit = ZorbaConstants::NO_INHERIT;
87 theStaticContext->getCopyNamespacesMode(lPreserve, lInherit);
88 if (lInherit==zorba::inherit_ns) {
89 aInherit = ZorbaConstants::INHERIT;
90 }
91 return aInherit;
92 }
7193
72std::string StaticContext::getDefaultCollation () const 94std::string StaticContext::getDefaultCollation () const
73 { return std::string(theStaticContext->getDefaultCollation().c_str()); }95 { return std::string(theStaticContext->getDefaultCollation().c_str()); }
7496
75std::string StaticContext::getDefaultElementAndTypeNamespace () const 97std::string StaticContext::getDefaultElementAndTypeNamespace () const
76 { 98 {
77 return std::string(theStaticContext->getDefaultElementAndTypeNamespace().99 return std::string( theStaticContext->getDefaultElementAndTypeNamespace().c_str() );
78 c_str());
79 }100 }
80101
81std::string StaticContext::getDefaultFunctionNamespace () const 102std::string StaticContext::getDefaultFunctionNamespace () const
82 { 103 {
83 return std::string(theStaticContext->getDefaultFunctionNamespace().c_str());104 return std::string( theStaticContext->getDefaultFunctionNamespace().c_str() );
84 }105 }
85106
86zorba::order_empty_mode_t StaticContext::getDefaultOrderForEmptySequences() const107ZorbaConstants::OrderEmptyMode StaticContext::getDefaultOrderForEmptySequences()
87 { return theStaticContext->getDefaultOrderForEmptySequences(); }108 {
109 ZorbaConstants::OrderEmptyMode result = ZorbaConstants::EMPTY_GREATEST;
110 zorba::order_empty_mode_t order = theStaticContext->getDefaultOrderForEmptySequences();
111 if (order == zorba::empty_least) {
112 result = ZorbaConstants::EMPTY_LEAST;
113 }
114 return result;
115 }
88116
89std::string StaticContext::getNamespaceURIByPrefix(const std::string &aPrefix) const117std::string StaticContext::getNamespaceURIByPrefix(const std::string &aPrefix) const
90 {118 {
91 return std::string(theStaticContext->getNamespaceURIByPrefix(aPrefix).119 return std::string( theStaticContext->getNamespaceURIByPrefix(aPrefix).c_str() );
92 c_str());
93 }120 }
94121
95bool StaticContext::getOption(const Item &aQName, std::string &aOptionValue) const122bool StaticContext::getOption(const Item &aQName, std::string &aOptionValue) const
@@ -98,40 +125,108 @@
98 return theStaticContext->getOption(aQName.theItem, optVal); 125 return theStaticContext->getOption(aQName.theItem, optVal);
99 }126 }
100127
101zorba::ordering_mode_t StaticContext::getOrderingMode () const128ZorbaConstants::OrderingMode StaticContext::getOrderingMode ()
102 { return theStaticContext->getOrderingMode(); }129 {
103130 ZorbaConstants::OrderingMode result = ZorbaConstants::ORDERED;
104long StaticContext::getRefCount () const131 zorba::ordering_mode_t order = theStaticContext->getOrderingMode();
105 { return theStaticContext->getRefCount(); }132 if (order == zorba::unordered) {
106133 result = ZorbaConstants::UNORDERED;
107zorba::validation_mode_t StaticContext::getRevalidationMode ()134 }
108 { return theStaticContext->getRevalidationMode(); }135 return result;
109136 }
110zorba::xpath1_0compatib_mode_t StaticContext::getXPath1_0CompatibMode () const137
111 { return theStaticContext->getXPath1_0CompatibMode(); } 138ZorbaConstants::RevalidationMode StaticContext::getRevalidationMode ()
112139 {
113void StaticContext::loadProlog (const std::string & aProlog, 140 ZorbaConstants::RevalidationMode result = ZorbaConstants::VALIDATE_SKIP;
114 const CompilerHints &hints)141 zorba::validation_mode_t revalidation = theStaticContext->getRevalidationMode();
142 if (revalidation == zorba::validate_lax) {
143 result = ZorbaConstants::VALIDATE_LAX;
144 } else if (revalidation == zorba::validate_strict) {
145 result = ZorbaConstants::VALIDATE_STRICT;
146 }
147 return result;
148 }
149
150ZorbaConstants::XPath1_0CompatibleMode StaticContext::getXPath1_0CompatibMode ()
151 {
152 ZorbaConstants::XPath1_0CompatibleMode result = ZorbaConstants::XPATH2_0;
153 zorba::xpath1_0compatib_mode_t comp = theStaticContext->getXPath1_0CompatibMode();
154 if (comp == zorba::xpath1_0) {
155 result = ZorbaConstants::XPATH1_0;
156 }
157 return result;
158 }
159
160void StaticContext::loadProlog (const std::string & aProlog, const CompilerHints &hints)
115 { theStaticContext->loadProlog( aProlog, hints.theCompilerHints); }161 { theStaticContext->loadProlog( aProlog, hints.theCompilerHints); }
116162
117void StaticContext::removeReference ()163void StaticContext::getExternalVariables(Iterator& vars) const
118 { theStaticContext->removeReference(); }164 { theStaticContext->getExternalVariables( vars.theIterator ); }
119165
166TypeIdentifier StaticContext::getCollectionType(const std::string & aCollectionUri)
167 { return TypeIdentifier(theStaticContext->getCollectionType(aCollectionUri)); }
168
169TypeIdentifier StaticContext::getDocumentType(const std::string &aDocUri)
170 { return TypeIdentifier(theStaticContext->getDocumentType(aDocUri)); }
171
172TypeIdentifier StaticContext::getContextItemStaticType()
173 { return TypeIdentifier(theStaticContext->getContextItemStaticType()); }
174
175std::vector< std::pair< std::string, std::string > > StaticContext::getNamespaceBindings () {
176 std::vector< std::pair< zorba::String, zorba::String > > items;
177 std::vector< std::pair< std::string, std::string > > result;
178 theStaticContext->getNamespaceBindings(items);
179 std::vector< std::pair< zorba::String, zorba::String > >::iterator iter;
180 for(iter = items.begin(); iter != items.end(); iter++) {
181 std::pair< std::string, std::string > pair;
182 pair.first = (*iter).first.c_str();
183 pair.second = (*iter).second.c_str();
184 result.push_back(pair);
185 }
186 return result;
187}
188
189
190
191void StaticContext::setContextItemStaticType(const TypeIdentifier &aType)
192 { theStaticContext->setContextItemStaticType(aType.theTypeIdentifier); }
193
120void StaticContext::resetTraceStream ()194void StaticContext::resetTraceStream ()
121 { theStaticContext->resetTraceStream(); }195 { theStaticContext->resetTraceStream(); }
122196
123bool StaticContext::setBaseURI (const std::string &aBaseURI)197bool StaticContext::setBaseURI (const std::string &aBaseURI)
124 { return theStaticContext->setBaseURI(aBaseURI); }198 { return theStaticContext->setBaseURI(aBaseURI); }
125199
126bool StaticContext::setBoundarySpacePolicy (zorba::boundary_space_mode_t aMode)200bool StaticContext::setBoundarySpacePolicy (ZorbaConstants::BoundarySpaceMode aMode)
127 { return theStaticContext->setBoundarySpacePolicy(aMode); } 201 {
128202 zorba::boundary_space_mode_t lMode = zorba::strip_space;
129bool StaticContext::setConstructionMode (zorba::construction_mode_t aMode)203 if (aMode == ZorbaConstants::PRESERVE_SPACE) {
130 { return theStaticContext->setConstructionMode(aMode); } 204 lMode = zorba::preserve_space;
131205 }
132bool StaticContext::setCopyNamespacesMode (zorba::preserve_mode_t aPreserve, 206 return theStaticContext->setBoundarySpacePolicy(lMode);
133 zorba::inherit_mode_t aInherit)207 }
134 { return theStaticContext->setCopyNamespacesMode(aPreserve, aInherit); } 208
209bool StaticContext::setConstructionMode (ZorbaConstants::ConstructionMode aMode)
210 {
211 zorba::construction_mode_t lMode = zorba::preserve_cons;
212 if (aMode == ZorbaConstants::STRIP_CONSTRUCTION) {
213 lMode = zorba::strip_cons;
214 }
215 return theStaticContext->setConstructionMode(lMode);
216 }
217
218bool StaticContext::setCopyNamespacesMode (ZorbaConstants::PreserveMode aPreserve, ZorbaConstants::InheritMode aInherit)
219 {
220 zorba::preserve_mode_t lPreserve = zorba::no_preserve_ns;
221 zorba::inherit_mode_t lInherit = zorba::no_inherit_ns;
222 if (aPreserve == ZorbaConstants::PRESERVE) {
223 lPreserve = zorba::preserve_ns;
224 }
225 if (aInherit == ZorbaConstants::INHERIT) {
226 lInherit = zorba::inherit_ns;
227 }
228 return theStaticContext->setCopyNamespacesMode(lPreserve, lInherit);
229 }
135230
136void StaticContext::setDefaultCollation (const std::string &aURI)231void StaticContext::setDefaultCollation (const std::string &aURI)
137 { theStaticContext->setDefaultCollation(aURI); }232 { theStaticContext->setDefaultCollation(aURI); }
@@ -142,17 +237,76 @@
142bool StaticContext::setDefaultFunctionNamespace (const std::string &aURI)237bool StaticContext::setDefaultFunctionNamespace (const std::string &aURI)
143 { return theStaticContext->setDefaultFunctionNamespace(aURI); }238 { return theStaticContext->setDefaultFunctionNamespace(aURI); }
144239
145bool StaticContext::setDefaultOrderForEmptySequences (zorba::order_empty_mode_t aMode)240bool StaticContext::setDefaultOrderForEmptySequences (ZorbaConstants::OrderEmptyMode aMode)
146 { return theStaticContext->setDefaultOrderForEmptySequences(aMode); } 241 {
147242 zorba::order_empty_mode_t lMode = zorba::empty_greatest;
148bool StaticContext::setOrderingMode (zorba::ordering_mode_t aMode)243 if (aMode == ZorbaConstants::EMPTY_LEAST) {
149 { return theStaticContext->setOrderingMode(aMode); } 244 lMode = zorba::empty_least;
150245 }
151void StaticContext::setRevalidationMode (zorba::validation_mode_t aMode)246 return theStaticContext->setDefaultOrderForEmptySequences(lMode);
152 { return theStaticContext->setRevalidationMode(aMode); } 247 }
153248
154bool StaticContext::setXPath1_0CompatibMode (zorba::xpath1_0compatib_mode_t aMode)249bool StaticContext::setOrderingMode (ZorbaConstants::OrderingMode aMode)
155 { return theStaticContext->setXPath1_0CompatibMode(aMode); }250 {
251 zorba::ordering_mode_t lMode = zorba::ordered;
252 if (aMode == ZorbaConstants::UNORDERED) {
253 lMode = zorba::unordered;
254 }
255 return theStaticContext->setOrderingMode(lMode);
256 }
257
258void StaticContext::setRevalidationMode (ZorbaConstants::RevalidationMode aMode)
259 {
260 zorba::validation_mode_t lMode = zorba::validate_skip;
261 if (aMode == ZorbaConstants::VALIDATE_LAX) {
262 lMode = zorba::validate_lax;
263 } else if (aMode == ZorbaConstants::VALIDATE_STRICT) {
264 lMode = zorba::validate_strict;
265 }
266 return theStaticContext->setRevalidationMode(lMode);
267 }
268
269void StaticContext::setURIPath(std::vector< std::string > &aURIPath )
270 {
271 std::vector< zorba::String > lURIPath;
272 lURIPath.reserve(aURIPath.size());
273 std::vector< std::string >::iterator iter;
274 for(iter = aURIPath.begin(); iter != aURIPath.end(); iter++) {
275 lURIPath.push_back((*iter));
276 }
277 theStaticContext->setURIPath(lURIPath);
278 }
279
280void StaticContext::setLIBPath(std::vector< std::string > &aLIBPath )
281 {
282 std::vector< zorba::String > lLIBPath;
283 lLIBPath.reserve(aLIBPath.size());
284 std::vector< std::string >::iterator iter;
285 for(iter = aLIBPath.begin(); iter != aLIBPath.end(); iter++) {
286 lLIBPath.push_back((*iter));
287 }
288 theStaticContext->setLibPath(lLIBPath);
289 }
290
291void StaticContext::setModulePath(std::vector< std::string > &aModulePath )
292 {
293 std::vector< zorba::String > lModulePath;
294 lModulePath.reserve(aModulePath.size());
295 std::vector< std::string >::iterator iter;
296 for(iter = aModulePath.begin(); iter != aModulePath.end(); iter++) {
297 lModulePath.push_back((*iter));
298 }
299 theStaticContext->setModulePaths(lModulePath);
300 }
301
302bool StaticContext::setXPath1_0CompatibMode (ZorbaConstants::XPath1_0CompatibleMode aMode)
303 {
304 zorba::xpath1_0compatib_mode_t lMode = zorba::xpath2_0;
305 if (aMode == ZorbaConstants::XPATH1_0) {
306 lMode = zorba::xpath1_0;
307 }
308 return theStaticContext->setXPath1_0CompatibMode(lMode);
309 }
156310
157void StaticContext::destroy() 311void StaticContext::destroy()
158 { theStaticContext = 0; }312 { theStaticContext = 0; }
@@ -165,7 +319,7 @@
165%} // end Implementation319%} // end Implementation
166320
167321
168 // Interface322// Interface
169323
170%rename(XPath1_0CompatibModeEnum) zorba::xpath1_0compatib_mode_t;324%rename(XPath1_0CompatibModeEnum) zorba::xpath1_0compatib_mode_t;
171%rename(XPATH2_0) xpath2_0;325%rename(XPATH2_0) xpath2_0;
172326
=== modified file 'swig/Store.i'
--- swig/Store.i 2012-03-23 17:32:07 +0000
+++ swig/Store.i 2012-03-26 20:16:18 +0000
@@ -15,6 +15,8 @@
15 */15 */
1616
17%{ // start Implementation17%{ // start Implementation
18
19#include <zorba/store_consts.h>
18 20
19class Store 21class Store
20{22{
2123
=== added file 'swig/TypeIdentifier.h'
--- swig/TypeIdentifier.h 1970-01-01 00:00:00 +0000
+++ swig/TypeIdentifier.h 2012-03-26 20:16:18 +0000
@@ -0,0 +1,97 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef API_TYPE_IDENTIFIER_H
18#define API_TYPE_IDENTIFIER_H
19
20class IdentTypes {
21public:
22 typedef enum {
23 NAMED_TYPE,
24 ELEMENT_TYPE,
25 ATTRIBUTE_TYPE,
26 DOCUMENT_TYPE,
27 PI_TYPE,
28 TEXT_TYPE,
29 COMMENT_TYPE,
30 ANY_NODE_TYPE,
31 ITEM_TYPE,
32 EMPTY_TYPE,
33 INVALID_TYPE,
34 } Kind;
35
36 typedef enum {
37 QUANT_ONE,
38 QUANT_QUESTION,
39 QUANT_PLUS,
40 QUANT_STAR,
41 } Quantifier;
42};
43
44class TypeIdentifier
45{
46 friend class StaticContext;
47private:
48 zorba::TypeIdentifier_t theTypeIdentifier;
49 static zorba::IdentTypes::quantifier_t convertQuantifier(IdentTypes::Quantifier quantifier);
50
51public:
52 TypeIdentifier (const TypeIdentifier& aTypeIdentifier) : theTypeIdentifier(aTypeIdentifier.theTypeIdentifier) {}
53 TypeIdentifier (const zorba::TypeIdentifier_t& aZTypeIdentifier) : theTypeIdentifier(aZTypeIdentifier) {}
54
55 TypeIdentifier getContentType();
56 IdentTypes::Kind getKind();
57 const std::string getLocalName();
58 IdentTypes::Quantifier getQuantifier();
59 long getRefCount();
60 const std::string getUri();
61 bool isLocalNameWildcard();
62 bool isUriWildcard();
63
64 static TypeIdentifier
65 createAnyNodeType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
66
67 static TypeIdentifier
68 createAttributeType (const std::string &uri, bool uriWildcard, const std::string &localNameName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
69
70 static TypeIdentifier
71 createCommentType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
72
73 static TypeIdentifier
74 createDocumentType (TypeIdentifier contentType, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
75
76 static TypeIdentifier
77 createElementType (const std::string &uri, bool uriWildcard, const std::string &localName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
78
79 static TypeIdentifier
80 createEmptyType();
81
82 static TypeIdentifier
83 createItemType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
84
85 static TypeIdentifier
86 createNamedType (const std::string &uri, const std::string &localName, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
87
88 static TypeIdentifier
89 createPIType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
90
91 static TypeIdentifier
92 createTextType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
93
94}; // class TypeIdentifier
95
96
97#endif
0\ No newline at end of file98\ No newline at end of file
199
=== added file 'swig/TypeIdentifier.i'
--- swig/TypeIdentifier.i 1970-01-01 00:00:00 +0000
+++ swig/TypeIdentifier.i 2012-03-26 20:16:18 +0000
@@ -0,0 +1,197 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17%{ // start Implementation
18
19 zorba::IdentTypes::quantifier_t
20 TypeIdentifier::convertQuantifier(IdentTypes::Quantifier quantifier)
21 {
22 zorba::IdentTypes::quantifier_t result;
23 switch (quantifier) {
24 case IdentTypes::QUANT_ONE:
25 result = zorba::IdentTypes::QUANT_ONE;
26 break;
27 case IdentTypes::QUANT_QUESTION:
28 result = zorba::IdentTypes::QUANT_QUESTION;
29 break;
30 case IdentTypes::QUANT_PLUS:
31 result = zorba::IdentTypes::QUANT_PLUS;
32 break;
33 case IdentTypes::QUANT_STAR:
34 result = zorba::IdentTypes::QUANT_STAR;
35 break;
36 }
37 return result;
38 }
39
40 TypeIdentifier TypeIdentifier::getContentType()
41 {
42 return TypeIdentifier(theTypeIdentifier->getContentType());
43 }
44 IdentTypes::Kind TypeIdentifier::getKind()
45 {
46 zorba::IdentTypes::kind_t lKind = theTypeIdentifier->getKind();
47 IdentTypes::Kind result;
48 switch (lKind) {
49 case zorba::IdentTypes::NAMED_TYPE:
50 result = IdentTypes::NAMED_TYPE;
51 break;
52 case zorba::IdentTypes::ELEMENT_TYPE:
53 result = IdentTypes::ELEMENT_TYPE;
54 break;
55 case zorba::IdentTypes::ATTRIBUTE_TYPE:
56 result = IdentTypes::ATTRIBUTE_TYPE;
57 break;
58 case zorba::IdentTypes::DOCUMENT_TYPE:
59 result = IdentTypes::DOCUMENT_TYPE;
60 break;
61 case zorba::IdentTypes::PI_TYPE:
62 result = IdentTypes::PI_TYPE;
63 break;
64 case zorba::IdentTypes::TEXT_TYPE:
65 result = IdentTypes::TEXT_TYPE;
66 break;
67 case zorba::IdentTypes::COMMENT_TYPE:
68 result = IdentTypes::COMMENT_TYPE;
69 break;
70 case zorba::IdentTypes::ANY_NODE_TYPE:
71 result = IdentTypes::ANY_NODE_TYPE;
72 break;
73 case zorba::IdentTypes::ITEM_TYPE:
74 result = IdentTypes::ITEM_TYPE;
75 break;
76 case zorba::IdentTypes::EMPTY_TYPE:
77 result = IdentTypes::EMPTY_TYPE;
78 break;
79 case zorba::IdentTypes::INVALID_TYPE:
80 result = IdentTypes::INVALID_TYPE;
81 break;
82 default:
83 result = IdentTypes::ANY_NODE_TYPE;
84 break;
85 }
86 return result;
87 }
88 const std::string TypeIdentifier::getLocalName()
89 {
90 return std::string(theTypeIdentifier->getLocalName().c_str());
91 }
92 IdentTypes::Quantifier TypeIdentifier::getQuantifier()
93 {
94 zorba::IdentTypes::quantifier_t lQuantifier = theTypeIdentifier->getQuantifier();
95 IdentTypes::Quantifier result;
96 switch (lQuantifier) {
97 case zorba::IdentTypes::QUANT_ONE:
98 result = IdentTypes::QUANT_ONE;
99 break;
100 case zorba::IdentTypes::QUANT_QUESTION:
101 result = IdentTypes::QUANT_QUESTION;
102 break;
103 case zorba::IdentTypes::QUANT_PLUS:
104 result = IdentTypes::QUANT_PLUS;
105 break;
106 case zorba::IdentTypes::QUANT_STAR:
107 result = IdentTypes::QUANT_STAR;
108 break;
109 }
110 return result;
111 }
112 long TypeIdentifier::getRefCount()
113 {
114 return theTypeIdentifier->getRefCount();
115 }
116 const std::string TypeIdentifier::getUri()
117 {
118 return std::string(theTypeIdentifier->getUri().c_str());
119 }
120 bool TypeIdentifier::isLocalNameWildcard()
121 {
122 return theTypeIdentifier->isLocalNameWildcard();
123 }
124 bool TypeIdentifier::isUriWildcard()
125 {
126 return theTypeIdentifier->isUriWildcard();
127 }
128
129
130 // STATIC METHODS
131 TypeIdentifier
132 TypeIdentifier::createAnyNodeType (IdentTypes::Quantifier quantifier)
133 {
134 return TypeIdentifier( zorba::TypeIdentifier::createAnyNodeType ( convertQuantifier(quantifier) ) );
135 }
136
137 TypeIdentifier
138 TypeIdentifier::createAttributeType (const std::string &uri, bool uriWildcard, const std::string &localNameName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier)
139 {
140 return TypeIdentifier( zorba::TypeIdentifier::createAttributeType( uri, uriWildcard, localNameName, localNameWildcard, contentType.theTypeIdentifier, convertQuantifier(quantifier) ) );
141 }
142
143 TypeIdentifier
144 TypeIdentifier::createCommentType (IdentTypes::Quantifier quantifier)
145 {
146 return TypeIdentifier( zorba::TypeIdentifier::createCommentType ( convertQuantifier(quantifier) ) );
147 }
148
149 TypeIdentifier
150 TypeIdentifier::createDocumentType (TypeIdentifier contentType, IdentTypes::Quantifier quantifier)
151 {
152 return TypeIdentifier( zorba::TypeIdentifier::createDocumentType(contentType.theTypeIdentifier, convertQuantifier(quantifier) ) );
153 }
154
155 TypeIdentifier
156 TypeIdentifier::createElementType (const std::string &uri, bool uriWildcard, const std::string &localName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier)
157 {
158 return TypeIdentifier( zorba::TypeIdentifier::createElementType(uri, uriWildcard, localName, localNameWildcard, contentType.theTypeIdentifier, convertQuantifier(quantifier) ) );
159 }
160
161 TypeIdentifier
162 TypeIdentifier::createEmptyType()
163 {
164 return TypeIdentifier( zorba::TypeIdentifier::createEmptyType() );
165 }
166
167 TypeIdentifier
168 TypeIdentifier::createItemType (IdentTypes::Quantifier quantifier)
169 {
170 return TypeIdentifier( zorba::TypeIdentifier::createItemType( convertQuantifier(quantifier) ) );
171 }
172
173 TypeIdentifier
174 TypeIdentifier::createNamedType (const std::string &uri, const std::string &localName, IdentTypes::Quantifier quantifier)
175 {
176 return TypeIdentifier( zorba::TypeIdentifier::createNamedType( uri, localName, convertQuantifier(quantifier) ) );
177 }
178
179 TypeIdentifier
180 TypeIdentifier::createPIType (IdentTypes::Quantifier quantifier)
181 {
182 return TypeIdentifier( zorba::TypeIdentifier::createPIType( convertQuantifier(quantifier) ) );
183 }
184
185 TypeIdentifier
186 TypeIdentifier::createTextType (IdentTypes::Quantifier quantifier)
187 {
188 return TypeIdentifier( zorba::TypeIdentifier::createTextType( convertQuantifier(quantifier) ) );
189 }
190
191 // END OF STATIC METHODS
192
193
194%} // end Implementation
195
196
197%include "TypeIdentifier.h"
0198
=== added file 'swig/XQuery.h'
--- swig/XQuery.h 1970-01-01 00:00:00 +0000
+++ swig/XQuery.h 2012-03-26 20:16:18 +0000
@@ -0,0 +1,47 @@
1/*
2 * Copyright 2006-2008 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef API_XQUERY_H
17#define API_XQUERY_H
18
19class XQuery
20{
21private:
22 zorba::XQuery_t theQuery;
23 bool closed;
24
25public:
26 XQuery():closed(false) {}
27 XQuery(const XQuery& aXQuery) : theQuery(aXQuery.theQuery), closed(aXQuery.closed) {}
28 XQuery(zorba::XQuery_t aQuery) : theQuery(aQuery), closed(false) {}
29
30 std::string execute();
31 std::string printPlanAsXML();
32 std::string printPlanAsDOT();
33 void compile (const std::string &aQuery);
34 void compile (const std::string &aQuery, StaticContext &aStaticContext);
35
36#ifdef SWIGPYTHON
37 void executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy);
38#endif
39
40 void destroy();
41 Iterator iterator();
42 DynamicContext getDynamicContext();
43 StaticContext getStaticContext();
44 void getExternalVariables(Iterator& vars) const;
45}; // class XQuery
46
47#endif
0\ No newline at end of file48\ No newline at end of file
149
=== modified file 'swig/XQuery.i'
--- swig/XQuery.i 2012-03-23 17:32:07 +0000
+++ swig/XQuery.i 2012-03-26 20:16:18 +0000
@@ -16,332 +16,60 @@
1616
17%{ // start Implementation17%{ // start Implementation
1818
19class Iterator 19 std::string XQuery::execute()
20{
21protected:
22 friend class DynamicContext;
23 zorba::Iterator_t theIterator;
24 zorba::Item theItem;
25 bool theConsumed;
26
27public:
28 Iterator() {}
29 Iterator(const Iterator& anIterator)
30 : theIterator(anIterator.theIterator),
31 theItem(anIterator.theItem),
32 theConsumed(false)
33 {}
34
35 Iterator(zorba::Iterator_t anIterator)
36 : theIterator(anIterator),
37 theConsumed(false)
38 {}
39
40 Iterator(zorba::Item& aItem)
41 : theIterator(0),
42 theItem(aItem),
43 theConsumed(false)
44 {}
45
46 void open()
47 {
48 if (theIterator)
49 theIterator->open();
50 theConsumed = false;
51 }
52
53 bool next(Item& aItem);
54
55 void close()
56 {
57 if (theIterator)
58 theIterator->close();
59 theConsumed = true;
60 }
61
62 void destroy()
63 {
64 theIterator = 0;
65 }
66
67}; // class Iterator
68
69
70class Item
71{
72 friend class Iterator;
73 friend class StaticContext;
74 friend class DocumentManager;
75 friend class SingletonIterator;
76 friend class DynamicContext;
77 friend class ItemFactory;
78
79private:
80 zorba::Item theItem;
81
82public:
83 Item() {}
84 Item(const Item& aItem) : theItem(aItem.theItem) {}
85 Item(const zorba::Item& aZItem) : theItem(aZItem) {}
86
87 static Item createEmptyItem()
88 { return Item(); }
89
90 std::string getStringValue() const
91 { return std::string(theItem.getStringValue().c_str()); }
92
93 std::string serialize() const
94 {
95 std::stringstream lStream;
96 Zorba_SerializerOptions_t lOptions;
97 zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(lOptions);
98 zorba::SingletonItemSequence lSequence(theItem);
99 lSerializer->serialize(&lSequence, lStream);
100 return lStream.str();
101 }
102
103 Iterator getAtomizationValue () const
104 { return Iterator(theItem.getAtomizationValue()); }
105
106 Iterator getAttributes () const
107 { return Iterator(theItem.getAttributes()); }
108
109 bool getBooleanValue () const
110 { return theItem.getBooleanValue(); }
111
112 Iterator getChildren () const
113 { return Iterator(theItem.getChildren()); }
114
115 Item getEBV () const
116 { return Item(theItem.getEBV()); }
117
118 int getIntValue () const
119 { return theItem.getIntValue(); }
120
121 std::string getLocalName () const
122 { return std::string(theItem.getLocalName().c_str()); }
123
124 std::string getNamespace () const
125 { return std::string(theItem.getNamespace().c_str()); }
126
127 bool getNodeName (Item &aNodeName) const
128 { return theItem.getNodeName( aNodeName.theItem ); }
129
130 std::string getPrefix () const
131 { return std::string(theItem.getPrefix().c_str()); }
132
133 Item getType () const
134 { return Item( theItem.getType() ); }
135
136 unsigned int getUnsignedIntValue () const
137 { return theItem.getUnsignedIntValue(); }
138
139 bool isAtomic () const
140 { return theItem.isAtomic(); }
141
142 bool isNaN () const
143 { return theItem.isNaN(); }
144
145 bool isNode () const
146 { return theItem.isNode(); }
147
148 bool isNull () const
149 { return theItem.isNull(); }
150
151 bool isPosOrNegInf () const
152 { return theItem.isPosOrNegInf(); }
153
154 int getNodeKind () const
155 { return theItem.getNodeKind(); }
156
157}; // class Item
158
159class DynamicContext
160{
161private:
162 zorba::DynamicContext* theContext;
163
164public:
165 DynamicContext()
166 : theContext(0)
167 {
168 }
169
170 DynamicContext(const DynamicContext& aCtx)
171 : theContext(aCtx.theContext)
172 {
173 }
174
175 DynamicContext(zorba::DynamicContext* aCtx)
176 : theContext(aCtx)
177 {
178 }
179
180 void
181 setVariable(
182 const std::string& aNamespace,
183 const std::string& aLocalname,
184 Iterator aIter)
185 {
186 theContext->setVariable(aNamespace, aLocalname, aIter.theIterator);
187 }
188
189 void
190 setContextItem(Item aItem)
191 {
192 theContext->setContextItem(aItem.theItem);
193 }
194};
195
196class XQuery
197{
198private:
199 zorba::XQuery_t theQuery;
200
201public:
202 XQuery() {}
203 XQuery(const XQuery& aXQuery) : theQuery(aXQuery.theQuery) {}
204 XQuery(zorba::XQuery_t aQuery) : theQuery(aQuery) {}
205
206 std::string execute()
207 {20 {
208 std::stringstream lStream;21 std::stringstream lStream;
209 lStream << theQuery;22 lStream << theQuery;
210 return lStream.str();23 std::string str = lStream.str();
24 return str;
211 }25 }
21226
213 void compile (const std::string &aQuery)27 void XQuery::compile (const std::string &aQuery)
214 {28 {
215 theQuery->compile(aQuery);29 theQuery->compile(aQuery);
216 }30 }
21731
218 void compile (const std::string &aQuery, StaticContext &aStaticContext )32 void XQuery::compile (const std::string &aQuery, StaticContext &aStaticContext )
219 {33 {
220 Zorba_CompilerHints_t hints;34 Zorba_CompilerHints_t hints;
221 theQuery->compile(aQuery, aStaticContext.theStaticContext, hints);35 theQuery->compile(aQuery, aStaticContext.theStaticContext, hints);
222 }36 }
22337
224 std::string printPlanAsXML()38 std::string XQuery::printPlanAsXML()
225 {39 {
226 std::ostringstream lStream;40 std::ostringstream lStream;
227 theQuery->printPlan(lStream);41 theQuery->printPlan(lStream);
228 return lStream.str();42 return lStream.str();
229 }43 }
23044
231 std::string printPlanAsDOT()45 std::string XQuery::printPlanAsDOT()
232 {46 {
233 std::ostringstream lStream;47 std::ostringstream lStream;
234 theQuery->printPlan(lStream, true);48 theQuery->printPlan(lStream, true);
235 return lStream.str();49 return lStream.str();
236 }50 }
23751
238 DynamicContext52 DynamicContext XQuery::getDynamicContext()
239 getDynamicContext()
240 {53 {
241 return DynamicContext(theQuery->getDynamicContext());54 return DynamicContext(theQuery->getDynamicContext());
242 }55 }
24356
57 StaticContext XQuery::getStaticContext()
58 {
59 return StaticContext( zorba::StaticContext_t( const_cast<zorba::StaticContext *>(theQuery->getStaticContext()) ) );
60 }
61
62 void XQuery::getExternalVariables(Iterator& vars) const
63 { theQuery->getExternalVariables( vars.theIterator ); }
64
244#ifdef SWIGPYTHON65#ifdef SWIGPYTHON
245 void executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy)66 void XQuery::executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy)
246 { theQuery->executeSAX(contentHandlerProxy); }67 { theQuery->executeSAX(contentHandlerProxy); }
247#endif68#endif
24869
249 void destroy() { theQuery = 0; }70 void XQuery::destroy() { theQuery = 0; }
250 Iterator iterator() { return Iterator(theQuery->iterator()); }71 Iterator XQuery::iterator() { return Iterator(theQuery->iterator()); }
251}; // class XQuery
252
253
254// remaining method definitions from Iterator
255bool
256Iterator::next(Item& aItem)
257{
258 if (theIterator)
259 {
260 return theIterator->next(aItem.theItem);
261 }
262 else
263 {
264 if (!theConsumed)
265 {
266 aItem = theItem;
267 return true;
268 }
269 else
270 {
271 return false;
272 }
273 }
274}
275
27672
277%} // end Implementation73%} // end Implementation
27874
27975%include "XQuery.h"
280// Interfaces
281
282class DynamicContext
283{
284public:
285 void
286 setVariable(
287 const std::string& aNamespace,
288 const std::string& aLocalname,
289 Iterator);
290
291 void
292 setContextItem(Item);
293};
294
295class Item
296{
297public:
298 static Item createEmptyItem();
299 std::string getStringValue() const;
300 std::string serialize() const;
301 Iterator getAtomizationValue () const;
302 Iterator getAttributes () const;
303 bool getBooleanValue () const;
304 Iterator getChildren () const;
305 Item getEBV () const;
306 int getIntValue () const;
307 std::string getLocalName () const;
308 std::string getNamespace () const;
309 bool getNodeName (Item &aNodeName) const;
310 std::string getPrefix () const;
311 Item getType () const;
312 unsigned int getUnsignedIntValue () const;
313
314 int getNodeKind() const;
315 bool isAtomic () const;
316 bool isNaN () const;
317 bool isNode () const;
318 bool isNull () const;
319 bool isPosOrNegInf () const;
320}; // class Item
321
322class Iterator
323{
324public:
325 void open();
326 bool next(Item&);
327 void close();
328 void destroy();
329}; // class Iterator
330
331class XQuery
332{
333public:
334 std::string execute();
335 std::string printPlanAsXML();
336 std::string printPlanAsDOT();
337 void compile (const std::string &aQuery);
338 void compile (const std::string &aQuery, StaticContext &aStaticContext);
339
340#ifdef SWIGPYTHON
341 void executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy);
342#endif
343
344 void destroy();
345 Iterator iterator();
346 DynamicContext getDynamicContext();
347}; // class XQuery
348\ No newline at end of file76\ No newline at end of file
34977
=== added file 'swig/XmlDataManager.h'
--- swig/XmlDataManager.h 1970-01-01 00:00:00 +0000
+++ swig/XmlDataManager.h 2012-03-26 20:16:18 +0000
@@ -0,0 +1,35 @@
1/*
2 * Copyright 2006-2012 The FLWOR Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef API_XML_DATA_MANAGER_H
17#define API_XML_DATA_MANAGER_H
18
19class XmlDataManager
20{
21private:
22 zorba::XmlDataManager* theManager;
23
24public:
25 XmlDataManager() : theManager(0) {}
26 XmlDataManager(const XmlDataManager& aMgr) : theManager(aMgr.theManager) {}
27 XmlDataManager(zorba::XmlDataManager* aMgr) : theManager(aMgr) {}
28
29 DocumentManager getDocumentManager();
30 CollectionManager getCollectionManager();
31 CollectionManager getW3CCollectionManager();
32 Iterator parseXML(const std::string& aDoc);
33
34};
35#endif
0\ No newline at end of file36\ No newline at end of file
137
=== modified file 'swig/XmlDataManager.i'
--- swig/XmlDataManager.i 2012-03-23 17:32:07 +0000
+++ swig/XmlDataManager.i 2012-03-26 20:16:18 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2006-2008 The FLWOR Foundation.2 * Copyright 2006-2012 The FLWOR Foundation.
3 *3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.5 * you may not use this file except in compliance with the License.
@@ -16,54 +16,20 @@
1616
17%{ // start Implementation17%{ // start Implementation
1818
1919 DocumentManager XmlDataManager::getDocumentManager()
20class DocumentManager
21{
22private:
23 zorba::DocumentManager* theManager;
24
25public:
26 DocumentManager() : theManager(0) {}
27 DocumentManager(const DocumentManager& aMgr) : theManager(aMgr.theManager) {}
28 DocumentManager(zorba::DocumentManager* aMgr) : theManager(aMgr) {}
29
30 void put(const std::string& aName, Item aDoc)
31 {
32 theManager->put(aName, aDoc.theItem);
33 }
34
35 void remove(const std::string& aName)
36 {
37 theManager->remove(aName);
38 }
39
40 Item document(const std::string& aName)
41 {
42 return theManager->document(aName);
43 }
44
45 bool isAvailableDocument(const std::string& aName)
46 {
47 return theManager->isAvailableDocument(aName);
48 }
49};
50
51class XmlDataManager
52{
53private:
54 zorba::XmlDataManager* theManager;
55
56public:
57 XmlDataManager() : theManager(0) {}
58 XmlDataManager(const XmlDataManager& aMgr) : theManager(aMgr.theManager) {}
59 XmlDataManager(zorba::XmlDataManager* aMgr) : theManager(aMgr) {}
60
61 DocumentManager getDocumentManager()
62 {20 {
63 return DocumentManager(theManager->getDocumentManager()); 21 return DocumentManager(theManager->getDocumentManager());
64 }22 }
23 CollectionManager XmlDataManager::getCollectionManager()
24 {
25 return CollectionManager(theManager->getCollectionManager());
26 }
27 CollectionManager XmlDataManager::getW3CCollectionManager()
28 {
29 return CollectionManager(theManager->getW3CCollectionManager());
30 }
6531
66 Iterator parseXML(const std::string& aDoc)32 Iterator XmlDataManager::parseXML(const std::string& aDoc)
67 {33 {
68 std::stringstream lDoc;34 std::stringstream lDoc;
69 lDoc << aDoc;35 lDoc << aDoc;
@@ -71,28 +37,7 @@
71 return Iterator(lItem);37 return Iterator(lItem);
72 }38 }
7339
74};
7540
76%} // end Implementation41%} // end Implementation
7742
78class DocumentManager43%include "XmlDataManager.h"
79{
80public:
81 void put(const std::string& aName, Item aDoc);
82
83 void remove(const std::string& aName);
84
85 Item document(const std::string& aName);
86
87 bool isAvailableDocument(const std::string& aName);
88};
89
90
91class XmlDataManager
92{
93public:
94 DocumentManager getDocumentManager();
95
96 Iterator parseXML(const std::string& aDoc);
97
98}; // class XmlDataManager
9944
=== modified file 'swig/Zorba.i'
--- swig/Zorba.i 2012-03-23 17:32:07 +0000
+++ swig/Zorba.i 2012-03-26 20:16:18 +0000
@@ -15,27 +15,26 @@
15 {15 {
16 return Zorba(zorba::Zorba::getInstance(aStore.getStore()));16 return Zorba(zorba::Zorba::getInstance(aStore.getStore()));
17 }17 }
18
19 ItemFactory getItemFactory()18 ItemFactory getItemFactory()
20 {19 {
21 return ItemFactory(theZorba->getItemFactory());20 return ItemFactory(theZorba->getItemFactory());
22 }21 }
2322
24 StaticContext createStaticContext()23 StaticContext createStaticContext()
25 {24 {
26 return StaticContext(theZorba->createStaticContext());25 return StaticContext(theZorba->createStaticContext());
27 }26 }
28 27
28 XQuery createQuery()
29 {
30 return XQuery(theZorba->createQuery());
31 }
32
29 XQuery compileQuery(const std::string& aStr) 33 XQuery compileQuery(const std::string& aStr)
30 {34 {
31 return XQuery(theZorba->compileQuery(aStr));35 return XQuery(theZorba->compileQuery(aStr));
32 }36 }
3337
34 XQuery createQuery()
35 {
36 return XQuery(theZorba->createQuery());
37 }
38
39 XQuery compileQuery(38 XQuery compileQuery(
40 const std::string& aStr,39 const std::string& aStr,
41 StaticContext &aStaticContext )40 StaticContext &aStaticContext )
@@ -47,6 +46,22 @@
47 )46 )
48 );47 );
49 }48 }
49/*
50 XQuery compileQuery(const ZIStreamHelper& aZorbaStream)
51 {
52 zorbabuffer *buffer = new zorbabuffer(&const_cast<ZIStreamHelper &> (aZorbaStream));
53 std::istream stream = std::istream(buffer);
54 //zistream stream = zistream(buffer);
55 return XQuery(theZorba->compileQuery(stream));
56 }
57
58 XQuery compileQuery(const ZIStreamHelper& aZorbaStream, StaticContext &aStaticContext )
59 {
60 zorbabuffer *buffer = new zorbabuffer(&const_cast<ZIStreamHelper &> (aZorbaStream));
61 std::istream stream = std::istream(buffer);
62 return XQuery(theZorba->compileQuery(stream, aStaticContext.theStaticContext));
63 }
64*/
5065
51 /*66 /*
52 //--->> DiagnosticHandler implementations are postponed67 //--->> DiagnosticHandler implementations are postponed
@@ -95,6 +110,18 @@
95 {110 {
96 theZorba->shutdown();111 theZorba->shutdown();
97 }112 }
113 std::string getVersion() {
114 return zorba::Zorba::version().getVersion();
115 }
116 int getMajorVersion() {
117 return zorba::Zorba::version().getMajorVersion();
118 }
119 int getMinorVersion() {
120 return zorba::Zorba::version().getMinorVersion();
121 }
122 int getPatchVersion() {
123 return zorba::Zorba::version().getPatchVersion();
124 }
98125
99}; // class Zorba126}; // class Zorba
100127
@@ -111,8 +138,9 @@
111 XQuery createQuery();138 XQuery createQuery();
112 XQuery compileQuery(const std::string& aStr);139 XQuery compileQuery(const std::string& aStr);
113 XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext );140 XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext );
141 //XQuery compileQuery(const ZIStreamHelper& aZorbaStream);
142 //XQuery compileQuery(const ZIStreamHelper& aZorbaStream, StaticContext &aStaticContext );
114 ItemFactory getItemFactory();143 ItemFactory getItemFactory();
115
116 /*144 /*
117 XQuery compileQuery(const std::string& aStr, DiagnosticHandler* aDiagnosticHandler);145 XQuery compileQuery(const std::string& aStr, DiagnosticHandler* aDiagnosticHandler);
118 XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext, 146 XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext,
@@ -122,5 +150,9 @@
122 */150 */
123 XmlDataManager getXmlDataManager();151 XmlDataManager getXmlDataManager();
124 void shutdown();152 void shutdown();
153 std::string getVersion();
154 int getMajorVersion();
155 int getMinorVersion();
156 int getPatchVersion();
125157
126}; // class Zorba158}; // class Zorba
127159
=== modified file 'swig/java/CMakeLists.txt'
--- swig/java/CMakeLists.txt 2012-03-23 17:32:07 +0000
+++ swig/java/CMakeLists.txt 2012-03-26 20:16:18 +0000
@@ -60,8 +60,21 @@
60 MESSAGE(STATUS "Java module install path: " ${JAVA_SITEARCH_DIR})60 MESSAGE(STATUS "Java module install path: " ${JAVA_SITEARCH_DIR})
6161
62 FILE(GLOB JAVA_SWIG_FILES "${CMAKE_CURRENT_BINARY_DIR}/*.java")62 FILE(GLOB JAVA_SWIG_FILES "${CMAKE_CURRENT_BINARY_DIR}/*.java")
63 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")63 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h" COPYONLY)
64 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")64 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h" COPYONLY)
65 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h" COPYONLY)
66 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h" COPYONLY)
67 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h" COPYONLY)
68 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h" COPYONLY)
69 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h" COPYONLY)
70 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h" COPYONLY)
71 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../SerializationOptions.h" "${CMAKE_CURRENT_BINARY_DIR}/SerializationOptions.h" COPYONLY)
72 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Collection.h" "${CMAKE_CURRENT_BINARY_DIR}/Collection.h" COPYONLY)
73 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY)
74 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY)
75 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY)
76# CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZInputStream.java" "${CMAKE_CURRENT_BINARY_DIR}/ZInputStream.java" COPYONLY)
77# CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/zistream.java" "${CMAKE_CURRENT_BINARY_DIR}/zistream.java" COPYONLY)
6578
66 IF ( APPLE )79 IF ( APPLE )
67 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_SWIG_LIB_PREFIX}libzorba_api.jnilib DESTINATION ${JAVA_SITEARCH_DIR})80 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_SWIG_LIB_PREFIX}libzorba_api.jnilib DESTINATION ${JAVA_SITEARCH_DIR})
6881
=== modified file 'swig/java/zorba_api.i'
--- swig/java/zorba_api.i 2012-03-23 17:32:07 +0000
+++ swig/java/zorba_api.i 2012-03-26 20:16:18 +0000
@@ -20,5 +20,6 @@
20// don't do a JNI call for constants and enums.20// don't do a JNI call for constants and enums.
21%javaconst(1);21%javaconst(1);
2222
23
24
23%include ../zorba_api.i25%include ../zorba_api.i
24
2526
=== modified file 'swig/php/CMakeLists.txt'
--- swig/php/CMakeLists.txt 2012-03-23 17:32:07 +0000
+++ swig/php/CMakeLists.txt 2012-03-26 20:16:18 +0000
@@ -35,6 +35,8 @@
35 ENDIF (APPLE)35 ENDIF (APPLE)
3636
37 IF (WIN32)37 IF (WIN32)
38 STRING(REGEX REPLACE "\\\\" "/" PHP5_LIBRARY "${PHP5_LIBRARY}")
39 MESSAGE (STATUS "SWIG PHP: Link library: " ${PHP5_LIBRARY})
38 SWIG_LINK_LIBRARIES (zorba_api ${PHP5_LIBRARY})40 SWIG_LINK_LIBRARIES (zorba_api ${PHP5_LIBRARY})
39 ENDIF (WIN32)41 ENDIF (WIN32)
4042
@@ -47,6 +49,17 @@
4749
48 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")50 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")
49 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")51 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")
52 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h")
53 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h")
54 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h")
55 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h")
56 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h")
57 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h")
58 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../SerializationOptions.h" "${CMAKE_CURRENT_BINARY_DIR}/SerializationOptions.h" COPYONLY)
59 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Collection.h" "${CMAKE_CURRENT_BINARY_DIR}/Collection.h" COPYONLY)
60 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY)
61 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY)
62 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY)
5063
51 # The following fix was added because of the changes in CMake 2.8, which have the64 # The following fix was added because of the changes in CMake 2.8, which have the
52 # result of naming the java binding library "liblibzorba_api.so" instead of "libzorba_api.so"65 # result of naming the java binding library "liblibzorba_api.so" instead of "libzorba_api.so"
@@ -84,4 +97,5 @@
84 DESTINATION share/php )97 DESTINATION share/php )
85 ENDIF (MSVC_IDE)98 ENDIF (MSVC_IDE)
86 ENDIF (NOT WIN32 OR CYGWIN)99 ENDIF (NOT WIN32 OR CYGWIN)
100 ADD_SUBDIRECTORY (tests)
87ENDIF (NOT PHP5_FOUND)101ENDIF (NOT PHP5_FOUND)
88102
=== added directory 'swig/php/tests'
=== added file 'swig/php/tests/CMakeLists.txt'
--- swig/php/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ swig/php/tests/CMakeLists.txt 2012-03-26 20:16:18 +0000
@@ -0,0 +1,90 @@
1# Copyright 2006-2011 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14MESSAGE(STATUS "Adding tests for PHP Binding")
15
16SET(phpPath ${CMAKE_BINARY_DIR}/swig/php)
17IF (MSVC_IDE)
18 SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php/@CMAKE_BUILD_TYPE@)
19ELSE (MSVC_IDE)
20 SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php)
21ENDIF (MSVC_IDE)
22SET(phpIncludePath ${CMAKE_BINARY_DIR}/swig/php)
23MESSAGE(STATUS "PHP Path:" ${phpPath})
24MESSAGE(STATUS "PHP Extension Path: " ${phpExtensionPath})
25MESSAGE(STATUS "PHP Include Path: " ${phpExtensionPath})
26
27CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/php.ini.in ${CMAKE_CURRENT_BINARY_DIR}/php.ini)
28
29CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/books.xml ${CMAKE_CURRENT_BINARY_DIR}/books.xml COPYONLY)
30CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/compilerHints.xq ${CMAKE_CURRENT_BINARY_DIR}/compilerHints.xq COPYONLY)
31
32CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test01.php ${CMAKE_CURRENT_BINARY_DIR}/test01.php)
33ADD_TEST("php_test01" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test01.php)
34SET_TESTS_PROPERTIES("php_test01" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
35
36CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test02.php ${CMAKE_CURRENT_BINARY_DIR}/test02.php)
37ADD_TEST("php_test02" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test02.php)
38SET_TESTS_PROPERTIES("php_test02" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
39
40#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test03.php ${CMAKE_CURRENT_BINARY_DIR}/test03.php)
41#ADD_TEST("php_test03" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test03.php)
42#SET_TESTS_PROPERTIES("php_test03" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
43
44CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test04.php ${CMAKE_CURRENT_BINARY_DIR}/test04.php)
45ADD_TEST("php_test04" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test04.php)
46CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test04.xq ${CMAKE_CURRENT_BINARY_DIR}/test04.xq COPYONLY)
47SET_TESTS_PROPERTIES("php_test04" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
48
49CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test05.php ${CMAKE_CURRENT_BINARY_DIR}/test05.php)
50ADD_TEST("php_test05" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test05.php)
51CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test05.xq ${CMAKE_CURRENT_BINARY_DIR}/test05.xq COPYONLY)
52SET_TESTS_PROPERTIES("php_test05" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
53
54CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test06.php ${CMAKE_CURRENT_BINARY_DIR}/test06.php)
55ADD_TEST("php_test06" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test06.php)
56CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test06.xq ${CMAKE_CURRENT_BINARY_DIR}/test06.xq COPYONLY)
57SET_TESTS_PROPERTIES("php_test06" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
58
59CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test07.php ${CMAKE_CURRENT_BINARY_DIR}/test07.php)
60ADD_TEST("php_test07" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test07.php)
61SET_TESTS_PROPERTIES("php_test07" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
62
63CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test08.php ${CMAKE_CURRENT_BINARY_DIR}/test08.php)
64ADD_TEST("php_test08" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test08.php)
65SET_TESTS_PROPERTIES("php_test08" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
66
67#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test09.php ${CMAKE_CURRENT_BINARY_DIR}/test09.php)
68#ADD_TEST("php_test09" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test09.php)
69#SET_TESTS_PROPERTIES("php_test09" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
70
71CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test10.php ${CMAKE_CURRENT_BINARY_DIR}/test10.php)
72ADD_TEST("php_test10" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test10.php)
73SET_TESTS_PROPERTIES("php_test10" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
74
75#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test11.php ${CMAKE_CURRENT_BINARY_DIR}/test11.php)
76#ADD_TEST("php_test11" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test11.php)
77#SET_TESTS_PROPERTIES("php_test11" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
78
79#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test12.php ${CMAKE_CURRENT_BINARY_DIR}/test12.php)
80#ADD_TEST("php_test12" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test12.php)
81#SET_TESTS_PROPERTIES("php_test12" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
82
83#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test13.php ${CMAKE_CURRENT_BINARY_DIR}/test13.php)
84#ADD_TEST("php_test13" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test13.php)
85#SET_TESTS_PROPERTIES("php_test13" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
86
87#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test14.php ${CMAKE_CURRENT_BINARY_DIR}/test14.php)
88#ADD_TEST("php_test14" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test14.php)
89#SET_TESTS_PROPERTIES("php_test14" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
90
091
=== added file 'swig/php/tests/books.xml'
--- swig/php/tests/books.xml 1970-01-01 00:00:00 +0000
+++ swig/php/tests/books.xml 2012-03-26 20:16:18 +0000
@@ -0,0 +1,11 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2<books>
3 <book>
4 <title>Book 1</title>
5 <author>Author 1</author>
6 </book>
7 <book featured="YES">
8 <title>Book 2</title>
9 <author>Author 2</author>
10 </book>
11</books>
012
=== added file 'swig/php/tests/compilerHints.xq'
--- swig/php/tests/compilerHints.xq 1970-01-01 00:00:00 +0000
+++ swig/php/tests/compilerHints.xq 2012-03-26 20:16:18 +0000
@@ -0,0 +1,4 @@
1for tumbling window $w in (2, 4, 6, 8, 10, 12, 14)
2 start at $s when fn:true()
3 only end at $e when $e - $s eq 2
4return avg($w)
05
=== added file 'swig/php/tests/php.ini.in'
--- swig/php/tests/php.ini.in 1970-01-01 00:00:00 +0000
+++ swig/php/tests/php.ini.in 2012-03-26 20:16:18 +0000
@@ -0,0 +1,3 @@
1enable_dl=On
2extension_dir=@phpExtensionPath@
3include_path=".:@phpIncludePath@"
0\ No newline at end of file4\ No newline at end of file
15
=== added file 'swig/php/tests/test01.php'
--- swig/php/tests/test01.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test01.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,29 @@
1<?
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18require '@phpPath@/Zorba/zorba_api_wrapper.php';
19
20print "Running: Get zorba instance and shutdown\n";
21
22$store = InMemoryStore::getInstance();
23$zorba = Zorba::getInstance($store);
24
25$zorba->shutdown();
26InMemoryStore::shutdown($store);
27
28print "Success";
29?>
0\ No newline at end of file30\ No newline at end of file
131
=== added file 'swig/php/tests/test02.php'
--- swig/php/tests/test02.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test02.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,44 @@
1<?
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18require '@phpPath@/Zorba/zorba_api_wrapper.php';
19
20function test(Zorba $aZorba) {
21 $lQuery = $aZorba->compileQuery("(1,2,3,4,5)");
22 $iter = $lQuery->iterator();
23 $iter->open();
24 $item = Item::createEmptyItem();
25 while ($iter->next($item)) {
26 print $item->getStringValue()."\n";
27 }
28 $iter->close();
29 $iter->destroy();
30 return true;
31}
32
33
34$store = InMemoryStore::getInstance();
35$zorba = Zorba::getInstance($store);
36
37print "Running: Compile query string\n";
38test($zorba);
39print "Success";
40
41$zorba->shutdown();
42InMemoryStore::shutdown($store);
43
44?>
0\ No newline at end of file45\ No newline at end of file
146
=== added file 'swig/php/tests/test03.php'
--- swig/php/tests/test03.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test03.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,48 @@
1<?
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18require '@phpPath@/Zorba/zorba_api_wrapper.php';
19
20class MyDiagnosticHandler(DiagnosticHandler handler) {
21 funtion error(self, *args) {
22 print "Error args: ", args;
23 }
24}
25
26function test(Zorba $aZorba)
27{
28 diagnosticHandler = MyDiagnosticHandler()
29 try {
30 xquery = zorba.compileQuery("1 div 0", diagnosticHandler);
31 print xquery.execute()
32 } catch (Exception e) {
33 print "Caught error: ";
34 }
35 return
36}
37
38$store = InMemoryStore::getInstance();
39$zorba = Zorba::getInstance($store);
40
41print "Running: Compile query string using Diagnostic Handler"
42test($zorba);
43print "Success";
44
45$zorba->shutdown();
46InMemoryStore::shutdown($store);
47
48?>
0\ No newline at end of file49\ No newline at end of file
150
=== added file 'swig/php/tests/test04.php'
--- swig/php/tests/test04.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test04.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,43 @@
1<?
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18require '@phpPath@/Zorba/zorba_api_wrapper.php';
19
20function test(Zorba $aZorba) {
21 #Read and write result
22 $filename = 'test04.xq';
23 print "Executing: $filename\n";
24 $f = fopen($filename, 'r');
25 $contents = fread($f, filesize($filename));
26 fclose($f);
27 $xquery = $aZorba->compileQuery($contents);
28 $result = $xquery->execute();
29 print $result."\n";
30 return;
31}
32
33$store = InMemoryStore::getInstance();
34$zorba = Zorba::getInstance($store);
35
36print "Running: XQuery execute\n";
37test($zorba);
38print "Success";
39
40$zorba->shutdown();
41InMemoryStore::shutdown($store);
42
43?>
0\ No newline at end of file44\ No newline at end of file
145
=== added file 'swig/php/tests/test04.xq'
--- swig/php/tests/test04.xq 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test04.xq 2012-03-26 20:16:18 +0000
@@ -0,0 +1,4 @@
1for tumbling window $w in (2, 4, 6, 8, 10, 12, 14)
2 start at $s when fn:true()
3 only end at $e when $e - $s eq 2
4return avg($w)
05
=== added file 'swig/php/tests/test05.php'
--- swig/php/tests/test05.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test05.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,43 @@
1<?
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18require '@phpPath@/Zorba/zorba_api_wrapper.php';
19
20function test(Zorba $aZorba) {
21 #Read and write result
22 $filename = 'test05.xq';
23 print "Executing: $filename\n";
24 $f = fopen($filename, 'r');
25 $contents = fread($f, filesize($filename));
26 fclose($f);
27 $xquery = $aZorba->compileQuery($contents);
28 $result = $xquery->printPlanAsXML();
29 print $result."\n";
30 return;
31}
32
33$store = InMemoryStore::getInstance();
34$zorba = Zorba::getInstance($store);
35
36print "Running: XQuery execute - printPlanAsXML\n";
37test($zorba);
38print "Success";
39
40$zorba->shutdown();
41InMemoryStore::shutdown($store);
42
43?>
0\ No newline at end of file44\ No newline at end of file
145
=== added file 'swig/php/tests/test05.xq'
--- swig/php/tests/test05.xq 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test05.xq 2012-03-26 20:16:18 +0000
@@ -0,0 +1,7 @@
1for $x in (5,6,7,1,2,3,4)
2where $x < 4
3for $y in (4,9,6,8,2)
4let $z := $x * $y
5where $z > 20
6return
7<value x="{$x}" y="{$y}">{$z}</value>
0\ No newline at end of file8\ No newline at end of file
19
=== added file 'swig/php/tests/test06.php'
--- swig/php/tests/test06.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test06.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,43 @@
1<?
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18require '@phpPath@/Zorba/zorba_api_wrapper.php';
19
20function test(Zorba $aZorba) {
21 #Read and write result
22 $filename = 'test06.xq';
23 print "Executing: $filename\n";
24 $f = fopen($filename, 'r');
25 $contents = fread($f, filesize($filename));
26 fclose($f);
27 $xquery = $aZorba->compileQuery($contents);
28 $result = $xquery->printPlanAsDOT();
29 print $result."\n";
30 return;
31}
32
33$store = InMemoryStore::getInstance();
34$zorba = Zorba::getInstance($store);
35
36print "Running: XQuery execute - printPlanAsDOT\n";
37test($zorba);
38print "Success";
39
40$zorba->shutdown();
41InMemoryStore::shutdown($store);
42
43?>
0\ No newline at end of file44\ No newline at end of file
145
=== added file 'swig/php/tests/test06.xq'
--- swig/php/tests/test06.xq 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test06.xq 2012-03-26 20:16:18 +0000
@@ -0,0 +1,7 @@
1for $x in (5,6,7,1,2,3,4)
2where $x < 4
3for $y in (4,9,6,8,2)
4let $z := $x * $y
5where $z > 20
6return
7<value x="{$x}" y="{$y}">{$z}</value>
0\ No newline at end of file8\ No newline at end of file
19
=== added file 'swig/php/tests/test07.php'
--- swig/php/tests/test07.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test07.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,56 @@
1<?
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18require '@phpPath@/Zorba/zorba_api_wrapper.php';
19
20function test(Zorba $aZorba) {
21 $filename = 'books.xml';
22 $f = fopen($filename, 'r');
23 $contents = fread($f, filesize($filename));
24 fclose($f);
25
26 $dataManager = $aZorba->getXmlDataManager();
27 $docIter = $dataManager->parseXML($contents);
28 $docIter->open();
29
30 $doc = Item::createEmptyItem();
31 $docIter->next($doc);
32
33 $docIter->close();
34 $docIter->destroy();
35
36 $docManager = $dataManager->getDocumentManager();
37 $docManager->put("my_fake_books.xml", $doc);
38 $xquery = $aZorba->compileQuery("doc('my_fake_books.xml')");
39
40 $result = $xquery->execute();
41 print $result."\n";
42
43 return;
44}
45
46$store = InMemoryStore::getInstance();
47$zorba = Zorba::getInstance($store);
48
49print "Running: XQuery execute - parsing XML\n";
50test($zorba);
51print "Success";
52
53$zorba->shutdown();
54InMemoryStore::shutdown($store);
55
56?>
0\ No newline at end of file57\ No newline at end of file
158
=== added file 'swig/php/tests/test08.php'
--- swig/php/tests/test08.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test08.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,120 @@
1<?
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18require '@phpPath@/Zorba/zorba_api_wrapper.php';
19
20function println($string) {
21 print $string."\n";
22}
23
24function test(Zorba $aZorba) {
25 #Read and write result
26 println ("Executing: test08.xq");
27 $lines = '(1, xs:int(2),"bla", <a><b att="{(3, xs:int(4),"foo", "bar")}"/>text<!--a comment--><?pi?></a>)';
28 $xquery = $aZorba->compileQuery($lines);
29 $result = $xquery->execute();
30 println ($result);
31
32 println ("Iterator:");
33 $iterator = $xquery->iterator();
34
35 printIterator($iterator, "");
36
37 $handle = fopen('test8_result.xml', 'w');
38 fwrite($handle, $result);
39 fclose($handle);
40 return;
41}
42
43function printIterator($iterator, $pre) {
44 $item = Item::createEmptyItem();
45 $iterator->open();
46 while ($iterator->next($item)) {
47 printItem($item, $pre);
48 }
49 $iterator->close();
50}
51
52function printItem($item, $pre) {
53 if ($item->isAtomic()) {
54 $typeItem = $item->getType();
55 println ($pre . "Leaf Atomic: '" . $item->getStringValue() . "' \ttype:" . $typeItem->getStringValue());
56 return;
57 }
58
59 if ($item->isNode()) {
60 $kind = $item->getNodeKind();
61
62 if ($kind == 0) { # anyNode
63 println ($pre . 'Any node');
64 println ($pre . " Children:");
65 printIterator($item->getChildren() . $pre." ");
66 }
67 if ($kind == 1) { # doc
68 println ($pre . 'Doc');
69 println ($pre . " Children:");
70 printIterator($item->getChildren() . $pre." ");
71 }
72 if ($kind == 2) { # element
73 $nodeName = Item::createEmptyItem();
74 $item->getNodeName($nodeName);
75 $typeItem = $item->getType();
76 println ($pre . "Start Element: " . $nodeName->getStringValue() . " \ttype:" . $typeItem->getStringValue());
77 println ($pre . " Attributes:");
78 printIterator($item->getAttributes(), $pre." ");
79 println ($pre . " Children:");
80 printIterator($item->getChildren(), $pre." ");
81 println ($pre . "End Element: " . $nodeName->getStringValue());
82 }
83 if ($kind == 3) { # attribute
84 $nodeName = Item::createEmptyItem();
85 $item->getNodeName($nodeName);
86 $typeItem = $item->getType();
87 println ($pre . "Attribute: " . $nodeName->getStringValue() . "= '" . $item->getStringValue() . " \ttype:" . $typeItem->getStringValue());
88 println ($pre." Atomization value:");
89 printIterator($item->getAtomizationValue(), $pre." ");
90 }
91 if ($kind == 4) { # text
92 $typeItem = $item->getType();
93 println ($pre . "Text: " . $item->getStringValue() . " \ttype:" . $typeItem->getStringValue());
94 println ($pre." Atomization value:");
95 printIterator($item->getAtomizationValue(), $pre." ");
96 }
97 if ($kind == 5) { # pi
98 $nodeName = Item::createEmptyItem();
99 $item->getNodeName($nodeName);
100 println ($pre . "Pi: " . $nodeName->getStringValue());
101 }
102 if ($kind == 6) { # comment
103 println ($pre . "Comment: " . $item->getStringValue());
104 }
105 } else {
106 println ($pre."Item not Node, not Atomic");
107 }
108}
109
110$store = InMemoryStore::getInstance();
111$zorba = Zorba::getInstance($store);
112
113println ("Running: XQuery execute - Get Iterator and println (info from its items\n");
114test($zorba);
115println ("Success");
116
117$zorba->shutdown();
118InMemoryStore::shutdown($store);
119
120?>
0\ No newline at end of file121\ No newline at end of file
1122
=== added file 'swig/php/tests/test09.php'
--- swig/php/tests/test09.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test09.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,92 @@
1<?
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18require '@phpPath@/Zorba/zorba_api_wrapper.php';
19
20function test(Zorba $aZorba) {
21 $xquery = $aZorba->compileQuery("<a>text-a1<b at1='att1' at2='{1+2}'>text-b1</b>text-a2</a>");
22
23
24 $saxHandler = new SAX2ContentHandlerProxy();
25 $saxHandler->setStartDocumentHandler(startDocumentHandler);
26 $saxHandler->setEndDocumentHandler(endDocumentHandler);
27 $saxHandler->setStartElementHandler(startElementHandler);
28 $saxHandler->setEndElementHandler(endElementHandler);
29 $saxHandler->setCharactersHandler(charactersHandler);
30 $saxHandler->setProcessingInstructionHandler(processingInstructionHandler);
31 $saxHandler->setIgnorableWhitespaceHandler(ignorableWhitespaceHandler);
32 $saxHandler->setStartPrefixMappingHandler(startPrefixMappingHandler);
33 $saxHandler->setEndPrefixMappingHandler(endPrefixMappingHandler);
34 $saxHandler->setSkippedEntityHandler(skippedEntityHandler);
35 $xquery->executeSAX($saxHandler);
36
37 return;
38}
39
40function startDocumentHandler() {
41 print "Start Document";
42 return;
43}
44function endDocumentHandler() {
45 print "End Document";
46 return;
47}
48function startElementHandler($URI, $localName, $QName, $SAXAttributes) {
49 print "Start Element - " . $QName;
50 return;
51}
52function endElementHandler($URI, $localName, $QName) {
53 print "End Element - " . $QName;
54 return;
55}
56function charactersHandler($text) {
57 print "Characters - " . $text;
58 return;
59}
60function processingInstructionHandler($target, $data) {
61 print "Processing Instruction";
62 return;
63}
64function ignorableWhitespaceHandler($text) {
65 print "Ignorable Whitespace - " . $text;
66 return;
67}
68function startPrefixMappingHandler($prefix, $URI) {
69 print "Start Prefix Mapping - " . $prefix;
70 return;
71}
72function endPrefixMappingHandler($prefix) {
73 print "End Prefix Mapping - " . $prefix;
74 return;
75}
76function skippedEntityHandler($name) {
77 print "Skipped Entity - " . $name;
78 return;
79}
80
81
82$store = InMemoryStore::getInstance();
83$zorba = Zorba::getInstance($store);
84
85print "Running: XQuery execute - executeSAX\n";
86test($zorba);
87print "Success";
88
89$zorba->shutdown();
90InMemoryStore::shutdown($store);
91
92?>
0\ No newline at end of file93\ No newline at end of file
194
=== added file 'swig/php/tests/test10.php'
--- swig/php/tests/test10.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test10.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,55 @@
1<?
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18require '@phpPath@/Zorba/zorba_api_wrapper.php';
19
20function test(Zorba $aZorba) {
21 $filename = 'books.xml';
22 $f = fopen($filename, 'r');
23 $contents = fread($f, filesize($filename));
24 fclose($f);
25
26 $dataManager = $aZorba->getXmlDataManager();
27 $docIter = $dataManager->parseXML($contents);
28 $docIter->open();
29
30 $doc = Item::createEmptyItem();
31 $docIter->next($doc);
32
33 $docIter->close();
34 $docIter->destroy();
35
36 $xquery = $aZorba->compileQuery(".");
37 $dynCtx = $xquery->getDynamicContext();
38 $dynCtx->setContextItem($doc);
39 print $xquery->execute()."\n";
40
41 return;
42}
43
44
45$store = InMemoryStore::getInstance();
46$zorba = Zorba::getInstance($store);
47
48print "Running: XQuery execute - Get Iterator and print info from its items\n";
49test($zorba);
50print "Success";
51
52$zorba->shutdown();
53InMemoryStore::shutdown($store);
54
55?>
0\ No newline at end of file56\ No newline at end of file
157
=== added file 'swig/php/tests/test11.php'
--- swig/php/tests/test11.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test11.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,52 @@
1<?
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18//require '@phpPath@/Zorba/zorba_api_wrapper.php';
19require 'C:/dev/zapi/build/swig/php/Zorba/zorba_api_wrapper.php';
20
21class MyDiagnosticHandler(zorba_api.DiagnosticHandler):
22 def error(self, *args):
23 print "Error args: ", args
24
25def test(zorba):
26 #Read and write result
27 print 'Executing: compilerHints.xq'
28 f = open('compilerHints.xq', 'r')
29 lines = f.read()
30 f.close()
31 diagnosticHandler = MyDiagnosticHandler()
32 compilerHints = zorba_api.CompilerHints()
33 compilerHints.setOptimizationLevel(0)
34 xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler)
35
36 result = xquery.execute()
37 print result
38 return
39
40
41store = zorba_api.InMemoryStore_getInstance()
42zorba = zorba_api.Zorba_getInstance(store)
43
44print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 0"
45test(zorba)
46print "Success"
47
48
49zorba.shutdown()
50zorba_api.InMemoryStore_shutdown(store)
51
52?>
0\ No newline at end of file53\ No newline at end of file
154
=== added file 'swig/php/tests/test12.php'
--- swig/php/tests/test12.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test12.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,52 @@
1<?
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18//require '@phpPath@/Zorba/zorba_api_wrapper.php';
19require 'C:/dev/zapi/build/swig/php/Zorba/zorba_api_wrapper.php';
20
21class MyDiagnosticHandler(zorba_api.DiagnosticHandler):
22 def error(self, *args):
23 print "Error args: ", args
24
25def test(zorba):
26 #Read and write result
27 print 'Executing: compilerHints.xq'
28 f = open('compilerHints.xq', 'r')
29 lines = f.read()
30 f.close()
31 diagnosticHandler = MyDiagnosticHandler()
32 compilerHints = zorba_api.CompilerHints()
33 compilerHints.setOptimizationLevel(1)
34 xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler)
35
36 result = xquery.execute()
37 print result
38 return
39
40
41store = zorba_api.InMemoryStore_getInstance()
42zorba = zorba_api.Zorba_getInstance(store)
43
44print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 1"
45test(zorba)
46print "Success"
47
48
49zorba.shutdown()
50zorba_api.InMemoryStore_shutdown(store)
51
52?>
0\ No newline at end of file53\ No newline at end of file
154
=== added file 'swig/php/tests/test13.php'
--- swig/php/tests/test13.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test13.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,53 @@
1<?
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18//require '@phpPath@/Zorba/zorba_api_wrapper.php';
19require 'C:/dev/zapi/build/swig/php/Zorba/zorba_api_wrapper.php';
20
21class MyDiagnosticHandler(zorba_api.DiagnosticHandler):
22 def error(self, *args):
23 print "Error args: ", args
24
25def test(zorba):
26 #Read and write result
27 print 'Executing: compilerHints.xq'
28 f = open('compilerHints.xq', 'r')
29 lines = f.read()
30 f.close()
31 diagnosticHandler = MyDiagnosticHandler()
32 compilerHints = zorba_api.CompilerHints()
33 compilerHints.setLibModule(True)
34 compilerHints.setOptimizationLevel(0)
35 xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler)
36
37 result = xquery.execute()
38 print result
39 return
40
41
42store = zorba_api.InMemoryStore_getInstance()
43zorba = zorba_api.Zorba_getInstance(store)
44
45print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 0 - setLibModule(True)"
46test(zorba)
47print "Success"
48
49
50zorba.shutdown()
51zorba_api.InMemoryStore_shutdown(store)
52
53?>
0\ No newline at end of file54\ No newline at end of file
155
=== added file 'swig/php/tests/test14.php'
--- swig/php/tests/test14.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/test14.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,53 @@
1<?
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18//require '@phpPath@/Zorba/zorba_api_wrapper.php';
19require 'C:/dev/zapi/build/swig/php/Zorba/zorba_api_wrapper.php';
20
21class MyDiagnosticHandler(zorba_api.DiagnosticHandler):
22 def error(self, *args):
23 print "Error args: ", args
24
25def test(zorba):
26 #Read and write result
27 print 'Executing: compilerHints.xq'
28 f = open('compilerHints.xq', 'r')
29 lines = f.read()
30 f.close()
31 diagnosticHandler = MyDiagnosticHandler()
32 compilerHints = zorba_api.CompilerHints()
33 compilerHints.setLibModule(True)
34 compilerHints.setOptimizationLevel(1)
35 xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler)
36
37 result = xquery.execute()
38 print result
39 return
40
41
42store = zorba_api.InMemoryStore_getInstance()
43zorba = zorba_api.Zorba_getInstance(store)
44
45print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 1 - setLibModule(True)"
46test(zorba)
47print "Success"
48
49
50zorba.shutdown()
51zorba_api.InMemoryStore_shutdown(store)
52
53?>
0\ No newline at end of file54\ No newline at end of file
155
=== added file 'swig/php/tests/zorba_api.php'
--- swig/php/tests/zorba_api.php 1970-01-01 00:00:00 +0000
+++ swig/php/tests/zorba_api.php 2012-03-26 20:16:18 +0000
@@ -0,0 +1,178 @@
1<?php
2/*
3 * Copyright 2006-2012 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18// Try to load our extension if it's not already loaded.
19if (!extension_loaded("zorba_api")) {
20 if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
21 if (!dl('zorba_api.dll')) return;
22 } else {
23 // PHP_SHLIB_SUFFIX is available as of PHP 4.3.0, for older PHP assume 'so'.
24 // It gives 'dylib' on MacOS X which is for libraries, modules are 'so'.
25 if (PHP_SHLIB_SUFFIX === 'PHP_SHLIB_SUFFIX' || PHP_SHLIB_SUFFIX === 'dylib') {
26 if (!dl('zorba_api.so')) return;
27 } else {
28 if (!dl('zorba_api.'.PHP_SHLIB_SUFFIX)) return;
29 }
30 }
31}
32
33class Item {
34 public $_cPtr=null;
35
36 static function createEmptyItem() {
37 $r=Item_createEmptyItem();
38 return is_resource($r) ? new Item($r) : $r;
39 }
40
41 function getStringValue() {
42 return Item_getStringValue($this->_cPtr);
43 }
44
45 function __construct() {
46 $this->_cPtr=new_Item();
47 }
48}
49
50class Iterator {
51 public $_cPtr=null;
52
53 function open() {
54 Iterator_open($this->_cPtr);
55 }
56
57 function next($arg1) {
58 return Iterator_next($this->_cPtr,$arg1);
59 }
60
61 function close() {
62 Iterator_close($this->_cPtr);
63 }
64
65 function destroy() {
66 Iterator_destroy($this->_cPtr);
67 }
68
69 function __construct($cPtr) {
70 $this->_cPtr=$cPtr;
71 }
72
73 public function __destruct() {
74 $this->destroy();
75 }
76}
77
78class XQuery {
79 public $_cPtr=null;
80
81 function execute() {
82 return XQuery_execute($this->_cPtr);
83 }
84
85 function isUpdateQuery() {
86 return XQuery_isUpdateQuery($this->_cPtr);
87 }
88
89 function applyUpdates() {
90 XQuery_applyUpdates($this->_cPtr);
91 }
92
93 function destroy() {
94 XQuery_destroy($this->_cPtr);
95 }
96
97 function iterator() {
98 $r=XQuery_iterator($this->_cPtr);
99 return is_resource($r) ? new Iterator($r) : $r;
100 }
101
102 function __construct($cPtr) {
103 $this->_cPtr=$cPtr;
104 }
105
106 function __destruct() {
107 $this->destroy();
108 }
109}
110
111class Store {
112 //public $_cPtr=null;
113
114 //function __construct() {
115 // $this->_cPtr=new_Store();
116 //}
117}
118
119class InMemoryStore extends Store {
120 public $_cPtr=null;
121
122 static function getInstance() {
123 $r=InMemoryStore_getInstance();
124 return is_resource($r) ? new InMemoryStore($r) : $r;
125 }
126
127 static function shutdown($arg1) {
128 InMemoryStore_shutdown($arg1);
129 }
130
131 private function __construct($cPtr) {
132 $this->_cPtr=$cPtr;
133 }
134}
135
136class XmlDataManager {
137 public $_cPtr=null;
138
139 function loadDocument($aName,$aContent) {
140 XmlDataManager_loadDocument($this->_cPtr,$aName,$aContent);
141 }
142
143 function deleteDocument($aName) {
144 return XmlDataManager_deleteDocument($this->_cPtr,$aName);
145 }
146
147 function __construct($cPtr) {
148 $this->_cPtr=$cPtr;
149 }
150}
151
152class Zorba {
153 public $_cPtr=null;
154
155 static function getInstance($arg1) {
156 $r=Zorba_getInstance($arg1->_cPtr);
157 return is_resource($r) ? new Zorba($r) : $r;
158 }
159
160 function compileQuery($aStr) {
161 $r=Zorba_compileQuery($this->_cPtr,$aStr);
162 return is_resource($r) ? new XQuery($r) : $r;
163 }
164
165 function getXmlDataManager() {
166 $r=Zorba_getXmlDataManager($this->_cPtr);
167 return is_resource($r) ? new XmlDataManager($r) : $r;
168 }
169
170 function shutdown() {
171 Zorba_shutdown($this->_cPtr);
172 }
173
174 private function __construct($cPtr) {
175 $this->_cPtr=$cPtr;
176 }
177}
178?>
0179
=== modified file 'swig/python/CMakeLists.txt'
--- swig/python/CMakeLists.txt 2012-03-23 17:32:07 +0000
+++ swig/python/CMakeLists.txt 2012-03-26 20:16:18 +0000
@@ -20,8 +20,13 @@
20 SWIG_ADD_MODULE (zorba_api_python python zorba_api.i)20 SWIG_ADD_MODULE (zorba_api_python python zorba_api.i)
21 SWIG_LINK_LIBRARIES (zorba_api_python zorba_simplestore ${PYTHON_LIBRARIES})21 SWIG_LINK_LIBRARIES (zorba_api_python zorba_simplestore ${PYTHON_LIBRARIES})
22 SET_TARGET_PROPERTIES (_zorba_api_python PROPERTIES OUTPUT_NAME "_zorba_api")22 SET_TARGET_PROPERTIES (_zorba_api_python PROPERTIES OUTPUT_NAME "_zorba_api")
23 SET_PROPERTY( TARGET _zorba_api_python PROPERTY PROJECT_LABEL "Api_Python" )23
2424 IF (MSVC_IDE)
25 SET_PROPERTY( TARGET _zorba_api_python PROPERTY PROJECT_LABEL "Api_Python" )
26 SET_PROPERTY( TARGET _zorba_api_python PROPERTY LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/swig/python )
27 SET_PROPERTY( TARGET _zorba_api_python PROPERTY LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/swig/python )
28 ENDIF (MSVC_IDE)
29
25 EXECUTE_PROCESS (30 EXECUTE_PROCESS (
26 COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig;print sysconfig.get_python_lib(0)"31 COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig;print sysconfig.get_python_lib(0)"
27 OUTPUT_VARIABLE PYTHON_INSTALL_PATH32 OUTPUT_VARIABLE PYTHON_INSTALL_PATH
@@ -31,6 +36,18 @@
31 SET (PYTHON_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/share/python")36 SET (PYTHON_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/share/python")
32 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")37 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")
33 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")38 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")
39 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h")
40 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h")
41 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h")
42 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h")
43 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h")
44 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h")
45 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../SerializationOptions.h" "${CMAKE_CURRENT_BINARY_DIR}/SerializationOptions.h" COPYONLY)
46 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Collection.h" "${CMAKE_CURRENT_BINARY_DIR}/Collection.h" COPYONLY)
47 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY)
48 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY)
49 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY)
50
34 MESSAGE (STATUS "SWIG Python: Python module install path: " ${PYTHON_INSTALL_PATH})51 MESSAGE (STATUS "SWIG Python: Python module install path: " ${PYTHON_INSTALL_PATH})
3552
36 IF (NOT WIN32) 53 IF (NOT WIN32)
@@ -41,17 +58,10 @@
41 DESTINATION ${PYTHON_INSTALL_PATH}58 DESTINATION ${PYTHON_INSTALL_PATH}
42 )59 )
43 ELSE(NOT WIN32)60 ELSE(NOT WIN32)
44 IF (MSVC_IDE)
45 INSTALL ( FILES
46 ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/_zorba_api.pyd
47 DESTINATION share/python
48 COMPONENT "python_swig" )
49 ELSE (MSVC_IDE)
50 INSTALL ( FILES 61 INSTALL ( FILES
51 ${CMAKE_CURRENT_BINARY_DIR}/_zorba_api.pyd62 ${CMAKE_CURRENT_BINARY_DIR}/_zorba_api.pyd
52 DESTINATION share/python63 DESTINATION share/python
53 COMPONENT "python_swig" )64 COMPONENT "python_swig" )
54 ENDIF (MSVC_IDE)
55 ENDIF(NOT WIN32)65 ENDIF(NOT WIN32)
56 66
57 ADD_SUBDIRECTORY (tests)67 ADD_SUBDIRECTORY (tests)
5868
=== modified file 'swig/ruby/CMakeLists.txt'
--- swig/ruby/CMakeLists.txt 2012-03-23 17:32:07 +0000
+++ swig/ruby/CMakeLists.txt 2012-03-26 20:16:18 +0000
@@ -23,8 +23,9 @@
23 IF (WIN32)23 IF (WIN32)
24 SWIG_ADD_MODULE(zorba_api_ruby ruby zorba_api.i)24 SWIG_ADD_MODULE(zorba_api_ruby ruby zorba_api.i)
25 SWIG_LINK_LIBRARIES(zorba_api_ruby zorba_simplestore ${RUBY_LIBRARY})25 SWIG_LINK_LIBRARIES(zorba_api_ruby zorba_simplestore ${RUBY_LIBRARY})
26 SET_TARGET_PROPERTIES (zorba_api_ruby PROPERTIES OUTPUT_NAME "zorba_api")26 SET_TARGET_PROPERTIES( zorba_api_ruby PROPERTIES OUTPUT_NAME "zorba_api")
27 SET_TARGET_PROPERTIES( zorba_api_ruby PROPERTIES PROJECT_LABEL "Api_Ruby" )27 SET_TARGET_PROPERTIES( zorba_api_ruby PROPERTIES PROJECT_LABEL "Api_Ruby" )
28 SET_TARGET_PROPERTIES( zorba_api_ruby PROPERTIES SUFFIX ".so" )
28 ELSE (WIN32)29 ELSE (WIN32)
29 SWIG_ADD_MODULE(zorba_api ruby zorba_api.i)30 SWIG_ADD_MODULE(zorba_api ruby zorba_api.i)
30 SWIG_LINK_LIBRARIES(zorba_api zorba_simplestore ${RUBY_LIBRARY})31 SWIG_LINK_LIBRARIES(zorba_api zorba_simplestore ${RUBY_LIBRARY})
@@ -52,7 +53,18 @@
52 #STRING(REPLACE "/usr/" "" RUBY_SITEARCH_DIR "${RUBY_SITEARCH_DIR}" )53 #STRING(REPLACE "/usr/" "" RUBY_SITEARCH_DIR "${RUBY_SITEARCH_DIR}" )
53 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")54 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")
54 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")55 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")
55 56 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h")
57 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h")
58 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h")
59 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h")
60 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h")
61 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h")
62 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../SerializationOptions.h" "${CMAKE_CURRENT_BINARY_DIR}/SerializationOptions.h" COPYONLY)
63 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Collection.h" "${CMAKE_CURRENT_BINARY_DIR}/Collection.h" COPYONLY)
64 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY)
65 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY)
66 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY)
67
56 SET (RUBY_SITEARCH_DIR "${CMAKE_INSTALL_PREFIX}/share/ruby")68 SET (RUBY_SITEARCH_DIR "${CMAKE_INSTALL_PREFIX}/share/ruby")
57 69
58 IF ( APPLE )70 IF ( APPLE )
@@ -77,6 +89,8 @@
77 ENDIF ( LINUX )89 ENDIF ( LINUX )
78 ENDIF ( APPLE )90 ENDIF ( APPLE )
7991
92 ADD_SUBDIRECTORY (tests)
93
80ELSE (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)94ELSE (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
81 MESSAGE(STATUS "SWIG Ruby: binding not generated because library and include files are not installed.")95 MESSAGE(STATUS "SWIG Ruby: binding not generated because library and include files are not installed.")
82ENDIF (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)96ENDIF (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
8397
=== added directory 'swig/ruby/tests'
=== added file 'swig/ruby/tests/CMakeLists.txt'
--- swig/ruby/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/CMakeLists.txt 2012-03-26 20:16:18 +0000
@@ -0,0 +1,83 @@
1# Copyright 2006-2011 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14MESSAGE(STATUS "Adding tests for Ruby Binding")
15
16IF (MSVC_IDE)
17 SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby/@CMAKE_BUILD_TYPE@)
18ELSE (MSVC_IDE)
19 SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby)
20ENDIF (MSVC_IDE)
21
22CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/books.xml ${CMAKE_CURRENT_BINARY_DIR}/books.xml COPYONLY)
23CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/compilerHints.xq ${CMAKE_CURRENT_BINARY_DIR}/compilerHints.xq COPYONLY)
24
25CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test01.rb ${CMAKE_CURRENT_BINARY_DIR}/test01.rb)
26ADD_TEST("ruby_test01" ${RUBY_EXECUTABLE} test01.rb)
27SET_TESTS_PROPERTIES("ruby_test01" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
28
29CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test02.rb ${CMAKE_CURRENT_BINARY_DIR}/test02.rb)
30ADD_TEST("ruby_test02" ${RUBY_EXECUTABLE} test02.rb)
31SET_TESTS_PROPERTIES("ruby_test02" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
32
33#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test03.rb ${CMAKE_CURRENT_BINARY_DIR}/test03.rb)
34#ADD_TEST("ruby_test03" ${RUBY_EXECUTABLE} test03.rb)
35#SET_TESTS_PROPERTIES("ruby_test03" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
36
37CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test04.rb ${CMAKE_CURRENT_BINARY_DIR}/test04.rb)
38ADD_TEST("ruby_test04" ${RUBY_EXECUTABLE} test04.rb)
39CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test04.xq ${CMAKE_CURRENT_BINARY_DIR}/test04.xq COPYONLY)
40SET_TESTS_PROPERTIES("ruby_test04" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
41
42CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test05.rb ${CMAKE_CURRENT_BINARY_DIR}/test05.rb)
43ADD_TEST("ruby_test05" ${RUBY_EXECUTABLE} test05.rb)
44CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test05.xq ${CMAKE_CURRENT_BINARY_DIR}/test05.xq COPYONLY)
45SET_TESTS_PROPERTIES("ruby_test05" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
46
47CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test06.rb ${CMAKE_CURRENT_BINARY_DIR}/test06.rb)
48ADD_TEST("ruby_test06" ${RUBY_EXECUTABLE} test06.rb)
49CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test06.xq ${CMAKE_CURRENT_BINARY_DIR}/test06.xq COPYONLY)
50SET_TESTS_PROPERTIES("ruby_test06" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
51
52CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test07.rb ${CMAKE_CURRENT_BINARY_DIR}/test07.rb)
53ADD_TEST("ruby_test07" ${RUBY_EXECUTABLE} test07.rb)
54SET_TESTS_PROPERTIES("ruby_test07" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
55
56# CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test08.rb ${CMAKE_CURRENT_BINARY_DIR}/test08.rb)
57# ADD_TEST("ruby_test08" ${RUBY_EXECUTABLE} test08.rb)
58# SET_TESTS_PROPERTIES("ruby_test08" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
59
60# CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test09.rb ${CMAKE_CURRENT_BINARY_DIR}/test09.rb)
61# ADD_TEST("ruby_test09" ${RUBY_EXECUTABLE} test09.rb)
62# SET_TESTS_PROPERTIES("ruby_test09" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
63
64CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test10.rb ${CMAKE_CURRENT_BINARY_DIR}/test10.rb)
65ADD_TEST("ruby_test10" ${RUBY_EXECUTABLE} test10.rb)
66SET_TESTS_PROPERTIES("ruby_test10" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
67
68#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test11.rb ${CMAKE_CURRENT_BINARY_DIR}/test11.rb)
69#ADD_TEST("ruby_test11" ${RUBY_EXECUTABLE} test11.rb)
70#SET_TESTS_PROPERTIES("ruby_test11" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
71
72#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test12.rb ${CMAKE_CURRENT_BINARY_DIR}/test12.rb)
73#ADD_TEST("ruby_test12" ${RUBY_EXECUTABLE} test12.rb)
74#SET_TESTS_PROPERTIES("ruby_test12" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
75
76#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test13.rb ${CMAKE_CURRENT_BINARY_DIR}/test13.rb)
77#ADD_TEST("ruby_test13" ${RUBY_EXECUTABLE} test13.rb)
78#SET_TESTS_PROPERTIES("ruby_test13" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
79
80#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test14.rb ${CMAKE_CURRENT_BINARY_DIR}/test14.rb)
81#ADD_TEST("ruby_test14" ${RUBY_EXECUTABLE} test14.rb)
82#SET_TESTS_PROPERTIES("ruby_test14" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
83
084
=== added file 'swig/ruby/tests/books.xml'
--- swig/ruby/tests/books.xml 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/books.xml 2012-03-26 20:16:18 +0000
@@ -0,0 +1,11 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2<books>
3 <book>
4 <title>Book 1</title>
5 <author>Author 1</author>
6 </book>
7 <book featured="YES">
8 <title>Book 2</title>
9 <author>Author 2</author>
10 </book>
11</books>
012
=== added file 'swig/ruby/tests/compilerHints.xq'
--- swig/ruby/tests/compilerHints.xq 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/compilerHints.xq 2012-03-26 20:16:18 +0000
@@ -0,0 +1,4 @@
1for tumbling window $w in (2, 4, 6, 8, 10, 12, 14)
2 start at $s when fn:true()
3 only end at $e when $e - $s eq 2
4return avg($w)
05
=== added file 'swig/ruby/tests/test01.rb'
--- swig/ruby/tests/test01.rb 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/test01.rb 2012-03-26 20:16:18 +0000
@@ -0,0 +1,24 @@
1# Copyright 2006-2012 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15require '@rubyPath@/zorba_api'
16
17print "Running: Get zorba instance and shutdown"
18
19store = Zorba_api::InMemoryStore.getInstance()
20zorba = Zorba_api::Zorba.getInstance(store)
21zorba.shutdown()
22Zorba_api::InMemoryStore.shutdown(store)
23
24print "Success"
025
=== added file 'swig/ruby/tests/test02.rb'
--- swig/ruby/tests/test02.rb 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/test02.rb 2012-03-26 20:16:18 +0000
@@ -0,0 +1,39 @@
1# Copyright 2006-2012 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15require '@rubyPath@/zorba_api'
16
17def test(zorba)
18 xquery = zorba.compileQuery("(1,2,3,4,5)")
19 iter = xquery.iterator()
20 iter.open()
21 item = Zorba_api::Item.createEmptyItem()
22 while iter.next(item) do
23 print item.getStringValue()
24 print "\n"
25 end
26 iter.close()
27 iter.destroy()
28 xquery.destroy()
29end
30
31store = Zorba_api::InMemoryStore.getInstance()
32zorba = Zorba_api::Zorba.getInstance(store)
33
34print "Running: Compile query string"
35test(zorba)
36print "Success"
37
38zorba.shutdown()
39Zorba_api::InMemoryStore.shutdown(store)
040
=== added file 'swig/ruby/tests/test03.rb'
--- swig/ruby/tests/test03.rb 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/test03.rb 2012-03-26 20:16:18 +0000
@@ -0,0 +1,43 @@
1# Copyright 2006-2012 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15require '@rubyPath@/zorba_api'
16
17class MyDiagnosticHandler < Zorba_api.DiagnosticHandler
18 def error(self, *args)
19 print "Error args: " + args
20 end
21end
22
23def test(zorba):
24 diagnosticHandler = MyDiagnosticHandler.new
25 begin
26 xquery = zorba.compileQuery("1 div 0", diagnosticHandler)
27 print xquery.execute()
28 rescue => e
29 print "Caught error: " + e.message
30 ensure
31 xquery.destroy()
32 end
33end
34
35store = Zorba_api::InMemoryStore.getInstance()
36zorba = Zorba_api::Zorba.getInstance(store)
37
38print "Running: Capturing error with DiagnosticHandler"
39test(zorba)
40print "Success"
41
42zorba.shutdown()
43Zorba_api::InMemoryStore.shutdown(store)
044
=== added file 'swig/ruby/tests/test04.rb'
--- swig/ruby/tests/test04.rb 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/test04.rb 2012-03-26 20:16:18 +0000
@@ -0,0 +1,35 @@
1# Copyright 2006-2012 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15require '@rubyPath@/zorba_api'
16
17def test(zorba)
18 print 'Executing: test04.xq'
19 file = File.open("test04.xq", "rb")
20 contents = file.read
21 xquery = zorba.compileQuery(contents)
22 result = xquery.execute()
23 print result
24 xquery.destroy()
25end
26
27store = Zorba_api::InMemoryStore.getInstance()
28zorba = Zorba_api::Zorba.getInstance(store)
29
30print "Running: XQuery execute"
31test(zorba)
32print "Success"
33
34zorba.shutdown()
35Zorba_api::InMemoryStore.shutdown(store)
036
=== added file 'swig/ruby/tests/test04.xq'
--- swig/ruby/tests/test04.xq 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/test04.xq 2012-03-26 20:16:18 +0000
@@ -0,0 +1,4 @@
1for tumbling window $w in (2, 4, 6, 8, 10, 12, 14)
2 start at $s when fn:true()
3 only end at $e when $e - $s eq 2
4return avg($w)
05
=== added file 'swig/ruby/tests/test05.rb'
--- swig/ruby/tests/test05.rb 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/test05.rb 2012-03-26 20:16:18 +0000
@@ -0,0 +1,35 @@
1# Copyright 2006-2011 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15require '@rubyPath@/zorba_api'
16
17def test(zorba)
18 print 'Executing: test05.xq'
19 file = File.open("test05.xq", "rb")
20 contents = file.read
21 xquery = zorba.compileQuery(contents)
22 result = xquery.printPlanAsXML()
23 print result
24 xquery.destroy()
25end
26
27store = Zorba_api::InMemoryStore.getInstance()
28zorba = Zorba_api::Zorba.getInstance(store)
29
30print "Running: XQuery execute - printPlanAsXML"
31test(zorba)
32print "Success"
33
34zorba.shutdown()
35Zorba_api::InMemoryStore.shutdown(store)
036
=== added file 'swig/ruby/tests/test05.xq'
--- swig/ruby/tests/test05.xq 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/test05.xq 2012-03-26 20:16:18 +0000
@@ -0,0 +1,7 @@
1for $x in (5,6,7,1,2,3,4)
2where $x < 4
3for $y in (4,9,6,8,2)
4let $z := $x * $y
5where $z > 20
6return
7<value x="{$x}" y="{$y}">{$z}</value>
0\ No newline at end of file8\ No newline at end of file
19
=== added file 'swig/ruby/tests/test06.rb'
--- swig/ruby/tests/test06.rb 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/test06.rb 2012-03-26 20:16:18 +0000
@@ -0,0 +1,35 @@
1# Copyright 2006-2011 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15require '@rubyPath@/zorba_api'
16
17def test(zorba)
18 print 'Executing: test06.xq'
19 file = File.open("test06.xq", "rb")
20 contents = file.read
21 xquery = zorba.compileQuery(contents)
22 result = xquery.printPlanAsDOT()
23 print result
24 xquery.destroy()
25end
26
27store = Zorba_api::InMemoryStore.getInstance()
28zorba = Zorba_api::Zorba.getInstance(store)
29
30print "Running: XQuery execute - printPlanAsDOT"
31test(zorba)
32print "Success"
33
34zorba.shutdown()
35Zorba_api::InMemoryStore.shutdown(store)
036
=== added file 'swig/ruby/tests/test06.xq'
--- swig/ruby/tests/test06.xq 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/test06.xq 2012-03-26 20:16:18 +0000
@@ -0,0 +1,7 @@
1for $x in (5,6,7,1,2,3,4)
2where $x < 4
3for $y in (4,9,6,8,2)
4let $z := $x * $y
5where $z > 20
6return
7<value x="{$x}" y="{$y}">{$z}</value>
0\ No newline at end of file8\ No newline at end of file
19
=== added file 'swig/ruby/tests/test07.rb'
--- swig/ruby/tests/test07.rb 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/test07.rb 2012-03-26 20:16:18 +0000
@@ -0,0 +1,48 @@
1# Copyright 2006-2011 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15require '@rubyPath@/zorba_api'
16
17def test(zorba)
18 file = File.open("books.xml", "rb")
19 contents = file.read
20
21 dataManager = zorba.getXmlDataManager()
22 docIter = dataManager.parseXML(contents)
23 docIter.open()
24
25 doc = Zorba_api::Item.createEmptyItem()
26 docIter.next(doc)
27
28 docIter.close()
29 docIter.destroy()
30
31 docManager = dataManager.getDocumentManager()
32 docManager.put("my_fake_books.xml", doc)
33 xquery = zorba.compileQuery("doc('my_fake_books.xml')")
34
35 result = xquery.execute()
36 print result
37 xquery.destroy()
38end
39
40store = Zorba_api::InMemoryStore.getInstance()
41zorba = Zorba_api::Zorba.getInstance(store)
42
43print "Running: XQuery execute - parsing XML"
44test(zorba)
45print "Success"
46
47zorba.shutdown()
48Zorba_api::InMemoryStore.shutdown(store)
049
=== added file 'swig/ruby/tests/test08.rb'
--- swig/ruby/tests/test08.rb 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/test08.rb 2012-03-26 20:16:18 +0000
@@ -0,0 +1,108 @@
1# Copyright 2006-2011 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15require '@rubyPath@/zorba_api'
16
17def test(zorba)
18 print 'Executing: test08.xq' + "\n"
19 lines = '(1, xs:int(2),"bla", <a><b att="{(3, xs:int(4),"foo", "bar")}"/>text<!--a comment--><?pi?></a>)'
20 xquery = zorba.compileQuery(lines)
21 result = xquery.execute()
22 print result + "\n"
23
24 print "Iterator:" + "\n"
25 iterator = xquery.iterator()
26 printIterator(iterator, "")
27 xquery.destroy()
28
29end
30
31
32def printIterator(iterator, pre)
33 item = Zorba_api::Item.createEmptyItem()
34 iterator.open()
35 while iterator.next(item)
36 printItem(item, pre)
37 end
38 iterator.close()
39 iterator.destroy()
40end
41
42def printItem(item, pre)
43 if item.isAtomic():
44 typeItem = item.getType()
45 print pre + "Leaf Atomic: '" + item.getStringValue() + "' \ttype:", typeItem.getStringValue() + "\n"
46 return
47 end
48
49 if item.isNode():
50 kind = item.getNodeKind()
51
52 if kind == 0 # anyNode
53 print pre + 'Any node' + "\n"
54 print pre + " Children:" + "\n"
55 printIterator(item.getChildren(), pre+" ")
56 end
57 if kind == 1 # doc
58 print pre + 'Doc' + "\n"
59 print pre + " Children:" + "\n"
60 printIterator(item.getChildren(), pre+" ")
61 end
62 if kind == 2 # element
63 nodeName = Zorba_api::Item.createEmptyItem()
64 item.getNodeName(nodeName)
65 typeItem = item.getType()
66 print pre + "Start Element: ", nodeName.getStringValue() + " \ttype:", typeItem.getStringValue() + "\n"
67 print pre + " Attributes:" + "\n"
68 printIterator(item.getAttributes(), pre+" ")
69 print pre + " Children:" + "\n"
70 printIterator(item.getChildren(), pre+" ")
71 print pre + "End Element: " + nodeName.getStringValue() + "\n"
72 end
73 if kind == 3 # attribute
74 nodeName = Zorba_api::Item.createEmptyItem()
75 item.getNodeName(nodeName)
76 typeItem = item.getType()
77 print pre + "Attribute: " + nodeName.getStringValue() + "= '" + item.getStringValue() + "'"" \ttype:" + typeItem.getStringValue() + "\n"
78 print pre+" Atomization value:" + "\n"
79 printIterator(item.getAtomizationValue(), pre+" ")
80 end
81 if kind == 4 # text
82 typeItem = item.getType()
83 print pre + "Text: " + item.getStringValue() + " \ttype:", typeItem.getStringValue() + "\n"
84 print pre+" Atomization value:" + "\n"
85 printIterator(item.getAtomizationValue(), pre+" ")
86 end
87 if kind == 5 # pi
88 nodeName = Zorba_api::Item.createEmptyItem()
89 item.getNodeName(nodeName)
90 print pre + "Pi: " + nodeName.getStringValue() + "\n"
91 end
92 if kind == 6 # comment
93 print pre + "Comment: " + item.getStringValue() + "\n"
94 end
95 else
96 print pre+"Item not Node, not Atomic" + "\n"
97 end
98end
99
100store = Zorba_api::InMemoryStore.getInstance()
101zorba = Zorba_api::Zorba.getInstance(store)
102
103print "Running: XQuery execute - Get Iterator and print info from its items" + "\n"
104test(zorba)
105print "Success" + "\n"
106
107zorba.shutdown()
108Zorba_api::InMemoryStore.shutdown(store)
0109
=== added file 'swig/ruby/tests/test09.rb'
--- swig/ruby/tests/test09.rb 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/test09.rb 2012-03-26 20:16:18 +0000
@@ -0,0 +1,81 @@
1# Copyright 2006-2011 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import sys
16sys.path.insert(0, '@pythonPath@')
17import zorba_api
18
19
20def test(zorba)
21 xquery = zorba.compileQuery("<a>text-a1<b at1='att1' at2='{1+2}'>text-b1</b>text-a2</a>")
22
23 saxHandler = zorba_api.SAX2ContentHandlerProxy()
24 saxHandler.setStartDocumentHandler(startDocumentHandler);
25 saxHandler.setEndDocumentHandler(endDocumentHandler);
26 saxHandler.setStartElementHandler(startElementHandler);
27 saxHandler.setEndElementHandler(endElementHandler);
28 saxHandler.setCharactersHandler(charactersHandler);
29 saxHandler.setProcessingInstructionHandler(processingInstructionHandler);
30 saxHandler.setIgnorableWhitespaceHandler(ignorableWhitespaceHandler);
31 saxHandler.setStartPrefixMappingHandler(startPrefixMappingHandler);
32 saxHandler.setEndPrefixMappingHandler(endPrefixMappingHandler);
33 saxHandler.setSkippedEntityHandler(skippedEntityHandler);
34 xquery.executeSAX(saxHandler)
35
36 return
37
38
39def startDocumentHandler():
40 print "Start Document"
41 return
42def endDocumentHandler():
43 print "End Document"
44 return
45def startElementHandler(URI, localName, QName, SAXAttributes):
46 print "Start Element - ", QName
47 return
48def endElementHandler(URI, localName, QName):
49 print "End Element - ", QName
50 return
51def charactersHandler(text):
52 print "Characters - ", text
53 return
54def processingInstructionHandler(target, data):
55 print "Processing Instruction"
56 return
57def ignorableWhitespaceHandler(text):
58 print "Ignorable Whitespace - ", text
59 return
60def startPrefixMappingHandler(prefix, URI):
61 print "Start Prefix Mapping - ", prefix
62 return
63def endPrefixMappingHandler(prefix):
64 print "End Prefix Mapping - ", prefix
65 return
66def skippedEntityHandler(name):
67 print "Skipped Entity - ", name
68 return
69
70
71store = zorba_api.InMemoryStore_getInstance()
72zorba = zorba_api.Zorba_getInstance(store)
73
74print "Running: XQuery execute - executeSAX"
75test(zorba)
76print "Success"
77
78
79zorba.shutdown()
80zorba_api.InMemoryStore_shutdown(store)
81
082
=== added file 'swig/ruby/tests/test10.rb'
--- swig/ruby/tests/test10.rb 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/test10.rb 2012-03-26 20:16:18 +0000
@@ -0,0 +1,46 @@
1# Copyright 2006-2011 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15require '@rubyPath@/zorba_api'
16
17def test(zorba)
18 file = File.open("books.xml", "rb")
19 contents = file.read
20
21 dataManager = zorba.getXmlDataManager()
22 docIter = dataManager.parseXML(contents)
23 docIter.open();
24
25 doc = Zorba_api::Item.createEmptyItem()
26 docIter.next(doc)
27
28 docIter.close()
29 docIter.destroy()
30
31 xquery = zorba.compileQuery(".")
32 dynCtx = xquery.getDynamicContext()
33 dynCtx.setContextItem(doc)
34 print xquery.execute()
35 xquery.destroy()
36end
37
38store = Zorba_api::InMemoryStore.getInstance()
39zorba = Zorba_api::Zorba.getInstance(store)
40
41print "Running: XQuery execute - Get Iterator and print info from its items"
42test(zorba)
43print "Success"
44
45zorba.shutdown()
46Zorba_api::InMemoryStore.shutdown(store)
047
=== added file 'swig/ruby/tests/test11.rb'
--- swig/ruby/tests/test11.rb 1970-01-01 00:00:00 +0000
+++ swig/ruby/tests/test11.rb 2012-03-26 20:16:18 +0000
@@ -0,0 +1,49 @@
1# Copyright 2006-2011 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches