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

Proposed by Rodolfo Ochoa on 2012-02-13
Status: Merged
Approved by: Rodolfo Ochoa on 2012-03-26
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 2012-02-13 Approve on 2012-03-24
Rodolfo Ochoa Approve on 2012-03-21
Cezar Andrei 2012-02-13 Approve on 2012-02-17
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.
Cezar Andrei (cezar-andrei) wrote :

Looks good.

review: Approve
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

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

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.

review: Approve
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!

Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 1 Approve, 2 Pending.

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
Rodolfo Ochoa (rodolfo-ochoa) wrote :

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

review: Approve
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

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!

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.

- 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
review: Approve
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 on 2012-03-26
10674. By Rodolfo Ochoa on 2012-03-26

-Solved conflict with Changelog

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
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-03-26 19:41:44 +0000
3+++ ChangeLog 2012-03-26 20:16:18 +0000
4@@ -1,10 +1,15 @@
5 Zorba - The XQuery Processor
6
7 version 2.5
8+
9+New Features:
10+ * Extended API for Python, Java, PHP and Ruby.
11+
12+Bug Fixes/Other Changes:
13 * Fixed bug in window iterator
14 * Fixed bug #872234 (prevent a rewritting to take place in case of sequential expr)
15
16-
17+
18 version 2.2
19
20 New Features:
21
22=== modified file 'doc/php/examples/CMakeLists.txt'
23--- doc/php/examples/CMakeLists.txt 2012-03-23 17:32:07 +0000
24+++ doc/php/examples/CMakeLists.txt 2012-03-26 20:16:18 +0000
25@@ -18,7 +18,11 @@
26
27 SET(phpPath ${CMAKE_BINARY_DIR}/swig/php)
28 MESSAGE(STATUS "PHP Path:" ${phpPath})
29- SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php)
30+ IF (MSVC_IDE)
31+ SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php/@CMAKE_BUILD_TYPE@)
32+ ELSE (MSVC_IDE)
33+ SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php)
34+ ENDIF (MSVC_IDE)
35 MESSAGE(STATUS "PHP Extension Path: " ${phpExtensionPath})
36 SET(phpIncludePath ${CMAKE_BINARY_DIR}/swig/php)
37 MESSAGE(STATUS "PHP Include Path: " ${phpExtensionPath})
38
39=== modified file 'doc/php/examples/zorba_api.php'
40--- doc/php/examples/zorba_api.php 2012-03-23 17:32:07 +0000
41+++ doc/php/examples/zorba_api.php 2012-03-26 20:16:18 +0000
42@@ -18,7 +18,7 @@
43 // Try to load our extension if it's not already loaded.
44 if (!extension_loaded("zorba_api")) {
45 if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
46- if (!dl('php_zorba_api.dll')) return;
47+ if (!dl('zorba_api.dll')) return;
48 } else {
49 // PHP_SHLIB_SUFFIX is available as of PHP 4.3.0, for older PHP assume 'so'.
50 // It gives 'dylib' on MacOS X which is for libraries, modules are 'so'.
51
52=== modified file 'doc/ruby/examples/CMakeLists.txt'
53--- doc/ruby/examples/CMakeLists.txt 2012-03-23 17:32:07 +0000
54+++ doc/ruby/examples/CMakeLists.txt 2012-03-26 20:16:18 +0000
55@@ -18,7 +18,12 @@
56 IF (NOT RUBY_EXECUTABLE)
57 MESSAGE(STATUS "Ruby test not added because Ruby Interpreter not found.")
58 ELSE (NOT RUBY_EXECUTABLE)
59- SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby)
60+ MESSAGE(STATUS "RUBY_EXECUTABLE: " ${RUBY_EXECUTABLE})
61+ IF (MSVC_IDE)
62+ SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby/@CMAKE_BUILD_TYPE@)
63+ ELSE (MSVC_IDE)
64+ SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby)
65+ ENDIF (MSVC_IDE)
66 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/ruby_test.rb.in ${CMAKE_CURRENT_BINARY_DIR}/ruby_test.rb)
67 ADD_TEST("ruby" ${RUBY_EXECUTABLE} ruby_test.rb)
68 ENDIF(NOT RUBY_EXECUTABLE)
69
70=== added file 'swig/Collection.h'
71--- swig/Collection.h 1970-01-01 00:00:00 +0000
72+++ swig/Collection.h 2012-03-26 20:16:18 +0000
73@@ -0,0 +1,47 @@
74+/*
75+ * Copyright 2006-2012 The FLWOR Foundation.
76+ *
77+ * Licensed under the Apache License, Version 2.0 (the "License");
78+ * you may not use this file except in compliance with the License.
79+ * You may obtain a copy of the License at
80+ *
81+ * http://www.apache.org/licenses/LICENSE-2.0
82+ *
83+ * Unless required by applicable law or agreed to in writing, software
84+ * distributed under the License is distributed on an "AS IS" BASIS,
85+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
86+ * See the License for the specific language governing permissions and
87+ * limitations under the License.
88+ */
89+#ifndef API_COLLECTION_H
90+#define API_COLLECTION_H
91+
92+class Collection
93+{
94+private:
95+ zorba::Collection* theCollection;
96+
97+public:
98+ Collection() : theCollection(0) {}
99+ Collection(const Collection& aMgr) : theCollection(aMgr.theCollection) {}
100+ Collection(zorba::Collection* aMgr) : theCollection(aMgr) {}
101+
102+ ItemSequence contents();
103+ void deleteNodeFirst();
104+ void deleteNodeLast();
105+ void deleteNodes(const ItemSequence &aNodes );
106+ void deleteNodesFirst(unsigned long aNumNodes );
107+ void deleteNodesLast(unsigned long aNumNodes );
108+ //std::vector< Annotation > getAnnotations():
109+ Item getName();
110+ TypeIdentifier getType();
111+ long long indexOf(const Item &aNode );
112+ void insertNodesAfter(const Item &aTarget, const ItemSequence &aNodes );
113+ void insertNodesBefore(const Item &aTarget, const ItemSequence &aNodes );
114+ void insertNodesFirst(const ItemSequence &aNodes );
115+ void insertNodesLast(const ItemSequence &aNodes );
116+ bool isStatic();
117+ //void registerDiagnosticHandler(DiagnosticHandler *aDiagnosticHandler );
118+};
119+
120+#endif
121\ No newline at end of file
122
123=== added file 'swig/Collection.i'
124--- swig/Collection.i 1970-01-01 00:00:00 +0000
125+++ swig/Collection.i 2012-03-26 20:16:18 +0000
126@@ -0,0 +1,91 @@
127+/*
128+ * Copyright 2006-2012 The FLWOR Foundation.
129+ *
130+ * Licensed under the Apache License, Version 2.0 (the "License");
131+ * you may not use this file except in compliance with the License.
132+ * You may obtain a copy of the License at
133+ *
134+ * http://www.apache.org/licenses/LICENSE-2.0
135+ *
136+ * Unless required by applicable law or agreed to in writing, software
137+ * distributed under the License is distributed on an "AS IS" BASIS,
138+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139+ * See the License for the specific language governing permissions and
140+ * limitations under the License.
141+ */
142+
143+%{ // start Implementation
144+
145+ ItemSequence Collection::contents()
146+ {
147+ return ItemSequence( theCollection->contents() );
148+ }
149+
150+ void Collection::deleteNodeFirst()
151+ {
152+ theCollection->deleteNodeFirst();
153+ }
154+
155+ void Collection::deleteNodeLast()
156+ {
157+ theCollection->deleteNodeLast();
158+ }
159+
160+ void Collection::deleteNodes(const ItemSequence &aNodes )
161+ {
162+ theCollection->deleteNodes( aNodes.theItemSequence );
163+ }
164+
165+ void Collection::deleteNodesFirst(unsigned long aNumNodes )
166+ {
167+ theCollection->deleteNodesFirst(aNumNodes);
168+ }
169+
170+ void Collection::deleteNodesLast(unsigned long aNumNodes )
171+ {
172+ theCollection->deleteNodesLast(aNumNodes);
173+ }
174+
175+ Item Collection::getName()
176+ {
177+ return Item( theCollection->getName() );
178+ }
179+
180+ TypeIdentifier Collection::getType()
181+ {
182+ return TypeIdentifier( theCollection->getType() );
183+ }
184+
185+ long long Collection::indexOf(const Item &aNode )
186+ {
187+ return theCollection->indexOf( aNode.theItem );
188+ }
189+
190+ void Collection::insertNodesAfter(const Item &aTarget, const ItemSequence &aNodes )
191+ {
192+ theCollection->insertNodesAfter( aTarget.theItem, aNodes.theItemSequence );
193+ }
194+
195+ void Collection::insertNodesBefore(const Item &aTarget, const ItemSequence &aNodes )
196+ {
197+ theCollection->insertNodesBefore( aTarget.theItem, aNodes.theItemSequence );
198+ }
199+
200+ void Collection::insertNodesFirst(const ItemSequence &aNodes )
201+ {
202+ theCollection->insertNodesFirst( aNodes.theItemSequence );
203+ }
204+
205+ void Collection::insertNodesLast(const ItemSequence &aNodes )
206+ {
207+ theCollection->insertNodesLast( aNodes.theItemSequence );
208+ }
209+
210+ bool Collection::isStatic()
211+ {
212+ return theCollection->isStatic();
213+ }
214+
215+%} // end Implementation
216+
217+%include "Collection.h"
218
219=== added file 'swig/CollectionManager.h'
220--- swig/CollectionManager.h 1970-01-01 00:00:00 +0000
221+++ swig/CollectionManager.h 2012-03-26 20:16:18 +0000
222@@ -0,0 +1,37 @@
223+/*
224+ * Copyright 2006-2012 The FLWOR Foundation.
225+ *
226+ * Licensed under the Apache License, Version 2.0 (the "License");
227+ * you may not use this file except in compliance with the License.
228+ * You may obtain a copy of the License at
229+ *
230+ * http://www.apache.org/licenses/LICENSE-2.0
231+ *
232+ * Unless required by applicable law or agreed to in writing, software
233+ * distributed under the License is distributed on an "AS IS" BASIS,
234+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
235+ * See the License for the specific language governing permissions and
236+ * limitations under the License.
237+ */
238+#ifndef API_COLLECTION_MANAGER_H
239+#define API_COLLECTION_MANAGER_H
240+
241+class CollectionManager
242+{
243+private:
244+ zorba::CollectionManager* theManager;
245+
246+public:
247+ CollectionManager() : theManager(0) {}
248+ CollectionManager(const CollectionManager& aMgr) : theManager(aMgr.theManager) {}
249+ CollectionManager(zorba::CollectionManager* aMgr) : theManager(aMgr) {}
250+
251+ ItemSequence availableCollections();
252+ void createCollection(const Item &aName );
253+ void deleteCollection(const Item &aName );
254+ Collection getCollection(const Item &aName );
255+ bool isAvailableCollection(const Item &aName );
256+ //virtual void registerDiagnosticHandler(DiagnosticHandler *aDiagnosticHandler )
257+};
258+
259+#endif
260\ No newline at end of file
261
262=== added file 'swig/CollectionManager.i'
263--- swig/CollectionManager.i 1970-01-01 00:00:00 +0000
264+++ swig/CollectionManager.i 2012-03-26 20:16:18 +0000
265@@ -0,0 +1,47 @@
266+/*
267+ * Copyright 2006-2012 The FLWOR Foundation.
268+ *
269+ * Licensed under the Apache License, Version 2.0 (the "License");
270+ * you may not use this file except in compliance with the License.
271+ * You may obtain a copy of the License at
272+ *
273+ * http://www.apache.org/licenses/LICENSE-2.0
274+ *
275+ * Unless required by applicable law or agreed to in writing, software
276+ * distributed under the License is distributed on an "AS IS" BASIS,
277+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
278+ * See the License for the specific language governing permissions and
279+ * limitations under the License.
280+ */
281+
282+%{ // start Implementation
283+
284+ ItemSequence CollectionManager::availableCollections()
285+ {
286+ return ItemSequence( theManager->availableCollections() );
287+ }
288+
289+ void CollectionManager::createCollection(const Item &aName )
290+ {
291+ theManager->createCollection(aName.theItem );
292+ }
293+
294+ void CollectionManager::deleteCollection(const Item &aName )
295+ {
296+ theManager->deleteCollection(aName.theItem );
297+ }
298+
299+ Collection CollectionManager::getCollection(const Item &aName )
300+ {
301+ return Collection(theManager->getCollection(aName.theItem ));
302+ }
303+
304+ bool CollectionManager::isAvailableCollection(const Item &aName )
305+ {
306+ return theManager->isAvailableCollection(aName.theItem );
307+ }
308+
309+
310+%} // end Implementation
311+
312+%include "CollectionManager.h"
313
314=== added file 'swig/DocumentManager.h'
315--- swig/DocumentManager.h 1970-01-01 00:00:00 +0000
316+++ swig/DocumentManager.h 2012-03-26 20:16:18 +0000
317@@ -0,0 +1,36 @@
318+/*
319+ * Copyright 2006-2012 The FLWOR Foundation.
320+ *
321+ * Licensed under the Apache License, Version 2.0 (the "License");
322+ * you may not use this file except in compliance with the License.
323+ * You may obtain a copy of the License at
324+ *
325+ * http://www.apache.org/licenses/LICENSE-2.0
326+ *
327+ * Unless required by applicable law or agreed to in writing, software
328+ * distributed under the License is distributed on an "AS IS" BASIS,
329+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
330+ * See the License for the specific language governing permissions and
331+ * limitations under the License.
332+ */
333+#ifndef API_DOCUMENT_MANAGER_H
334+#define API_DOCUMENT_MANAGER_H
335+
336+class DocumentManager
337+{
338+private:
339+ zorba::DocumentManager* theManager;
340+
341+public:
342+ DocumentManager() : theManager(0) {}
343+ DocumentManager(const DocumentManager& aMgr) : theManager(aMgr.theManager) {}
344+ DocumentManager(zorba::DocumentManager* aMgr) : theManager(aMgr) {}
345+
346+ void put(const std::string& aName, Item aDoc);
347+ void remove(const std::string& aName);
348+ Item document(const std::string& aName);
349+ bool isAvailableDocument(const std::string& aName);
350+ ItemSequence availableDocuments();
351+};
352+
353+#endif
354\ No newline at end of file
355
356=== added file 'swig/DocumentManager.i'
357--- swig/DocumentManager.i 1970-01-01 00:00:00 +0000
358+++ swig/DocumentManager.i 2012-03-26 20:16:18 +0000
359@@ -0,0 +1,46 @@
360+/*
361+ * Copyright 2006-2012 The FLWOR Foundation.
362+ *
363+ * Licensed under the Apache License, Version 2.0 (the "License");
364+ * you may not use this file except in compliance with the License.
365+ * You may obtain a copy of the License at
366+ *
367+ * http://www.apache.org/licenses/LICENSE-2.0
368+ *
369+ * Unless required by applicable law or agreed to in writing, software
370+ * distributed under the License is distributed on an "AS IS" BASIS,
371+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
372+ * See the License for the specific language governing permissions and
373+ * limitations under the License.
374+ */
375+
376+%{ // start Implementation
377+ void DocumentManager::put(const std::string& aName, Item aDoc)
378+ {
379+ theManager->put(aName, aDoc.theItem);
380+ }
381+
382+ void DocumentManager::remove(const std::string& aName)
383+ {
384+ theManager->remove(aName);
385+ }
386+
387+ Item DocumentManager::document(const std::string& aName)
388+ {
389+ return theManager->document(aName);
390+ }
391+
392+ bool DocumentManager::isAvailableDocument(const std::string& aName)
393+ {
394+ return theManager->isAvailableDocument(aName);
395+ }
396+
397+ ItemSequence DocumentManager::availableDocuments()
398+ {
399+ return ItemSequence( theManager->availableDocuments() );
400+ }
401+
402+
403+%} // end Implementation
404+
405+%include "DocumentManager.h"
406
407=== added file 'swig/DynamicContext.h'
408--- swig/DynamicContext.h 1970-01-01 00:00:00 +0000
409+++ swig/DynamicContext.h 2012-03-26 20:16:18 +0000
410@@ -0,0 +1,45 @@
411+/*
412+ * Copyright 2006-2008 The FLWOR Foundation.
413+ *
414+ * Licensed under the Apache License, Version 2.0 (the "License");
415+ * you may not use this file except in compliance with the License.
416+ * You may obtain a copy of the License at
417+ *
418+ * http://www.apache.org/licenses/LICENSE-2.0
419+ *
420+ * Unless required by applicable law or agreed to in writing, software
421+ * distributed under the License is distributed on an "AS IS" BASIS,
422+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
423+ * See the License for the specific language governing permissions and
424+ * limitations under the License.
425+ */
426+#ifndef API_DYNAMIC_CONTEXT_H
427+#define API_DYNAMIC_CONTEXT_H
428+
429+class DynamicContext
430+{
431+private:
432+ zorba::DynamicContext* theContext;
433+public:
434+
435+ DynamicContext():theContext(0) {}
436+ DynamicContext(const DynamicContext& aCtx):theContext(aCtx.theContext) {}
437+ DynamicContext(zorba::DynamicContext* aCtx):theContext(aCtx) {}
438+
439+ bool getContextItem (Item& aItem);
440+ Item getCurrentDateTime ();
441+ Item getDefaultCollection ();
442+ int getImplicitTimezone ();
443+ bool getVariable (const std::string& aNamespace, const std::string& aLocalname, Item& aItem, Iterator& aIterator);
444+
445+ bool setContextItem (Item& aItem);
446+ bool setCurrentDateTime (Item& aDateTimeItem);
447+ bool setDefaultCollection (Item& aCollectionUri);
448+ bool setImplicitTimezone (int aTimezone);
449+ bool setVariable (const std::string& aNamespace, const std::string& aLocalname, Iterator& aIter);
450+ bool setVariable (const std::string& aQName, Item& aItem);
451+ bool setVariable (const std::string& aQName, Iterator& aIterator);
452+
453+};
454+
455+#endif
456\ No newline at end of file
457
458=== added file 'swig/DynamicContext.i'
459--- swig/DynamicContext.i 1970-01-01 00:00:00 +0000
460+++ swig/DynamicContext.i 2012-03-26 20:16:18 +0000
461@@ -0,0 +1,59 @@
462+/*
463+ * Copyright 2006-2008 The FLWOR Foundation.
464+ *
465+ * Licensed under the Apache License, Version 2.0 (the "License");
466+ * you may not use this file except in compliance with the License.
467+ * You may obtain a copy of the License at
468+ *
469+ * http://www.apache.org/licenses/LICENSE-2.0
470+ *
471+ * Unless required by applicable law or agreed to in writing, software
472+ * distributed under the License is distributed on an "AS IS" BASIS,
473+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
474+ * See the License for the specific language governing permissions and
475+ * limitations under the License.
476+ */
477+
478+%{ // start Implementation
479+
480+ bool DynamicContext::getContextItem (Item& aItem) {
481+ return theContext->getContextItem(aItem.theItem);
482+ }
483+ Item DynamicContext::getCurrentDateTime (){
484+ return Item(theContext->getCurrentDateTime());
485+ }
486+ Item DynamicContext::getDefaultCollection () {
487+ return Item(theContext->getDefaultCollection());
488+ }
489+ int DynamicContext::getImplicitTimezone (){
490+ return theContext->getImplicitTimezone();
491+ }
492+ bool DynamicContext::getVariable (const std::string& aNamespace, const std::string& aLocalname, Item& aItem, Iterator& aIterator) {
493+ return theContext->getVariable(aNamespace, aLocalname, aItem.theItem, aIterator.theIterator);
494+ }
495+
496+ bool DynamicContext::setContextItem (Item& aItem) {
497+ return theContext->setContextItem(aItem.theItem);
498+ }
499+ bool DynamicContext::setCurrentDateTime (Item& aDateTimeItem) {
500+ return theContext->setCurrentDateTime(aDateTimeItem.theItem);
501+ }
502+ bool DynamicContext::setDefaultCollection (Item& aCollectionUri) {
503+ return theContext->setDefaultCollection(aCollectionUri.theItem);
504+ }
505+ bool DynamicContext::setImplicitTimezone (int aTimezone) {
506+ return theContext->setImplicitTimezone(aTimezone);
507+ }
508+ bool DynamicContext::setVariable(const std::string& aNamespace, const std::string& aLocalname, Iterator& aIter) {
509+ return theContext->setVariable(aNamespace, aLocalname, aIter.theIterator);
510+ }
511+ bool DynamicContext::setVariable (const std::string& aQName, Item& aItem) {
512+ return theContext->setVariable (aQName, aItem.theItem);
513+ }
514+ bool DynamicContext::setVariable (const std::string& aQName, Iterator& aIterator) {
515+ return theContext->setVariable (aQName, aIterator.theIterator);
516+ }
517+
518+%} // end Implementation
519+
520+%include "DynamicContext.h"
521
522=== added file 'swig/Item.h'
523--- swig/Item.h 1970-01-01 00:00:00 +0000
524+++ swig/Item.h 2012-03-26 20:16:18 +0000
525@@ -0,0 +1,68 @@
526+/*
527+ * Copyright 2006-2008 The FLWOR Foundation.
528+ *
529+ * Licensed under the Apache License, Version 2.0 (the "License");
530+ * you may not use this file except in compliance with the License.
531+ * You may obtain a copy of the License at
532+ *
533+ * http://www.apache.org/licenses/LICENSE-2.0
534+ *
535+ * Unless required by applicable law or agreed to in writing, software
536+ * distributed under the License is distributed on an "AS IS" BASIS,
537+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
538+ * See the License for the specific language governing permissions and
539+ * limitations under the License.
540+ */
541+
542+#ifndef API_ITEM_H
543+#define API_ITEM_H
544+
545+class Item
546+{
547+ friend class Iterator;
548+ friend class StaticContext;
549+ friend class DocumentManager;
550+ friend class SingletonIterator;
551+ friend class DynamicContext;
552+ friend class ItemFactory;
553+ friend class Collection;
554+ friend class CollectionManager;
555+private:
556+ zorba::Item theItem;
557+
558+public:
559+ Item() {}
560+ Item(const Item& aItem) : theItem(aItem.theItem) {}
561+ Item(const zorba::Item& aZItem) : theItem(aZItem) {}
562+
563+ static Item createEmptyItem();
564+ std::string getStringValue() const;
565+ std::string serialize() const;
566+ std::string serialize(SerializationOptions serOptions) const;
567+ Iterator getAtomizationValue () const;
568+ Iterator getAttributes () const;
569+ bool getBooleanValue () const;
570+ Iterator getChildren () const;
571+ Item getEBV () const;
572+ int getIntValue () const;
573+ double getDoubleValue () const;
574+ long long getLongValue () const;
575+ std::string getLocalName () const;
576+ std::string getNamespace () const;
577+ bool getNodeName (Item &aNodeName) const;
578+ Item getParent () const;
579+ std::string getPrefix () const;
580+ Item getType () const;
581+ unsigned int getUnsignedIntValue () const;
582+
583+ int getNodeKind() const;
584+ bool isAtomic () const;
585+ bool isNaN () const;
586+ bool isNode () const;
587+ bool isNull () const;
588+ bool isPosOrNegInf () const;
589+
590+ void close();
591+}; // class Item
592+
593+#endif
594
595=== added file 'swig/Item.i'
596--- swig/Item.i 1970-01-01 00:00:00 +0000
597+++ swig/Item.i 2012-03-26 20:16:18 +0000
598@@ -0,0 +1,114 @@
599+/*
600+ * Copyright 2006-2008 The FLWOR Foundation.
601+ *
602+ * Licensed under the Apache License, Version 2.0 (the "License");
603+ * you may not use this file except in compliance with the License.
604+ * You may obtain a copy of the License at
605+ *
606+ * http://www.apache.org/licenses/LICENSE-2.0
607+ *
608+ * Unless required by applicable law or agreed to in writing, software
609+ * distributed under the License is distributed on an "AS IS" BASIS,
610+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
611+ * See the License for the specific language governing permissions and
612+ * limitations under the License.
613+ */
614+
615+%{ // start Implementation
616+
617+ Item Item::createEmptyItem()
618+ { return Item(); }
619+
620+ std::string Item::getStringValue() const
621+ { return std::string(theItem.getStringValue().c_str()); }
622+
623+ std::string Item::serialize() const
624+ {
625+ std::stringstream lStream;
626+ Zorba_SerializerOptions_t lOptions;
627+ lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
628+ zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(lOptions);
629+ zorba::SingletonItemSequence lSequence(theItem);
630+ lSerializer->serialize(&lSequence, lStream);
631+ return lStream.str();
632+ }
633+ std::string Item::serialize(SerializationOptions serOptions) const
634+ {
635+ std::stringstream lStream;
636+ serOptions.lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
637+ zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(serOptions.lOptions);
638+ zorba::SingletonItemSequence lSequence(theItem);
639+ lSerializer->serialize(&lSequence, lStream);
640+ return lStream.str();
641+ }
642+
643+ Iterator Item::getAtomizationValue () const
644+ { return Iterator(theItem.getAtomizationValue()); }
645+
646+ Iterator Item::getAttributes () const
647+ { return Iterator(theItem.getAttributes()); }
648+
649+ bool Item::getBooleanValue () const
650+ { return theItem.getBooleanValue(); }
651+
652+ Iterator Item::getChildren () const
653+ { return Iterator(theItem.getChildren()); }
654+
655+ Item Item::getEBV () const
656+ { return Item(theItem.getEBV()); }
657+
658+ int Item::getIntValue () const
659+ { return theItem.getIntValue(); }
660+
661+ double Item::getDoubleValue () const
662+ { return theItem.getDoubleValue(); }
663+
664+ long long Item::getLongValue () const
665+ { return theItem.getLongValue(); }
666+
667+ std::string Item::getLocalName () const
668+ { return std::string(theItem.getLocalName().c_str()); }
669+
670+ std::string Item::getNamespace () const
671+ { return std::string(theItem.getNamespace().c_str()); }
672+
673+ bool Item::getNodeName (Item &aNodeName) const
674+ { return theItem.getNodeName( aNodeName.theItem ); }
675+
676+ Item Item::getParent () const
677+ { return theItem.getParent(); }
678+
679+ std::string Item::getPrefix () const
680+ { return std::string(theItem.getPrefix().c_str()); }
681+
682+ Item Item::getType () const
683+ { return Item( theItem.getType() ); }
684+
685+ unsigned int Item::getUnsignedIntValue () const
686+ { return theItem.getUnsignedIntValue(); }
687+
688+ bool Item::isAtomic () const
689+ { return theItem.isAtomic(); }
690+
691+ bool Item::isNaN () const
692+ { return theItem.isNaN(); }
693+
694+ bool Item::isNode () const
695+ { return theItem.isNode(); }
696+
697+ bool Item::isNull () const
698+ { return theItem.isNull(); }
699+
700+ bool Item::isPosOrNegInf () const
701+ { return theItem.isPosOrNegInf(); }
702+
703+ int Item::getNodeKind () const
704+ { return theItem.getNodeKind(); }
705+
706+ void Item::close()
707+ { theItem.close(); }
708+
709+%} // end Implementation
710+
711+
712+%include "Item.h"
713
714=== modified file 'swig/ItemFactory.h'
715--- swig/ItemFactory.h 2012-03-23 17:32:07 +0000
716+++ swig/ItemFactory.h 2012-03-26 20:16:18 +0000
717@@ -1,4 +1,21 @@
718-// Interface
719+/*
720+ * Copyright 2006-2008 The FLWOR Foundation.
721+ *
722+ * Licensed under the Apache License, Version 2.0 (the "License");
723+ * you may not use this file except in compliance with the License.
724+ * You may obtain a copy of the License at
725+ *
726+ * http://www.apache.org/licenses/LICENSE-2.0
727+ *
728+ * Unless required by applicable law or agreed to in writing, software
729+ * distributed under the License is distributed on an "AS IS" BASIS,
730+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
731+ * See the License for the specific language governing permissions and
732+ * limitations under the License.
733+ */
734+
735+#ifndef API_ITEM_FACTORY_H
736+#define API_ITEM_FACTORY_H
737
738 class ItemFactory
739 {
740@@ -11,13 +28,16 @@
741 ItemFactory(const ItemFactory& aItemFactory) : theItemFactory(aItemFactory.theItemFactory) {}
742
743 Item createAnyURI (const std::string &aURI);
744- Item createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, Item aTypedValue);
745- Item createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, std::vector< Item > aTypedValue);
746+ Item createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, Item& aTypedValue);
747+#ifndef SWIGRUBY
748+ Item createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, std::vector< Item > aTypedValue);
749+#endif
750 Item createBase64Binary (const char *aBinData, size_t aLength);
751 Item createBase64Binary (std::istream &aStream);
752 Item createBase64Binary (const unsigned char *aBinData, size_t aLength);
753 Item createBoolean (bool aValue);
754 Item createByte (char aByte);
755+ Item createCommentNode (Item &aParent, const std::string &aContent);
756 Item createDate (const std::string &aDate);
757 Item createDate (short aYear, short aMonth, short aDay);
758 Item createDateTime (const std::string &aDateTimeValue);
759@@ -29,7 +49,13 @@
760 Item createDouble (double aValue);
761 Item createDuration (const std::string &aValue);
762 Item createDuration (short aYear, short aMonths, short aDays, short aHours, short aMinutes, double aSeconds);
763- //Item createElementNode (Item &aParent, Item aNodeName, Item aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings);
764+ Item createDayTimeDuration (const std::string &aValue);
765+ Item createYearMonthDuration (const std::string &aValue);
766+ Item createDocumentNode (const std::string &aBaseUri, const std::string &aDocUri);
767+#ifndef SWIGRUBY
768+ Item createElementNode (Item &aParent, Item &aNodeName, Item &aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings);
769+#endif
770+ Item createElementNode (Item &aParent, Item &aNodeName, Item &aTypeName, bool aHasTypedValue, bool aHasEmptyValue);
771 Item createFloat (const std::string &aValue);
772 Item createFloat (float aValue);
773 Item createGDay (const std::string &aValue);
774@@ -51,6 +77,7 @@
775 Item createNegativeInteger (long long aValue);
776 Item createNonNegativeInteger (unsigned long long aValue);
777 Item createNonPositiveInteger (long long aValue);
778+ Item createPiNode (Item &aParent, const std::string &aTarget, const std::string &aContent, const std::string &aBaseUri);
779 Item createPositiveInteger (unsigned long long aValue);
780 Item createQName (const std::string &aNamespace, const std::string &aPrefix, const std::string &aLocalname);
781 Item createQName (const std::string &aNamespace, const std::string &aLocalname);
782@@ -58,7 +85,7 @@
783 Item createShort (short aShort);
784 //Item createStreamableString (std::istream &stream, StreamReleaser streamReleaser, bool seekable=false);
785 Item createString (const std::string &aString);
786- Item createTextNode (Item parent, std::string content);
787+ Item createTextNode (Item &aParent, const std::string &aContent);
788 Item createTime (short aHour, short aMinute, double aSecond, short aTimeZone_hours);
789 Item createTime (short aHour, short aMinute, double aSecond);
790 Item createTime (const std::string &aValue);
791@@ -67,3 +94,5 @@
792 Item createUnsignedLong (unsigned long long aValue);
793 Item createUnsignedShort (unsigned short aValue);
794 }; // class ItemFactory
795+
796+#endif
797\ No newline at end of file
798
799=== modified file 'swig/ItemFactory.i'
800--- swig/ItemFactory.i 2012-03-23 17:32:07 +0000
801+++ swig/ItemFactory.i 2012-03-26 20:16:18 +0000
802@@ -7,11 +7,12 @@
803 return Item(theItemFactory->createAnyURI(aURI));
804 }
805
806- Item ItemFactory::createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, Item aTypedValue){
807+ Item ItemFactory::createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, Item& aTypedValue){
808 return Item( theItemFactory->createAttributeNode( aParent.theItem, aNodeName.theItem, aTypeName.theItem, aTypedValue.theItem ));
809 }
810
811- Item ItemFactory::createAttributeNode (Item aParent, Item aNodeName, Item aTypeName, std::vector< Item > aTypedValue){
812+#ifndef SWIGRUBY
813+ Item ItemFactory::createAttributeNode (Item& aParent, Item& aNodeName, Item& aTypeName, std::vector< Item > aTypedValue){
814
815 std::vector< zorba::Item > typedValue;
816 typedValue.reserve(aTypedValue.size());
817@@ -21,6 +22,7 @@
818 }
819 return Item( theItemFactory->createAttributeNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, typedValue ));
820 }
821+#endif
822
823 Item ItemFactory::createBase64Binary (const char *aBinData, size_t aLength){
824 return Item( theItemFactory->createBase64Binary(aBinData, aLength));
825@@ -37,6 +39,10 @@
826 Item ItemFactory::createByte (char aByte){
827 return Item( theItemFactory->createByte(aByte));
828 }
829+ Item ItemFactory::createCommentNode (Item &aParent, const std::string &aContent){
830+ zorba::String lContent = zorba::String(aContent);
831+ return Item( theItemFactory->createCommentNode (aParent.theItem, lContent));
832+ }
833 Item ItemFactory::createDate (const std::string &aDate){
834 return Item( theItemFactory->createDate(aDate));
835 }
836@@ -70,11 +76,32 @@
837 Item ItemFactory::createDuration (short aYear, short aMonths, short aDays, short aHours, short aMinutes, double aSeconds){
838 return Item( theItemFactory->createDuration (aYear, aMonths, aDays, aHours, aMinutes, aSeconds));
839 }
840- /*
841- Item ItemFactory::createElementNode (Item &aParent, Item aNodeName, Item aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings){
842- return Item( theItemFactory->createElementNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, aHasTypedValue, aHasEmptyValue, aNsBindings));
843- }
844- */
845+ Item ItemFactory::createDayTimeDuration (const std::string &aValue){
846+ return Item( theItemFactory->createDayTimeDuration (aValue));
847+ }
848+ Item ItemFactory::createYearMonthDuration (const std::string &aValue){
849+ return Item( theItemFactory->createYearMonthDuration (aValue));
850+ }
851+ Item ItemFactory::createDocumentNode (const std::string &aBaseUri, const std::string &aDocUri){
852+ return Item( theItemFactory->createDocumentNode (aBaseUri, aDocUri));
853+ }
854+#ifndef SWIGRUBY
855+ Item ItemFactory::createElementNode (Item &aParent, Item& aNodeName, Item& aTypeName, bool aHasTypedValue, bool aHasEmptyValue, std::vector< std::pair< std::string, std::string > > aNsBindings){
856+ std::vector< std::pair< zorba::String, zorba::String > > items;
857+ items.reserve(aNsBindings.size());
858+ std::vector< std::pair< std::string, std::string > >::iterator iter;
859+ for(iter = aNsBindings.begin(); iter != aNsBindings.end(); iter++) {
860+ std::pair< zorba::String, zorba::String > pair;
861+ pair.first = (*iter).first;
862+ pair.second = (*iter).second;
863+ items.push_back(pair);
864+ }
865+ return Item( theItemFactory->createElementNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, aHasTypedValue, aHasEmptyValue, items));
866+ }
867+#endif
868+ Item ItemFactory::createElementNode (Item &aParent, Item& aNodeName, Item& aTypeName, bool aHasTypedValue, bool aHasEmptyValue){
869+ return Item( theItemFactory->createElementNode (aParent.theItem, aNodeName.theItem, aTypeName.theItem, aHasTypedValue, aHasEmptyValue, std::vector<std::pair<zorba::String, zorba::String> >()));
870+ }
871 Item ItemFactory::createFloat (const std::string &aValue){
872 return Item( theItemFactory->createFloat (aValue));
873 }
874@@ -138,6 +165,12 @@
875 Item ItemFactory::createNonPositiveInteger (long long aValue){
876 return Item( theItemFactory->createNonPositiveInteger (aValue));
877 }
878+ Item ItemFactory::createPiNode (Item &aParent, const std::string &aTarget, const std::string &aContent, const std::string &aBaseUri){
879+ zorba::String lTarget = zorba::String(aTarget);
880+ zorba::String lContent = zorba::String(aContent);
881+ zorba::String lBaseUri = zorba::String(aBaseUri);
882+ return Item( theItemFactory->createPiNode (aParent.theItem, lTarget, lContent, lBaseUri));
883+ }
884 Item ItemFactory::createPositiveInteger (unsigned long long aValue){
885 return Item( theItemFactory->createPositiveInteger (aValue));
886 }
887@@ -161,8 +194,9 @@
888 Item ItemFactory::createString (const std::string &aString){
889 return Item( theItemFactory->createString (aString));
890 }
891- Item ItemFactory::createTextNode (Item parent, std::string content){
892- return Item( theItemFactory->createTextNode (parent.theItem, content));
893+ Item ItemFactory::createTextNode (Item &aParent, const std::string &aContent){
894+ zorba::String lContent = zorba::String(aContent);
895+ return Item( theItemFactory->createTextNode (aParent.theItem, lContent));
896 }
897 Item ItemFactory::createTime (short aHour, short aMinute, double aSecond, short aTimeZone_hours){
898 return Item( theItemFactory->createTime (aHour, aMinute, aSecond, aTimeZone_hours));
899@@ -189,4 +223,4 @@
900
901 %} // end Implementation
902
903-%include "ItemFactory.h"
904\ No newline at end of file
905+%include "ItemFactory.h"
906
907=== added file 'swig/ItemSequence.h'
908--- swig/ItemSequence.h 1970-01-01 00:00:00 +0000
909+++ swig/ItemSequence.h 2012-03-26 20:16:18 +0000
910@@ -0,0 +1,32 @@
911+/*
912+ * Copyright 2006-2012 The FLWOR Foundation.
913+ *
914+ * Licensed under the Apache License, Version 2.0 (the "License");
915+ * you may not use this file except in compliance with the License.
916+ * You may obtain a copy of the License at
917+ *
918+ * http://www.apache.org/licenses/LICENSE-2.0
919+ *
920+ * Unless required by applicable law or agreed to in writing, software
921+ * distributed under the License is distributed on an "AS IS" BASIS,
922+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
923+ * See the License for the specific language governing permissions and
924+ * limitations under the License.
925+ */
926+#ifndef API_ITEM_SEQUENCE_H
927+#define API_ITEM_SEQUENCE_H
928+
929+class ItemSequence
930+{
931+ friend class Collection;
932+private:
933+ zorba::ItemSequence_t theItemSequence;
934+
935+public:
936+ ItemSequence(const ItemSequence& aItemSequence) : theItemSequence(aItemSequence.theItemSequence) {}
937+ ItemSequence(zorba::ItemSequence_t aItemSequence) : theItemSequence(aItemSequence) {}
938+ Iterator getIterator();
939+
940+};
941+
942+#endif
943\ No newline at end of file
944
945=== added file 'swig/ItemSequence.i'
946--- swig/ItemSequence.i 1970-01-01 00:00:00 +0000
947+++ swig/ItemSequence.i 2012-03-26 20:16:18 +0000
948@@ -0,0 +1,26 @@
949+/*
950+ * Copyright 2006-2012 The FLWOR Foundation.
951+ *
952+ * Licensed under the Apache License, Version 2.0 (the "License");
953+ * you may not use this file except in compliance with the License.
954+ * You may obtain a copy of the License at
955+ *
956+ * http://www.apache.org/licenses/LICENSE-2.0
957+ *
958+ * Unless required by applicable law or agreed to in writing, software
959+ * distributed under the License is distributed on an "AS IS" BASIS,
960+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
961+ * See the License for the specific language governing permissions and
962+ * limitations under the License.
963+ */
964+
965+%{ // start Implementation
966+
967+ Iterator ItemSequence::getIterator()
968+ {
969+ return Iterator( theItemSequence->getIterator() );
970+ }
971+
972+%} // end Implementation
973+
974+%include "ItemSequence.h"
975
976=== added file 'swig/Iterator.h'
977--- swig/Iterator.h 1970-01-01 00:00:00 +0000
978+++ swig/Iterator.h 2012-03-26 20:16:18 +0000
979@@ -0,0 +1,57 @@
980+/*
981+ * Copyright 2006-2008 The FLWOR Foundation.
982+ *
983+ * Licensed under the Apache License, Version 2.0 (the "License");
984+ * you may not use this file except in compliance with the License.
985+ * You may obtain a copy of the License at
986+ *
987+ * http://www.apache.org/licenses/LICENSE-2.0
988+ *
989+ * Unless required by applicable law or agreed to in writing, software
990+ * distributed under the License is distributed on an "AS IS" BASIS,
991+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
992+ * See the License for the specific language governing permissions and
993+ * limitations under the License.
994+ */
995+#ifndef API_ITERATOR_H
996+#define API_ITERATOR_H
997+
998+class Iterator
999+{
1000+protected:
1001+ friend class DynamicContext;
1002+ friend class DocumentManager;
1003+ friend class CollectionManager;
1004+ friend class Collection;
1005+ friend class StaticContext;
1006+ friend class XQuery;
1007+ friend class ItemSequence;
1008+ zorba::Iterator_t theIterator;
1009+ zorba::Item theItem;
1010+ bool theConsumed;
1011+public:
1012+ // constructors
1013+ Iterator() {}
1014+ Iterator(const Iterator& anIterator)
1015+ : theIterator(anIterator.theIterator),
1016+ theItem(anIterator.theItem),
1017+ theConsumed(false)
1018+ {}
1019+ Iterator(zorba::Iterator_t anIterator)
1020+ : theIterator(anIterator),
1021+ theConsumed(false)
1022+ {}
1023+ Iterator(zorba::Item& aItem)
1024+ : theIterator(0),
1025+ theItem(aItem),
1026+ theConsumed(false)
1027+ {}
1028+
1029+ void open();
1030+ bool isOpen();
1031+ bool next(Item&);
1032+ void close();
1033+ void destroy();
1034+}; // class Iterator
1035+
1036+#endif
1037\ No newline at end of file
1038
1039=== added file 'swig/Iterator.i'
1040--- swig/Iterator.i 1970-01-01 00:00:00 +0000
1041+++ swig/Iterator.i 2012-03-26 20:16:18 +0000
1042@@ -0,0 +1,69 @@
1043+/*
1044+ * Copyright 2006-2008 The FLWOR Foundation.
1045+ *
1046+ * Licensed under the Apache License, Version 2.0 (the "License");
1047+ * you may not use this file except in compliance with the License.
1048+ * You may obtain a copy of the License at
1049+ *
1050+ * http://www.apache.org/licenses/LICENSE-2.0
1051+ *
1052+ * Unless required by applicable law or agreed to in writing, software
1053+ * distributed under the License is distributed on an "AS IS" BASIS,
1054+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1055+ * See the License for the specific language governing permissions and
1056+ * limitations under the License.
1057+ */
1058+
1059+%{ // start Implementation
1060+
1061+ void Iterator::open()
1062+ {
1063+ if (theIterator)
1064+ theIterator->open();
1065+ theConsumed = false;
1066+ }
1067+
1068+ bool Iterator::isOpen()
1069+ {
1070+ if (theIterator)
1071+ return theIterator->isOpen();
1072+ else
1073+ return !theConsumed;
1074+ }
1075+
1076+ void Iterator::close()
1077+ {
1078+ if (theIterator)
1079+ theIterator->close();
1080+ theConsumed = true;
1081+ }
1082+
1083+ void Iterator::destroy()
1084+ {
1085+ theIterator = 0;
1086+ }
1087+
1088+ bool Iterator::next(Item& aItem)
1089+ {
1090+ if (theIterator)
1091+ {
1092+ return theIterator->next(aItem.theItem);
1093+ }
1094+ else
1095+ {
1096+ if (!theConsumed)
1097+ {
1098+ aItem = theItem;
1099+ return true;
1100+ }
1101+ else
1102+ {
1103+ return false;
1104+ }
1105+ }
1106+ }
1107+
1108+
1109+%} // end Implementation
1110+
1111+%include "Iterator.h"
1112
1113=== added file 'swig/SerializationOptions.h'
1114--- swig/SerializationOptions.h 1970-01-01 00:00:00 +0000
1115+++ swig/SerializationOptions.h 2012-03-26 20:16:18 +0000
1116@@ -0,0 +1,114 @@
1117+/*
1118+ * Copyright 2006-2008 The FLWOR Foundation.
1119+ *
1120+ * Licensed under the Apache License, Version 2.0 (the "License");
1121+ * you may not use this file except in compliance with the License.
1122+ * You may obtain a copy of the License at
1123+ *
1124+ * http://www.apache.org/licenses/LICENSE-2.0
1125+ *
1126+ * Unless required by applicable law or agreed to in writing, software
1127+ * distributed under the License is distributed on an "AS IS" BASIS,
1128+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1129+ * See the License for the specific language governing permissions and
1130+ * limitations under the License.
1131+ */
1132+
1133+#ifndef API_SERIALIZATION_OPTIONS_H
1134+#define API_SERIALIZATION_OPTIONS_H
1135+
1136+class SerializationOptions
1137+{
1138+friend class Item;
1139+
1140+public:
1141+ typedef enum
1142+ {
1143+ ZORBA_API_SERIALIZATION_METHOD_XML,
1144+ ZORBA_API_SERIALIZATION_METHOD_HTML,
1145+ ZORBA_API_SERIALIZATION_METHOD_XHTML,
1146+ ZORBA_API_SERIALIZATION_METHOD_TEXT,
1147+ ZORBA_API_SERIALIZATION_METHOD_BINARY
1148+ } SerializationMethod;
1149+
1150+ typedef enum
1151+ {
1152+ ZORBA_API_BYTE_ORDER_MARK_YES,
1153+ ZORBA_API_BYTE_ORDER_MARK_NO
1154+ } ByteOrderMark;
1155+
1156+
1157+ typedef enum
1158+ {
1159+ ZORBA_API_ESCAPE_URI_ATTRIBUTES_YES,
1160+ ZORBA_API_ESCAPE_URI_ATTRIBUTES_NO
1161+ } EscapeUriAttributes;
1162+
1163+ typedef enum {
1164+ ZORBA_API_INCLUDE_CONTENT_TYPE_YES,
1165+ ZORBA_API_INCLUDE_CONTENT_TYPE_NO
1166+ } IncludeContentType;
1167+
1168+ typedef enum {
1169+ ZORBA_API_INDENT_YES,
1170+ ZORBA_API_INDENT_NO
1171+ } Indent;
1172+
1173+ typedef enum {
1174+ ZORBA_API_NORMALIZATION_FORM_NFC,
1175+ ZORBA_API_NORMALIZATION_FORM_NFD,
1176+ ZORBA_API_NORMALIZATION_FORM_NFKC,
1177+ ZORBA_API_NORMALIZATION_FORM_NFKD,
1178+ ZORBA_API_NORMALIZATION_FORM_FULLY_normalized,
1179+ ZORBA_API_NORMALIZATION_FORM_NONE
1180+ } NormalizationForm;
1181+
1182+ typedef enum {
1183+ ZORBA_API_OMIT_XML_DECLARATION_YES,
1184+ ZORBA_API_OMIT_XML_DECLARATION_NO
1185+ } OmitXMLDeclaration;
1186+
1187+ typedef enum {
1188+ ZORBA_API_STANDALONE_YES,
1189+ ZORBA_API_STANDALONE_NO,
1190+ ZORBA_API_STANDALONE_OMIT
1191+ } Standalone;
1192+
1193+ typedef enum {
1194+ ZORBA_API_UNDECLARE_PREFIXES_YES,
1195+ ZORBA_API_UNDECLARE_PREFIXES_NO
1196+ } UndeclarePrefixes;
1197+
1198+
1199+private:
1200+ Zorba_SerializerOptions_t lOptions;
1201+
1202+public:
1203+ /*
1204+ * Default values:
1205+ * - serialization method: XML
1206+ * - byte order mark: NO
1207+ * - esacpe uri attributes: NO
1208+ * - include content type: NO
1209+ * - indent: NO
1210+ * - normalization form: none
1211+ * - omit xml declaration: NO
1212+ * - standalone: omit
1213+ * - undeclare prefixes: NO
1214+ */
1215+
1216+
1217+ void setSerializationMethod ( SerializationMethod aSerializationMethod );
1218+ void setByteOrderMark ( ByteOrderMark aByteOrderMark );
1219+ void setEscapeUriAttributes ( EscapeUriAttributes aEscapeUriAttributes );
1220+ void setIncludeContentType ( IncludeContentType aIncludeContentType );
1221+ void setIndent ( Indent aIndent );
1222+ void setNormalizationForm ( NormalizationForm aNormalizationForm );
1223+ void setOmitXMLDeclaration ( OmitXMLDeclaration aOmitXMLDeclaration );
1224+ void setStandalone ( Standalone aStandalone );
1225+ void setUndeclarePrefixes ( UndeclarePrefixes aUndeclarePrefixes );
1226+ void setSerializerOption(const std::string &parameter, const std::string &value);
1227+
1228+}; // class SerializationOptions
1229+
1230+#endif
1231
1232=== added file 'swig/SerializationOptions.i'
1233--- swig/SerializationOptions.i 1970-01-01 00:00:00 +0000
1234+++ swig/SerializationOptions.i 2012-03-26 20:16:18 +0000
1235@@ -0,0 +1,125 @@
1236+/*
1237+ * Copyright 2006-2008 The FLWOR Foundation.
1238+ *
1239+ * Licensed under the Apache License, Version 2.0 (the "License");
1240+ * you may not use this file except in compliance with the License.
1241+ * You may obtain a copy of the License at
1242+ *
1243+ * http://www.apache.org/licenses/LICENSE-2.0
1244+ *
1245+ * Unless required by applicable law or agreed to in writing, software
1246+ * distributed under the License is distributed on an "AS IS" BASIS,
1247+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1248+ * See the License for the specific language governing permissions and
1249+ * limitations under the License.
1250+ */
1251+
1252+%{ // start Implementation
1253+
1254+ void SerializationOptions::setSerializationMethod ( SerializationMethod aSerializationMethod ) {
1255+ switch (aSerializationMethod) {
1256+ case ZORBA_API_SERIALIZATION_METHOD_HTML:
1257+ lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_HTML;
1258+ break;
1259+ case ZORBA_API_SERIALIZATION_METHOD_XHTML:
1260+ lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_XHTML;
1261+ break;
1262+ case ZORBA_API_SERIALIZATION_METHOD_TEXT:
1263+ lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_TEXT;
1264+ break;
1265+ case ZORBA_API_SERIALIZATION_METHOD_BINARY:
1266+ lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_BINARY;
1267+ break;
1268+ case ZORBA_API_SERIALIZATION_METHOD_XML:
1269+ default:
1270+ lOptions.ser_method = ZORBA_SERIALIZATION_METHOD_XML;
1271+ break;
1272+ }
1273+ }
1274+ void SerializationOptions::setByteOrderMark ( ByteOrderMark aByteOrderMark ) {
1275+ if (aByteOrderMark == ZORBA_API_BYTE_ORDER_MARK_YES) {
1276+ lOptions.byte_order_mark = ZORBA_BYTE_ORDER_MARK_YES;
1277+ } else {
1278+ lOptions.byte_order_mark = ZORBA_BYTE_ORDER_MARK_NO;
1279+ }
1280+ }
1281+ void SerializationOptions::setEscapeUriAttributes ( EscapeUriAttributes aEscapeUriAttributes ) {
1282+ if (aEscapeUriAttributes == ZORBA_API_ESCAPE_URI_ATTRIBUTES_YES) {
1283+ lOptions.escape_uri_attributes = ZORBA_ESCAPE_URI_ATTRIBUTES_YES;
1284+ } else {
1285+ lOptions.escape_uri_attributes = ZORBA_ESCAPE_URI_ATTRIBUTES_NO;
1286+ }
1287+ }
1288+ void SerializationOptions::setIncludeContentType ( IncludeContentType aIncludeContentType ) {
1289+ if (aIncludeContentType == ZORBA_API_INCLUDE_CONTENT_TYPE_YES) {
1290+ lOptions.include_content_type = ZORBA_INCLUDE_CONTENT_TYPE_YES;
1291+ } else {
1292+ lOptions.include_content_type = ZORBA_INCLUDE_CONTENT_TYPE_NO;
1293+ }
1294+ }
1295+ void SerializationOptions::setIndent ( Indent aIndent ) {
1296+ if (aIndent == ZORBA_API_INDENT_YES) {
1297+ lOptions.indent = ZORBA_INDENT_YES;
1298+ } else {
1299+ lOptions.indent = ZORBA_INDENT_NO;
1300+ }
1301+ }
1302+ void SerializationOptions::setNormalizationForm ( NormalizationForm aNormalizationForm ) {
1303+ switch (aNormalizationForm) {
1304+ case ZORBA_API_NORMALIZATION_FORM_NFC:
1305+ lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NFC;
1306+ break;
1307+ case ZORBA_API_NORMALIZATION_FORM_NFD:
1308+ lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NFD;
1309+ break;
1310+ case ZORBA_API_NORMALIZATION_FORM_NFKC:
1311+ lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NFKC;
1312+ break;
1313+ case ZORBA_API_NORMALIZATION_FORM_NFKD:
1314+ lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NFKD;
1315+ break;
1316+ case ZORBA_API_NORMALIZATION_FORM_FULLY_normalized:
1317+ lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_FULLY_normalized;
1318+ break;
1319+ case ZORBA_API_NORMALIZATION_FORM_NONE:
1320+ default:
1321+ lOptions.normalization_form = ZORBA_NORMALIZATION_FORM_NONE;
1322+ break;
1323+ }
1324+ }
1325+ void SerializationOptions::setOmitXMLDeclaration ( OmitXMLDeclaration aOmitXMLDeclaration ) {
1326+ if (aOmitXMLDeclaration == ZORBA_API_OMIT_XML_DECLARATION_YES) {
1327+ lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
1328+ } else {
1329+ lOptions.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_NO;
1330+ }
1331+ }
1332+ void SerializationOptions::setStandalone ( Standalone aStandalone ) {
1333+ switch (aStandalone) {
1334+ case ZORBA_API_STANDALONE_YES:
1335+ lOptions.standalone = ZORBA_STANDALONE_YES;
1336+ break;
1337+ case ZORBA_API_STANDALONE_NO:
1338+ lOptions.standalone = ZORBA_STANDALONE_NO;
1339+ break;
1340+ case ZORBA_API_STANDALONE_OMIT:
1341+ default:
1342+ lOptions.standalone = ZORBA_STANDALONE_OMIT;
1343+ break;
1344+ }
1345+ }
1346+ void SerializationOptions::setUndeclarePrefixes ( UndeclarePrefixes aUndeclarePrefixes ) {
1347+ if (aUndeclarePrefixes == ZORBA_API_UNDECLARE_PREFIXES_YES) {
1348+ lOptions.undeclare_prefixes = ZORBA_UNDECLARE_PREFIXES_YES;
1349+ } else {
1350+ lOptions.undeclare_prefixes = ZORBA_UNDECLARE_PREFIXES_NO;
1351+ }
1352+ }
1353+
1354+ void SerializationOptions::setSerializerOption(const std::string &parameter, const std::string &value) {
1355+ lOptions.SetSerializerOption(parameter.c_str(), value.c_str());
1356+ }
1357+
1358+%} // end Implementation
1359+
1360+%include "SerializationOptions.h"
1361
1362=== modified file 'swig/StaticContext.h'
1363--- swig/StaticContext.h 2012-03-23 17:32:07 +0000
1364+++ swig/StaticContext.h 2012-03-26 20:16:18 +0000
1365@@ -1,5 +1,69 @@
1366+/*
1367+ * Copyright 2006-2008 The FLWOR Foundation.
1368+ *
1369+ * Licensed under the Apache License, Version 2.0 (the "License");
1370+ * you may not use this file except in compliance with the License.
1371+ * You may obtain a copy of the License at
1372+ *
1373+ * http://www.apache.org/licenses/LICENSE-2.0
1374+ *
1375+ * Unless required by applicable law or agreed to in writing, software
1376+ * distributed under the License is distributed on an "AS IS" BASIS,
1377+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1378+ * See the License for the specific language governing permissions and
1379+ * limitations under the License.
1380+ */
1381+#ifndef API_STATIC_CONTEXT_H
1382+#define API_STATIC_CONTEXT_H
1383+
1384 #include <zorba/static_context_consts.h>
1385
1386+class ZorbaConstants
1387+{
1388+public:
1389+ typedef enum {
1390+ PRESERVE,
1391+ NO_PRESERVE
1392+ } PreserveMode;
1393+
1394+ typedef enum {
1395+ INHERIT,
1396+ NO_INHERIT
1397+ } InheritMode;
1398+
1399+ typedef enum {
1400+ PRESERVE_SPACE,
1401+ STRIP_SPACE
1402+ } BoundarySpaceMode;
1403+
1404+ typedef enum {
1405+ PRESERVE_CONSTRUCTION,
1406+ STRIP_CONSTRUCTION
1407+ } ConstructionMode;
1408+
1409+ typedef enum {
1410+ EMPTY_GREATEST,
1411+ EMPTY_LEAST
1412+ } OrderEmptyMode;
1413+
1414+ typedef enum {
1415+ ORDERED,
1416+ UNORDERED
1417+ } OrderingMode;
1418+
1419+ typedef enum {
1420+ VALIDATE_SKIP,
1421+ VALIDATE_LAX,
1422+ VALIDATE_STRICT
1423+ } RevalidationMode;
1424+
1425+ typedef enum {
1426+ XPATH2_0,
1427+ XPATH1_0
1428+ } XPath1_0CompatibleMode;
1429+
1430+}; // ZorbaConstants
1431+
1432 class StaticContext
1433 {
1434 friend class Zorba;
1435@@ -8,62 +72,73 @@
1436 private:
1437 zorba::StaticContext_t theStaticContext;
1438 public:
1439- StaticContext();
1440+
1441 StaticContext(const StaticContext& aStaticContext);
1442 StaticContext(zorba::StaticContext_t aStaticContext);
1443
1444- virtual void addColation(const std::string& aURI);
1445- virtual bool addNamespace(const std::string& aPrefix,
1446+ void addColation(const std::string& aURI);
1447+ bool addNamespace(const std::string& aPrefix,
1448 const std::string& aURI);
1449- void addReference() const;
1450- virtual bool containsFunction(const std::string &aFnNameUri,
1451+
1452+ bool containsFunction(const std::string &aFnNameUri,
1453 const std::string &aFnNameLocal,
1454 int arity) const;
1455
1456- virtual StaticContext createChildContext() const;
1457- virtual void declareOption(const Item &aQName,
1458+ StaticContext createChildContext() const;
1459+ void declareOption(const Item &aQName,
1460 const std::string &aOptionVal);
1461- virtual void disableFunction(const Item &aQName, int arity);
1462-
1463- virtual void free ();
1464- virtual std::string getBaseURI () const;
1465- virtual zorba::boundary_space_mode_t getBoundarySpacePolicy () const;
1466-
1467- virtual zorba::construction_mode_t getConstructionMode () const;
1468- virtual void getCopyNamespacesMode (zorba::preserve_mode_t &aPreserve, zorba::inherit_mode_t &aInherit) const;
1469- virtual std::string getDefaultCollation () const;
1470- virtual std::string getDefaultElementAndTypeNamespace () const;
1471- virtual std::string getDefaultFunctionNamespace () const;
1472- virtual zorba::order_empty_mode_t getDefaultOrderForEmptySequences () const;
1473-
1474- virtual std::string getNamespaceURIByPrefix(const std::string &aPrefix) const;
1475- virtual bool getOption(const Item &aQName, std::string &aOptionValue) const;
1476- virtual zorba::ordering_mode_t getOrderingMode() const;
1477- long getRefCount() const;
1478- virtual zorba::validation_mode_t getRevalidationMode();
1479- virtual zorba::xpath1_0compatib_mode_t getXPath1_0CompatibMode () const;
1480- virtual void loadProlog (const std::string & aProlog,
1481- const CompilerHints &hints);
1482-
1483- void removeReference ();
1484- virtual void resetTraceStream ();
1485- virtual bool setBaseURI (const std::string &aBaseURI);
1486- virtual bool setBoundarySpacePolicy (zorba::boundary_space_mode_t aMode);
1487-
1488- virtual bool setConstructionMode (zorba::construction_mode_t aMode);
1489-
1490- virtual bool setCopyNamespacesMode (zorba::preserve_mode_t aPreserve,
1491- zorba::inherit_mode_t aInherit);
1492- virtual void setDefaultCollation (const std::string &aURI);
1493- virtual bool setDefaultElementAndTypeNamespace (const std::string &aURI);
1494- virtual bool setDefaultFunctionNamespace (const std::string &aURI);
1495- virtual bool setDefaultOrderForEmptySequences (zorba::order_empty_mode_t aMode);
1496-
1497- virtual bool setOrderingMode (zorba::ordering_mode_t aMode);
1498- virtual void setRevalidationMode (zorba::validation_mode_t aMode);
1499-
1500- virtual bool setXPath1_0CompatibMode (zorba::xpath1_0compatib_mode_t aMode);
1501+ void disableFunction(const Item &aQName, int arity);
1502+
1503+ std::string getBaseURI () const;
1504+
1505+ ZorbaConstants::BoundarySpaceMode getBoundarySpacePolicy ();
1506+ ZorbaConstants::ConstructionMode getConstructionMode();
1507+ ZorbaConstants::PreserveMode getCopyNamespacesModePreserve();
1508+ ZorbaConstants::InheritMode getCopyNamespacesModeInherit();
1509+ ZorbaConstants::OrderEmptyMode getDefaultOrderForEmptySequences();
1510+ ZorbaConstants::OrderingMode getOrderingMode();
1511+ ZorbaConstants::RevalidationMode getRevalidationMode();
1512+ ZorbaConstants::XPath1_0CompatibleMode getXPath1_0CompatibMode();
1513+
1514+ std::string getDefaultCollation () const;
1515+ std::string getDefaultElementAndTypeNamespace () const;
1516+ std::string getDefaultFunctionNamespace () const;
1517+
1518+ std::vector< std::pair< std::string, std::string > > getNamespaceBindings ();
1519+
1520+ std::string getNamespaceURIByPrefix(const std::string &aPrefix) const;
1521+ bool getOption(const Item &aQName, std::string &aOptionValue) const;
1522+ void loadProlog (const std::string & aProlog, const CompilerHints &hints);
1523+
1524+ void getExternalVariables(Iterator& vars) const;
1525+
1526+ TypeIdentifier getCollectionType(const std::string &aCollectionUri);
1527+ TypeIdentifier getDocumentType(const std::string &aDocUri);
1528+ TypeIdentifier getContextItemStaticType();
1529+
1530+ void setContextItemStaticType(const TypeIdentifier &aType);
1531+
1532+ void resetTraceStream ();
1533+ bool setBaseURI (const std::string &aBaseURI);
1534+
1535+ bool setBoundarySpacePolicy (ZorbaConstants::BoundarySpaceMode aMode);
1536+ bool setConstructionMode (ZorbaConstants::ConstructionMode aMode);
1537+ bool setCopyNamespacesMode (ZorbaConstants::PreserveMode aPreserve, ZorbaConstants::InheritMode aInherit);
1538+ bool setDefaultOrderForEmptySequences (ZorbaConstants::OrderEmptyMode aMode);
1539+ bool setOrderingMode (ZorbaConstants::OrderingMode aMode);
1540+ void setRevalidationMode (ZorbaConstants::RevalidationMode aMode);
1541+
1542+ void setURIPath(std::vector< std::string > &aURIPath );
1543+ void setLIBPath(std::vector< std::string > &aLIBPath );
1544+ void setModulePath(std::vector< std::string > &aModulePath );
1545+
1546+ bool setXPath1_0CompatibMode (ZorbaConstants::XPath1_0CompatibleMode aMode);
1547+
1548+ void setDefaultCollation (const std::string &aURI);
1549+ bool setDefaultElementAndTypeNamespace (const std::string &aURI);
1550+ bool setDefaultFunctionNamespace (const std::string &aURI);
1551
1552 void destroy();
1553 }; // class StaticContext
1554
1555+#endif
1556\ No newline at end of file
1557
1558=== modified file 'swig/StaticContext.i'
1559--- swig/StaticContext.i 2012-03-23 17:32:07 +0000
1560+++ swig/StaticContext.i 2012-03-26 20:16:18 +0000
1561@@ -20,8 +20,6 @@
1562 #include <zorba/static_context_consts.h>
1563
1564
1565-StaticContext::StaticContext() {}
1566-
1567 StaticContext::StaticContext(const StaticContext& aStaticContext) :
1568 theStaticContext(aStaticContext.theStaticContext) {}
1569
1570@@ -31,65 +29,94 @@
1571 void StaticContext::addColation(const std::string& aURI)
1572 { theStaticContext->addCollation(aURI); }
1573
1574-bool StaticContext::addNamespace(const std::string& aPrefix,
1575- const std::string& aURI)
1576+bool StaticContext::addNamespace(const std::string& aPrefix, const std::string& aURI)
1577 { return theStaticContext->addNamespace(aPrefix, aURI); }
1578
1579-void StaticContext::addReference() const
1580- { theStaticContext->addReference(); }
1581-
1582-bool StaticContext::containsFunction(const std::string &aFnNameUri,
1583- const std::string &aFnNameLocal,
1584- int arity) const
1585- { return theStaticContext->containsFunction(aFnNameUri, aFnNameLocal,
1586- arity); }
1587+bool StaticContext::containsFunction(const std::string &aFnNameUri, const std::string &aFnNameLocal, int arity) const
1588+ { return theStaticContext->containsFunction(aFnNameUri, aFnNameLocal, arity); }
1589
1590 StaticContext StaticContext::createChildContext() const
1591 { return StaticContext(theStaticContext->createChildContext()); }
1592
1593-void StaticContext::declareOption (const Item &aQName,
1594- const std::string &aOptionVal)
1595+void StaticContext::declareOption (const Item &aQName, const std::string &aOptionVal)
1596 { return theStaticContext->declareOption(aQName.theItem, aOptionVal); }
1597
1598 void StaticContext::disableFunction (const Item &aQName, int arity)
1599 { theStaticContext->disableFunction( aQName.theItem, arity); }
1600
1601-void StaticContext::free ()
1602- { theStaticContext->free(); }
1603-
1604 std::string StaticContext::getBaseURI () const
1605 { return std::string(theStaticContext->getBaseURI().c_str()); }
1606
1607-zorba::boundary_space_mode_t StaticContext::getBoundarySpacePolicy() const
1608- { return theStaticContext->getBoundarySpacePolicy(); }
1609-
1610-zorba::construction_mode_t StaticContext::getConstructionMode () const
1611- { return theStaticContext->getConstructionMode(); }
1612-
1613-void StaticContext::getCopyNamespacesMode (zorba::preserve_mode_t &aPreserve, zorba::inherit_mode_t &aInherit) const
1614- { return theStaticContext->getCopyNamespacesMode(aPreserve, aInherit); }
1615+ZorbaConstants::BoundarySpaceMode StaticContext::getBoundarySpacePolicy()
1616+ {
1617+ ZorbaConstants::BoundarySpaceMode result = ZorbaConstants::PRESERVE_SPACE;
1618+ zorba::boundary_space_mode_t boundary = theStaticContext->getBoundarySpacePolicy();
1619+ if (boundary == zorba::strip_space) {
1620+ result = ZorbaConstants::STRIP_SPACE;
1621+ }
1622+ return result;
1623+ }
1624+
1625+ZorbaConstants::ConstructionMode StaticContext::getConstructionMode()
1626+ {
1627+ ZorbaConstants::ConstructionMode result = ZorbaConstants::STRIP_CONSTRUCTION;
1628+ zorba::construction_mode_t construction = theStaticContext->getConstructionMode();
1629+ if (construction == zorba::preserve_cons) {
1630+ result = ZorbaConstants::PRESERVE_CONSTRUCTION;
1631+ }
1632+ return result;
1633+ }
1634+
1635+ZorbaConstants::PreserveMode StaticContext::getCopyNamespacesModePreserve()
1636+ {
1637+ zorba::preserve_mode_t lPreserve;
1638+ zorba::inherit_mode_t lInherit;
1639+ ZorbaConstants::PreserveMode aPreserve = ZorbaConstants::NO_PRESERVE;
1640+ theStaticContext->getCopyNamespacesMode(lPreserve, lInherit);
1641+ if (lPreserve==zorba::preserve_ns) {
1642+ aPreserve = ZorbaConstants::PRESERVE;
1643+ }
1644+ return aPreserve;
1645+ }
1646+
1647+ZorbaConstants::InheritMode StaticContext::getCopyNamespacesModeInherit()
1648+ {
1649+ zorba::preserve_mode_t lPreserve;
1650+ zorba::inherit_mode_t lInherit;
1651+ ZorbaConstants::InheritMode aInherit = ZorbaConstants::NO_INHERIT;
1652+ theStaticContext->getCopyNamespacesMode(lPreserve, lInherit);
1653+ if (lInherit==zorba::inherit_ns) {
1654+ aInherit = ZorbaConstants::INHERIT;
1655+ }
1656+ return aInherit;
1657+ }
1658
1659 std::string StaticContext::getDefaultCollation () const
1660 { return std::string(theStaticContext->getDefaultCollation().c_str()); }
1661
1662 std::string StaticContext::getDefaultElementAndTypeNamespace () const
1663 {
1664- return std::string(theStaticContext->getDefaultElementAndTypeNamespace().
1665- c_str());
1666+ return std::string( theStaticContext->getDefaultElementAndTypeNamespace().c_str() );
1667 }
1668
1669 std::string StaticContext::getDefaultFunctionNamespace () const
1670 {
1671- return std::string(theStaticContext->getDefaultFunctionNamespace().c_str());
1672+ return std::string( theStaticContext->getDefaultFunctionNamespace().c_str() );
1673 }
1674
1675-zorba::order_empty_mode_t StaticContext::getDefaultOrderForEmptySequences() const
1676- { return theStaticContext->getDefaultOrderForEmptySequences(); }
1677+ZorbaConstants::OrderEmptyMode StaticContext::getDefaultOrderForEmptySequences()
1678+ {
1679+ ZorbaConstants::OrderEmptyMode result = ZorbaConstants::EMPTY_GREATEST;
1680+ zorba::order_empty_mode_t order = theStaticContext->getDefaultOrderForEmptySequences();
1681+ if (order == zorba::empty_least) {
1682+ result = ZorbaConstants::EMPTY_LEAST;
1683+ }
1684+ return result;
1685+ }
1686
1687 std::string StaticContext::getNamespaceURIByPrefix(const std::string &aPrefix) const
1688 {
1689- return std::string(theStaticContext->getNamespaceURIByPrefix(aPrefix).
1690- c_str());
1691+ return std::string( theStaticContext->getNamespaceURIByPrefix(aPrefix).c_str() );
1692 }
1693
1694 bool StaticContext::getOption(const Item &aQName, std::string &aOptionValue) const
1695@@ -98,40 +125,108 @@
1696 return theStaticContext->getOption(aQName.theItem, optVal);
1697 }
1698
1699-zorba::ordering_mode_t StaticContext::getOrderingMode () const
1700- { return theStaticContext->getOrderingMode(); }
1701-
1702-long StaticContext::getRefCount () const
1703- { return theStaticContext->getRefCount(); }
1704-
1705-zorba::validation_mode_t StaticContext::getRevalidationMode ()
1706- { return theStaticContext->getRevalidationMode(); }
1707-
1708-zorba::xpath1_0compatib_mode_t StaticContext::getXPath1_0CompatibMode () const
1709- { return theStaticContext->getXPath1_0CompatibMode(); }
1710-
1711-void StaticContext::loadProlog (const std::string & aProlog,
1712- const CompilerHints &hints)
1713+ZorbaConstants::OrderingMode StaticContext::getOrderingMode ()
1714+ {
1715+ ZorbaConstants::OrderingMode result = ZorbaConstants::ORDERED;
1716+ zorba::ordering_mode_t order = theStaticContext->getOrderingMode();
1717+ if (order == zorba::unordered) {
1718+ result = ZorbaConstants::UNORDERED;
1719+ }
1720+ return result;
1721+ }
1722+
1723+ZorbaConstants::RevalidationMode StaticContext::getRevalidationMode ()
1724+ {
1725+ ZorbaConstants::RevalidationMode result = ZorbaConstants::VALIDATE_SKIP;
1726+ zorba::validation_mode_t revalidation = theStaticContext->getRevalidationMode();
1727+ if (revalidation == zorba::validate_lax) {
1728+ result = ZorbaConstants::VALIDATE_LAX;
1729+ } else if (revalidation == zorba::validate_strict) {
1730+ result = ZorbaConstants::VALIDATE_STRICT;
1731+ }
1732+ return result;
1733+ }
1734+
1735+ZorbaConstants::XPath1_0CompatibleMode StaticContext::getXPath1_0CompatibMode ()
1736+ {
1737+ ZorbaConstants::XPath1_0CompatibleMode result = ZorbaConstants::XPATH2_0;
1738+ zorba::xpath1_0compatib_mode_t comp = theStaticContext->getXPath1_0CompatibMode();
1739+ if (comp == zorba::xpath1_0) {
1740+ result = ZorbaConstants::XPATH1_0;
1741+ }
1742+ return result;
1743+ }
1744+
1745+void StaticContext::loadProlog (const std::string & aProlog, const CompilerHints &hints)
1746 { theStaticContext->loadProlog( aProlog, hints.theCompilerHints); }
1747
1748-void StaticContext::removeReference ()
1749- { theStaticContext->removeReference(); }
1750-
1751+void StaticContext::getExternalVariables(Iterator& vars) const
1752+ { theStaticContext->getExternalVariables( vars.theIterator ); }
1753+
1754+TypeIdentifier StaticContext::getCollectionType(const std::string & aCollectionUri)
1755+ { return TypeIdentifier(theStaticContext->getCollectionType(aCollectionUri)); }
1756+
1757+TypeIdentifier StaticContext::getDocumentType(const std::string &aDocUri)
1758+ { return TypeIdentifier(theStaticContext->getDocumentType(aDocUri)); }
1759+
1760+TypeIdentifier StaticContext::getContextItemStaticType()
1761+ { return TypeIdentifier(theStaticContext->getContextItemStaticType()); }
1762+
1763+std::vector< std::pair< std::string, std::string > > StaticContext::getNamespaceBindings () {
1764+ std::vector< std::pair< zorba::String, zorba::String > > items;
1765+ std::vector< std::pair< std::string, std::string > > result;
1766+ theStaticContext->getNamespaceBindings(items);
1767+ std::vector< std::pair< zorba::String, zorba::String > >::iterator iter;
1768+ for(iter = items.begin(); iter != items.end(); iter++) {
1769+ std::pair< std::string, std::string > pair;
1770+ pair.first = (*iter).first.c_str();
1771+ pair.second = (*iter).second.c_str();
1772+ result.push_back(pair);
1773+ }
1774+ return result;
1775+}
1776+
1777+
1778+
1779+void StaticContext::setContextItemStaticType(const TypeIdentifier &aType)
1780+ { theStaticContext->setContextItemStaticType(aType.theTypeIdentifier); }
1781+
1782 void StaticContext::resetTraceStream ()
1783 { theStaticContext->resetTraceStream(); }
1784
1785 bool StaticContext::setBaseURI (const std::string &aBaseURI)
1786 { return theStaticContext->setBaseURI(aBaseURI); }
1787
1788-bool StaticContext::setBoundarySpacePolicy (zorba::boundary_space_mode_t aMode)
1789- { return theStaticContext->setBoundarySpacePolicy(aMode); }
1790-
1791-bool StaticContext::setConstructionMode (zorba::construction_mode_t aMode)
1792- { return theStaticContext->setConstructionMode(aMode); }
1793-
1794-bool StaticContext::setCopyNamespacesMode (zorba::preserve_mode_t aPreserve,
1795- zorba::inherit_mode_t aInherit)
1796- { return theStaticContext->setCopyNamespacesMode(aPreserve, aInherit); }
1797+bool StaticContext::setBoundarySpacePolicy (ZorbaConstants::BoundarySpaceMode aMode)
1798+ {
1799+ zorba::boundary_space_mode_t lMode = zorba::strip_space;
1800+ if (aMode == ZorbaConstants::PRESERVE_SPACE) {
1801+ lMode = zorba::preserve_space;
1802+ }
1803+ return theStaticContext->setBoundarySpacePolicy(lMode);
1804+ }
1805+
1806+bool StaticContext::setConstructionMode (ZorbaConstants::ConstructionMode aMode)
1807+ {
1808+ zorba::construction_mode_t lMode = zorba::preserve_cons;
1809+ if (aMode == ZorbaConstants::STRIP_CONSTRUCTION) {
1810+ lMode = zorba::strip_cons;
1811+ }
1812+ return theStaticContext->setConstructionMode(lMode);
1813+ }
1814+
1815+bool StaticContext::setCopyNamespacesMode (ZorbaConstants::PreserveMode aPreserve, ZorbaConstants::InheritMode aInherit)
1816+ {
1817+ zorba::preserve_mode_t lPreserve = zorba::no_preserve_ns;
1818+ zorba::inherit_mode_t lInherit = zorba::no_inherit_ns;
1819+ if (aPreserve == ZorbaConstants::PRESERVE) {
1820+ lPreserve = zorba::preserve_ns;
1821+ }
1822+ if (aInherit == ZorbaConstants::INHERIT) {
1823+ lInherit = zorba::inherit_ns;
1824+ }
1825+ return theStaticContext->setCopyNamespacesMode(lPreserve, lInherit);
1826+ }
1827
1828 void StaticContext::setDefaultCollation (const std::string &aURI)
1829 { theStaticContext->setDefaultCollation(aURI); }
1830@@ -142,17 +237,76 @@
1831 bool StaticContext::setDefaultFunctionNamespace (const std::string &aURI)
1832 { return theStaticContext->setDefaultFunctionNamespace(aURI); }
1833
1834-bool StaticContext::setDefaultOrderForEmptySequences (zorba::order_empty_mode_t aMode)
1835- { return theStaticContext->setDefaultOrderForEmptySequences(aMode); }
1836-
1837-bool StaticContext::setOrderingMode (zorba::ordering_mode_t aMode)
1838- { return theStaticContext->setOrderingMode(aMode); }
1839-
1840-void StaticContext::setRevalidationMode (zorba::validation_mode_t aMode)
1841- { return theStaticContext->setRevalidationMode(aMode); }
1842-
1843-bool StaticContext::setXPath1_0CompatibMode (zorba::xpath1_0compatib_mode_t aMode)
1844- { return theStaticContext->setXPath1_0CompatibMode(aMode); }
1845+bool StaticContext::setDefaultOrderForEmptySequences (ZorbaConstants::OrderEmptyMode aMode)
1846+ {
1847+ zorba::order_empty_mode_t lMode = zorba::empty_greatest;
1848+ if (aMode == ZorbaConstants::EMPTY_LEAST) {
1849+ lMode = zorba::empty_least;
1850+ }
1851+ return theStaticContext->setDefaultOrderForEmptySequences(lMode);
1852+ }
1853+
1854+bool StaticContext::setOrderingMode (ZorbaConstants::OrderingMode aMode)
1855+ {
1856+ zorba::ordering_mode_t lMode = zorba::ordered;
1857+ if (aMode == ZorbaConstants::UNORDERED) {
1858+ lMode = zorba::unordered;
1859+ }
1860+ return theStaticContext->setOrderingMode(lMode);
1861+ }
1862+
1863+void StaticContext::setRevalidationMode (ZorbaConstants::RevalidationMode aMode)
1864+ {
1865+ zorba::validation_mode_t lMode = zorba::validate_skip;
1866+ if (aMode == ZorbaConstants::VALIDATE_LAX) {
1867+ lMode = zorba::validate_lax;
1868+ } else if (aMode == ZorbaConstants::VALIDATE_STRICT) {
1869+ lMode = zorba::validate_strict;
1870+ }
1871+ return theStaticContext->setRevalidationMode(lMode);
1872+ }
1873+
1874+void StaticContext::setURIPath(std::vector< std::string > &aURIPath )
1875+ {
1876+ std::vector< zorba::String > lURIPath;
1877+ lURIPath.reserve(aURIPath.size());
1878+ std::vector< std::string >::iterator iter;
1879+ for(iter = aURIPath.begin(); iter != aURIPath.end(); iter++) {
1880+ lURIPath.push_back((*iter));
1881+ }
1882+ theStaticContext->setURIPath(lURIPath);
1883+ }
1884+
1885+void StaticContext::setLIBPath(std::vector< std::string > &aLIBPath )
1886+ {
1887+ std::vector< zorba::String > lLIBPath;
1888+ lLIBPath.reserve(aLIBPath.size());
1889+ std::vector< std::string >::iterator iter;
1890+ for(iter = aLIBPath.begin(); iter != aLIBPath.end(); iter++) {
1891+ lLIBPath.push_back((*iter));
1892+ }
1893+ theStaticContext->setLibPath(lLIBPath);
1894+ }
1895+
1896+void StaticContext::setModulePath(std::vector< std::string > &aModulePath )
1897+ {
1898+ std::vector< zorba::String > lModulePath;
1899+ lModulePath.reserve(aModulePath.size());
1900+ std::vector< std::string >::iterator iter;
1901+ for(iter = aModulePath.begin(); iter != aModulePath.end(); iter++) {
1902+ lModulePath.push_back((*iter));
1903+ }
1904+ theStaticContext->setModulePaths(lModulePath);
1905+ }
1906+
1907+bool StaticContext::setXPath1_0CompatibMode (ZorbaConstants::XPath1_0CompatibleMode aMode)
1908+ {
1909+ zorba::xpath1_0compatib_mode_t lMode = zorba::xpath2_0;
1910+ if (aMode == ZorbaConstants::XPATH1_0) {
1911+ lMode = zorba::xpath1_0;
1912+ }
1913+ return theStaticContext->setXPath1_0CompatibMode(lMode);
1914+ }
1915
1916 void StaticContext::destroy()
1917 { theStaticContext = 0; }
1918@@ -165,7 +319,7 @@
1919 %} // end Implementation
1920
1921
1922- // Interface
1923+// Interface
1924
1925 %rename(XPath1_0CompatibModeEnum) zorba::xpath1_0compatib_mode_t;
1926 %rename(XPATH2_0) xpath2_0;
1927
1928=== modified file 'swig/Store.i'
1929--- swig/Store.i 2012-03-23 17:32:07 +0000
1930+++ swig/Store.i 2012-03-26 20:16:18 +0000
1931@@ -15,6 +15,8 @@
1932 */
1933
1934 %{ // start Implementation
1935+
1936+#include <zorba/store_consts.h>
1937
1938 class Store
1939 {
1940
1941=== added file 'swig/TypeIdentifier.h'
1942--- swig/TypeIdentifier.h 1970-01-01 00:00:00 +0000
1943+++ swig/TypeIdentifier.h 2012-03-26 20:16:18 +0000
1944@@ -0,0 +1,97 @@
1945+/*
1946+ * Copyright 2006-2008 The FLWOR Foundation.
1947+ *
1948+ * Licensed under the Apache License, Version 2.0 (the "License");
1949+ * you may not use this file except in compliance with the License.
1950+ * You may obtain a copy of the License at
1951+ *
1952+ * http://www.apache.org/licenses/LICENSE-2.0
1953+ *
1954+ * Unless required by applicable law or agreed to in writing, software
1955+ * distributed under the License is distributed on an "AS IS" BASIS,
1956+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1957+ * See the License for the specific language governing permissions and
1958+ * limitations under the License.
1959+ */
1960+
1961+#ifndef API_TYPE_IDENTIFIER_H
1962+#define API_TYPE_IDENTIFIER_H
1963+
1964+class IdentTypes {
1965+public:
1966+ typedef enum {
1967+ NAMED_TYPE,
1968+ ELEMENT_TYPE,
1969+ ATTRIBUTE_TYPE,
1970+ DOCUMENT_TYPE,
1971+ PI_TYPE,
1972+ TEXT_TYPE,
1973+ COMMENT_TYPE,
1974+ ANY_NODE_TYPE,
1975+ ITEM_TYPE,
1976+ EMPTY_TYPE,
1977+ INVALID_TYPE,
1978+ } Kind;
1979+
1980+ typedef enum {
1981+ QUANT_ONE,
1982+ QUANT_QUESTION,
1983+ QUANT_PLUS,
1984+ QUANT_STAR,
1985+ } Quantifier;
1986+};
1987+
1988+class TypeIdentifier
1989+{
1990+ friend class StaticContext;
1991+private:
1992+ zorba::TypeIdentifier_t theTypeIdentifier;
1993+ static zorba::IdentTypes::quantifier_t convertQuantifier(IdentTypes::Quantifier quantifier);
1994+
1995+public:
1996+ TypeIdentifier (const TypeIdentifier& aTypeIdentifier) : theTypeIdentifier(aTypeIdentifier.theTypeIdentifier) {}
1997+ TypeIdentifier (const zorba::TypeIdentifier_t& aZTypeIdentifier) : theTypeIdentifier(aZTypeIdentifier) {}
1998+
1999+ TypeIdentifier getContentType();
2000+ IdentTypes::Kind getKind();
2001+ const std::string getLocalName();
2002+ IdentTypes::Quantifier getQuantifier();
2003+ long getRefCount();
2004+ const std::string getUri();
2005+ bool isLocalNameWildcard();
2006+ bool isUriWildcard();
2007+
2008+ static TypeIdentifier
2009+ createAnyNodeType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
2010+
2011+ static TypeIdentifier
2012+ createAttributeType (const std::string &uri, bool uriWildcard, const std::string &localNameName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
2013+
2014+ static TypeIdentifier
2015+ createCommentType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
2016+
2017+ static TypeIdentifier
2018+ createDocumentType (TypeIdentifier contentType, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
2019+
2020+ static TypeIdentifier
2021+ createElementType (const std::string &uri, bool uriWildcard, const std::string &localName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
2022+
2023+ static TypeIdentifier
2024+ createEmptyType();
2025+
2026+ static TypeIdentifier
2027+ createItemType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
2028+
2029+ static TypeIdentifier
2030+ createNamedType (const std::string &uri, const std::string &localName, IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
2031+
2032+ static TypeIdentifier
2033+ createPIType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
2034+
2035+ static TypeIdentifier
2036+ createTextType (IdentTypes::Quantifier quantifier=IdentTypes::QUANT_ONE);
2037+
2038+}; // class TypeIdentifier
2039+
2040+
2041+#endif
2042\ No newline at end of file
2043
2044=== added file 'swig/TypeIdentifier.i'
2045--- swig/TypeIdentifier.i 1970-01-01 00:00:00 +0000
2046+++ swig/TypeIdentifier.i 2012-03-26 20:16:18 +0000
2047@@ -0,0 +1,197 @@
2048+/*
2049+ * Copyright 2006-2008 The FLWOR Foundation.
2050+ *
2051+ * Licensed under the Apache License, Version 2.0 (the "License");
2052+ * you may not use this file except in compliance with the License.
2053+ * You may obtain a copy of the License at
2054+ *
2055+ * http://www.apache.org/licenses/LICENSE-2.0
2056+ *
2057+ * Unless required by applicable law or agreed to in writing, software
2058+ * distributed under the License is distributed on an "AS IS" BASIS,
2059+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2060+ * See the License for the specific language governing permissions and
2061+ * limitations under the License.
2062+ */
2063+
2064+%{ // start Implementation
2065+
2066+ zorba::IdentTypes::quantifier_t
2067+ TypeIdentifier::convertQuantifier(IdentTypes::Quantifier quantifier)
2068+ {
2069+ zorba::IdentTypes::quantifier_t result;
2070+ switch (quantifier) {
2071+ case IdentTypes::QUANT_ONE:
2072+ result = zorba::IdentTypes::QUANT_ONE;
2073+ break;
2074+ case IdentTypes::QUANT_QUESTION:
2075+ result = zorba::IdentTypes::QUANT_QUESTION;
2076+ break;
2077+ case IdentTypes::QUANT_PLUS:
2078+ result = zorba::IdentTypes::QUANT_PLUS;
2079+ break;
2080+ case IdentTypes::QUANT_STAR:
2081+ result = zorba::IdentTypes::QUANT_STAR;
2082+ break;
2083+ }
2084+ return result;
2085+ }
2086+
2087+ TypeIdentifier TypeIdentifier::getContentType()
2088+ {
2089+ return TypeIdentifier(theTypeIdentifier->getContentType());
2090+ }
2091+ IdentTypes::Kind TypeIdentifier::getKind()
2092+ {
2093+ zorba::IdentTypes::kind_t lKind = theTypeIdentifier->getKind();
2094+ IdentTypes::Kind result;
2095+ switch (lKind) {
2096+ case zorba::IdentTypes::NAMED_TYPE:
2097+ result = IdentTypes::NAMED_TYPE;
2098+ break;
2099+ case zorba::IdentTypes::ELEMENT_TYPE:
2100+ result = IdentTypes::ELEMENT_TYPE;
2101+ break;
2102+ case zorba::IdentTypes::ATTRIBUTE_TYPE:
2103+ result = IdentTypes::ATTRIBUTE_TYPE;
2104+ break;
2105+ case zorba::IdentTypes::DOCUMENT_TYPE:
2106+ result = IdentTypes::DOCUMENT_TYPE;
2107+ break;
2108+ case zorba::IdentTypes::PI_TYPE:
2109+ result = IdentTypes::PI_TYPE;
2110+ break;
2111+ case zorba::IdentTypes::TEXT_TYPE:
2112+ result = IdentTypes::TEXT_TYPE;
2113+ break;
2114+ case zorba::IdentTypes::COMMENT_TYPE:
2115+ result = IdentTypes::COMMENT_TYPE;
2116+ break;
2117+ case zorba::IdentTypes::ANY_NODE_TYPE:
2118+ result = IdentTypes::ANY_NODE_TYPE;
2119+ break;
2120+ case zorba::IdentTypes::ITEM_TYPE:
2121+ result = IdentTypes::ITEM_TYPE;
2122+ break;
2123+ case zorba::IdentTypes::EMPTY_TYPE:
2124+ result = IdentTypes::EMPTY_TYPE;
2125+ break;
2126+ case zorba::IdentTypes::INVALID_TYPE:
2127+ result = IdentTypes::INVALID_TYPE;
2128+ break;
2129+ default:
2130+ result = IdentTypes::ANY_NODE_TYPE;
2131+ break;
2132+ }
2133+ return result;
2134+ }
2135+ const std::string TypeIdentifier::getLocalName()
2136+ {
2137+ return std::string(theTypeIdentifier->getLocalName().c_str());
2138+ }
2139+ IdentTypes::Quantifier TypeIdentifier::getQuantifier()
2140+ {
2141+ zorba::IdentTypes::quantifier_t lQuantifier = theTypeIdentifier->getQuantifier();
2142+ IdentTypes::Quantifier result;
2143+ switch (lQuantifier) {
2144+ case zorba::IdentTypes::QUANT_ONE:
2145+ result = IdentTypes::QUANT_ONE;
2146+ break;
2147+ case zorba::IdentTypes::QUANT_QUESTION:
2148+ result = IdentTypes::QUANT_QUESTION;
2149+ break;
2150+ case zorba::IdentTypes::QUANT_PLUS:
2151+ result = IdentTypes::QUANT_PLUS;
2152+ break;
2153+ case zorba::IdentTypes::QUANT_STAR:
2154+ result = IdentTypes::QUANT_STAR;
2155+ break;
2156+ }
2157+ return result;
2158+ }
2159+ long TypeIdentifier::getRefCount()
2160+ {
2161+ return theTypeIdentifier->getRefCount();
2162+ }
2163+ const std::string TypeIdentifier::getUri()
2164+ {
2165+ return std::string(theTypeIdentifier->getUri().c_str());
2166+ }
2167+ bool TypeIdentifier::isLocalNameWildcard()
2168+ {
2169+ return theTypeIdentifier->isLocalNameWildcard();
2170+ }
2171+ bool TypeIdentifier::isUriWildcard()
2172+ {
2173+ return theTypeIdentifier->isUriWildcard();
2174+ }
2175+
2176+
2177+ // STATIC METHODS
2178+ TypeIdentifier
2179+ TypeIdentifier::createAnyNodeType (IdentTypes::Quantifier quantifier)
2180+ {
2181+ return TypeIdentifier( zorba::TypeIdentifier::createAnyNodeType ( convertQuantifier(quantifier) ) );
2182+ }
2183+
2184+ TypeIdentifier
2185+ TypeIdentifier::createAttributeType (const std::string &uri, bool uriWildcard, const std::string &localNameName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier)
2186+ {
2187+ return TypeIdentifier( zorba::TypeIdentifier::createAttributeType( uri, uriWildcard, localNameName, localNameWildcard, contentType.theTypeIdentifier, convertQuantifier(quantifier) ) );
2188+ }
2189+
2190+ TypeIdentifier
2191+ TypeIdentifier::createCommentType (IdentTypes::Quantifier quantifier)
2192+ {
2193+ return TypeIdentifier( zorba::TypeIdentifier::createCommentType ( convertQuantifier(quantifier) ) );
2194+ }
2195+
2196+ TypeIdentifier
2197+ TypeIdentifier::createDocumentType (TypeIdentifier contentType, IdentTypes::Quantifier quantifier)
2198+ {
2199+ return TypeIdentifier( zorba::TypeIdentifier::createDocumentType(contentType.theTypeIdentifier, convertQuantifier(quantifier) ) );
2200+ }
2201+
2202+ TypeIdentifier
2203+ TypeIdentifier::createElementType (const std::string &uri, bool uriWildcard, const std::string &localName, bool localNameWildcard, TypeIdentifier contentType, IdentTypes::Quantifier quantifier)
2204+ {
2205+ return TypeIdentifier( zorba::TypeIdentifier::createElementType(uri, uriWildcard, localName, localNameWildcard, contentType.theTypeIdentifier, convertQuantifier(quantifier) ) );
2206+ }
2207+
2208+ TypeIdentifier
2209+ TypeIdentifier::createEmptyType()
2210+ {
2211+ return TypeIdentifier( zorba::TypeIdentifier::createEmptyType() );
2212+ }
2213+
2214+ TypeIdentifier
2215+ TypeIdentifier::createItemType (IdentTypes::Quantifier quantifier)
2216+ {
2217+ return TypeIdentifier( zorba::TypeIdentifier::createItemType( convertQuantifier(quantifier) ) );
2218+ }
2219+
2220+ TypeIdentifier
2221+ TypeIdentifier::createNamedType (const std::string &uri, const std::string &localName, IdentTypes::Quantifier quantifier)
2222+ {
2223+ return TypeIdentifier( zorba::TypeIdentifier::createNamedType( uri, localName, convertQuantifier(quantifier) ) );
2224+ }
2225+
2226+ TypeIdentifier
2227+ TypeIdentifier::createPIType (IdentTypes::Quantifier quantifier)
2228+ {
2229+ return TypeIdentifier( zorba::TypeIdentifier::createPIType( convertQuantifier(quantifier) ) );
2230+ }
2231+
2232+ TypeIdentifier
2233+ TypeIdentifier::createTextType (IdentTypes::Quantifier quantifier)
2234+ {
2235+ return TypeIdentifier( zorba::TypeIdentifier::createTextType( convertQuantifier(quantifier) ) );
2236+ }
2237+
2238+ // END OF STATIC METHODS
2239+
2240+
2241+%} // end Implementation
2242+
2243+
2244+%include "TypeIdentifier.h"
2245
2246=== added file 'swig/XQuery.h'
2247--- swig/XQuery.h 1970-01-01 00:00:00 +0000
2248+++ swig/XQuery.h 2012-03-26 20:16:18 +0000
2249@@ -0,0 +1,47 @@
2250+/*
2251+ * Copyright 2006-2008 The FLWOR Foundation.
2252+ *
2253+ * Licensed under the Apache License, Version 2.0 (the "License");
2254+ * you may not use this file except in compliance with the License.
2255+ * You may obtain a copy of the License at
2256+ *
2257+ * http://www.apache.org/licenses/LICENSE-2.0
2258+ *
2259+ * Unless required by applicable law or agreed to in writing, software
2260+ * distributed under the License is distributed on an "AS IS" BASIS,
2261+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2262+ * See the License for the specific language governing permissions and
2263+ * limitations under the License.
2264+ */
2265+#ifndef API_XQUERY_H
2266+#define API_XQUERY_H
2267+
2268+class XQuery
2269+{
2270+private:
2271+ zorba::XQuery_t theQuery;
2272+ bool closed;
2273+
2274+public:
2275+ XQuery():closed(false) {}
2276+ XQuery(const XQuery& aXQuery) : theQuery(aXQuery.theQuery), closed(aXQuery.closed) {}
2277+ XQuery(zorba::XQuery_t aQuery) : theQuery(aQuery), closed(false) {}
2278+
2279+ std::string execute();
2280+ std::string printPlanAsXML();
2281+ std::string printPlanAsDOT();
2282+ void compile (const std::string &aQuery);
2283+ void compile (const std::string &aQuery, StaticContext &aStaticContext);
2284+
2285+#ifdef SWIGPYTHON
2286+ void executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy);
2287+#endif
2288+
2289+ void destroy();
2290+ Iterator iterator();
2291+ DynamicContext getDynamicContext();
2292+ StaticContext getStaticContext();
2293+ void getExternalVariables(Iterator& vars) const;
2294+}; // class XQuery
2295+
2296+#endif
2297\ No newline at end of file
2298
2299=== modified file 'swig/XQuery.i'
2300--- swig/XQuery.i 2012-03-23 17:32:07 +0000
2301+++ swig/XQuery.i 2012-03-26 20:16:18 +0000
2302@@ -16,332 +16,60 @@
2303
2304 %{ // start Implementation
2305
2306-class Iterator
2307-{
2308-protected:
2309- friend class DynamicContext;
2310- zorba::Iterator_t theIterator;
2311- zorba::Item theItem;
2312- bool theConsumed;
2313-
2314-public:
2315- Iterator() {}
2316- Iterator(const Iterator& anIterator)
2317- : theIterator(anIterator.theIterator),
2318- theItem(anIterator.theItem),
2319- theConsumed(false)
2320- {}
2321-
2322- Iterator(zorba::Iterator_t anIterator)
2323- : theIterator(anIterator),
2324- theConsumed(false)
2325- {}
2326-
2327- Iterator(zorba::Item& aItem)
2328- : theIterator(0),
2329- theItem(aItem),
2330- theConsumed(false)
2331- {}
2332-
2333- void open()
2334- {
2335- if (theIterator)
2336- theIterator->open();
2337- theConsumed = false;
2338- }
2339-
2340- bool next(Item& aItem);
2341-
2342- void close()
2343- {
2344- if (theIterator)
2345- theIterator->close();
2346- theConsumed = true;
2347- }
2348-
2349- void destroy()
2350- {
2351- theIterator = 0;
2352- }
2353-
2354-}; // class Iterator
2355-
2356-
2357-class Item
2358-{
2359- friend class Iterator;
2360- friend class StaticContext;
2361- friend class DocumentManager;
2362- friend class SingletonIterator;
2363- friend class DynamicContext;
2364- friend class ItemFactory;
2365-
2366-private:
2367- zorba::Item theItem;
2368-
2369-public:
2370- Item() {}
2371- Item(const Item& aItem) : theItem(aItem.theItem) {}
2372- Item(const zorba::Item& aZItem) : theItem(aZItem) {}
2373-
2374- static Item createEmptyItem()
2375- { return Item(); }
2376-
2377- std::string getStringValue() const
2378- { return std::string(theItem.getStringValue().c_str()); }
2379-
2380- std::string serialize() const
2381- {
2382- std::stringstream lStream;
2383- Zorba_SerializerOptions_t lOptions;
2384- zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(lOptions);
2385- zorba::SingletonItemSequence lSequence(theItem);
2386- lSerializer->serialize(&lSequence, lStream);
2387- return lStream.str();
2388- }
2389-
2390- Iterator getAtomizationValue () const
2391- { return Iterator(theItem.getAtomizationValue()); }
2392-
2393- Iterator getAttributes () const
2394- { return Iterator(theItem.getAttributes()); }
2395-
2396- bool getBooleanValue () const
2397- { return theItem.getBooleanValue(); }
2398-
2399- Iterator getChildren () const
2400- { return Iterator(theItem.getChildren()); }
2401-
2402- Item getEBV () const
2403- { return Item(theItem.getEBV()); }
2404-
2405- int getIntValue () const
2406- { return theItem.getIntValue(); }
2407-
2408- std::string getLocalName () const
2409- { return std::string(theItem.getLocalName().c_str()); }
2410-
2411- std::string getNamespace () const
2412- { return std::string(theItem.getNamespace().c_str()); }
2413-
2414- bool getNodeName (Item &aNodeName) const
2415- { return theItem.getNodeName( aNodeName.theItem ); }
2416-
2417- std::string getPrefix () const
2418- { return std::string(theItem.getPrefix().c_str()); }
2419-
2420- Item getType () const
2421- { return Item( theItem.getType() ); }
2422-
2423- unsigned int getUnsignedIntValue () const
2424- { return theItem.getUnsignedIntValue(); }
2425-
2426- bool isAtomic () const
2427- { return theItem.isAtomic(); }
2428-
2429- bool isNaN () const
2430- { return theItem.isNaN(); }
2431-
2432- bool isNode () const
2433- { return theItem.isNode(); }
2434-
2435- bool isNull () const
2436- { return theItem.isNull(); }
2437-
2438- bool isPosOrNegInf () const
2439- { return theItem.isPosOrNegInf(); }
2440-
2441- int getNodeKind () const
2442- { return theItem.getNodeKind(); }
2443-
2444-}; // class Item
2445-
2446-class DynamicContext
2447-{
2448-private:
2449- zorba::DynamicContext* theContext;
2450-
2451-public:
2452- DynamicContext()
2453- : theContext(0)
2454- {
2455- }
2456-
2457- DynamicContext(const DynamicContext& aCtx)
2458- : theContext(aCtx.theContext)
2459- {
2460- }
2461-
2462- DynamicContext(zorba::DynamicContext* aCtx)
2463- : theContext(aCtx)
2464- {
2465- }
2466-
2467- void
2468- setVariable(
2469- const std::string& aNamespace,
2470- const std::string& aLocalname,
2471- Iterator aIter)
2472- {
2473- theContext->setVariable(aNamespace, aLocalname, aIter.theIterator);
2474- }
2475-
2476- void
2477- setContextItem(Item aItem)
2478- {
2479- theContext->setContextItem(aItem.theItem);
2480- }
2481-};
2482-
2483-class XQuery
2484-{
2485-private:
2486- zorba::XQuery_t theQuery;
2487-
2488-public:
2489- XQuery() {}
2490- XQuery(const XQuery& aXQuery) : theQuery(aXQuery.theQuery) {}
2491- XQuery(zorba::XQuery_t aQuery) : theQuery(aQuery) {}
2492-
2493- std::string execute()
2494+ std::string XQuery::execute()
2495 {
2496 std::stringstream lStream;
2497 lStream << theQuery;
2498- return lStream.str();
2499+ std::string str = lStream.str();
2500+ return str;
2501 }
2502-
2503- void compile (const std::string &aQuery)
2504+
2505+ void XQuery::compile (const std::string &aQuery)
2506 {
2507 theQuery->compile(aQuery);
2508 }
2509
2510- void compile (const std::string &aQuery, StaticContext &aStaticContext )
2511+ void XQuery::compile (const std::string &aQuery, StaticContext &aStaticContext )
2512 {
2513 Zorba_CompilerHints_t hints;
2514 theQuery->compile(aQuery, aStaticContext.theStaticContext, hints);
2515 }
2516-
2517- std::string printPlanAsXML()
2518+
2519+ std::string XQuery::printPlanAsXML()
2520 {
2521 std::ostringstream lStream;
2522 theQuery->printPlan(lStream);
2523 return lStream.str();
2524 }
2525
2526- std::string printPlanAsDOT()
2527+ std::string XQuery::printPlanAsDOT()
2528 {
2529 std::ostringstream lStream;
2530 theQuery->printPlan(lStream, true);
2531 return lStream.str();
2532 }
2533-
2534- DynamicContext
2535- getDynamicContext()
2536+
2537+ DynamicContext XQuery::getDynamicContext()
2538 {
2539 return DynamicContext(theQuery->getDynamicContext());
2540 }
2541
2542+ StaticContext XQuery::getStaticContext()
2543+ {
2544+ return StaticContext( zorba::StaticContext_t( const_cast<zorba::StaticContext *>(theQuery->getStaticContext()) ) );
2545+ }
2546+
2547+ void XQuery::getExternalVariables(Iterator& vars) const
2548+ { theQuery->getExternalVariables( vars.theIterator ); }
2549+
2550 #ifdef SWIGPYTHON
2551- void executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy)
2552+ void XQuery::executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy)
2553 { theQuery->executeSAX(contentHandlerProxy); }
2554 #endif
2555
2556- void destroy() { theQuery = 0; }
2557- Iterator iterator() { return Iterator(theQuery->iterator()); }
2558-}; // class XQuery
2559-
2560-
2561-// remaining method definitions from Iterator
2562-bool
2563-Iterator::next(Item& aItem)
2564-{
2565- if (theIterator)
2566- {
2567- return theIterator->next(aItem.theItem);
2568- }
2569- else
2570- {
2571- if (!theConsumed)
2572- {
2573- aItem = theItem;
2574- return true;
2575- }
2576- else
2577- {
2578- return false;
2579- }
2580- }
2581-}
2582-
2583+ void XQuery::destroy() { theQuery = 0; }
2584+ Iterator XQuery::iterator() { return Iterator(theQuery->iterator()); }
2585
2586 %} // end Implementation
2587
2588-
2589-// Interfaces
2590-
2591-class DynamicContext
2592-{
2593-public:
2594- void
2595- setVariable(
2596- const std::string& aNamespace,
2597- const std::string& aLocalname,
2598- Iterator);
2599-
2600- void
2601- setContextItem(Item);
2602-};
2603-
2604-class Item
2605-{
2606-public:
2607- static Item createEmptyItem();
2608- std::string getStringValue() const;
2609- std::string serialize() const;
2610- Iterator getAtomizationValue () const;
2611- Iterator getAttributes () const;
2612- bool getBooleanValue () const;
2613- Iterator getChildren () const;
2614- Item getEBV () const;
2615- int getIntValue () const;
2616- std::string getLocalName () const;
2617- std::string getNamespace () const;
2618- bool getNodeName (Item &aNodeName) const;
2619- std::string getPrefix () const;
2620- Item getType () const;
2621- unsigned int getUnsignedIntValue () const;
2622-
2623- int getNodeKind() const;
2624- bool isAtomic () const;
2625- bool isNaN () const;
2626- bool isNode () const;
2627- bool isNull () const;
2628- bool isPosOrNegInf () const;
2629-}; // class Item
2630-
2631-class Iterator
2632-{
2633-public:
2634- void open();
2635- bool next(Item&);
2636- void close();
2637- void destroy();
2638-}; // class Iterator
2639-
2640-class XQuery
2641-{
2642-public:
2643- std::string execute();
2644- std::string printPlanAsXML();
2645- std::string printPlanAsDOT();
2646- void compile (const std::string &aQuery);
2647- void compile (const std::string &aQuery, StaticContext &aStaticContext);
2648-
2649-#ifdef SWIGPYTHON
2650- void executeSAX(SAX2ContentHandlerProxy* contentHandlerProxy);
2651-#endif
2652-
2653- void destroy();
2654- Iterator iterator();
2655- DynamicContext getDynamicContext();
2656-}; // class XQuery
2657+%include "XQuery.h"
2658\ No newline at end of file
2659
2660=== added file 'swig/XmlDataManager.h'
2661--- swig/XmlDataManager.h 1970-01-01 00:00:00 +0000
2662+++ swig/XmlDataManager.h 2012-03-26 20:16:18 +0000
2663@@ -0,0 +1,35 @@
2664+/*
2665+ * Copyright 2006-2012 The FLWOR Foundation.
2666+ *
2667+ * Licensed under the Apache License, Version 2.0 (the "License");
2668+ * you may not use this file except in compliance with the License.
2669+ * You may obtain a copy of the License at
2670+ *
2671+ * http://www.apache.org/licenses/LICENSE-2.0
2672+ *
2673+ * Unless required by applicable law or agreed to in writing, software
2674+ * distributed under the License is distributed on an "AS IS" BASIS,
2675+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2676+ * See the License for the specific language governing permissions and
2677+ * limitations under the License.
2678+ */
2679+#ifndef API_XML_DATA_MANAGER_H
2680+#define API_XML_DATA_MANAGER_H
2681+
2682+class XmlDataManager
2683+{
2684+private:
2685+ zorba::XmlDataManager* theManager;
2686+
2687+public:
2688+ XmlDataManager() : theManager(0) {}
2689+ XmlDataManager(const XmlDataManager& aMgr) : theManager(aMgr.theManager) {}
2690+ XmlDataManager(zorba::XmlDataManager* aMgr) : theManager(aMgr) {}
2691+
2692+ DocumentManager getDocumentManager();
2693+ CollectionManager getCollectionManager();
2694+ CollectionManager getW3CCollectionManager();
2695+ Iterator parseXML(const std::string& aDoc);
2696+
2697+};
2698+#endif
2699\ No newline at end of file
2700
2701=== modified file 'swig/XmlDataManager.i'
2702--- swig/XmlDataManager.i 2012-03-23 17:32:07 +0000
2703+++ swig/XmlDataManager.i 2012-03-26 20:16:18 +0000
2704@@ -1,5 +1,5 @@
2705 /*
2706- * Copyright 2006-2008 The FLWOR Foundation.
2707+ * Copyright 2006-2012 The FLWOR Foundation.
2708 *
2709 * Licensed under the Apache License, Version 2.0 (the "License");
2710 * you may not use this file except in compliance with the License.
2711@@ -16,54 +16,20 @@
2712
2713 %{ // start Implementation
2714
2715-
2716-class DocumentManager
2717-{
2718-private:
2719- zorba::DocumentManager* theManager;
2720-
2721-public:
2722- DocumentManager() : theManager(0) {}
2723- DocumentManager(const DocumentManager& aMgr) : theManager(aMgr.theManager) {}
2724- DocumentManager(zorba::DocumentManager* aMgr) : theManager(aMgr) {}
2725-
2726- void put(const std::string& aName, Item aDoc)
2727- {
2728- theManager->put(aName, aDoc.theItem);
2729- }
2730-
2731- void remove(const std::string& aName)
2732- {
2733- theManager->remove(aName);
2734- }
2735-
2736- Item document(const std::string& aName)
2737- {
2738- return theManager->document(aName);
2739- }
2740-
2741- bool isAvailableDocument(const std::string& aName)
2742- {
2743- return theManager->isAvailableDocument(aName);
2744- }
2745-};
2746-
2747-class XmlDataManager
2748-{
2749-private:
2750- zorba::XmlDataManager* theManager;
2751-
2752-public:
2753- XmlDataManager() : theManager(0) {}
2754- XmlDataManager(const XmlDataManager& aMgr) : theManager(aMgr.theManager) {}
2755- XmlDataManager(zorba::XmlDataManager* aMgr) : theManager(aMgr) {}
2756-
2757- DocumentManager getDocumentManager()
2758+ DocumentManager XmlDataManager::getDocumentManager()
2759 {
2760 return DocumentManager(theManager->getDocumentManager());
2761 }
2762+ CollectionManager XmlDataManager::getCollectionManager()
2763+ {
2764+ return CollectionManager(theManager->getCollectionManager());
2765+ }
2766+ CollectionManager XmlDataManager::getW3CCollectionManager()
2767+ {
2768+ return CollectionManager(theManager->getW3CCollectionManager());
2769+ }
2770
2771- Iterator parseXML(const std::string& aDoc)
2772+ Iterator XmlDataManager::parseXML(const std::string& aDoc)
2773 {
2774 std::stringstream lDoc;
2775 lDoc << aDoc;
2776@@ -71,28 +37,7 @@
2777 return Iterator(lItem);
2778 }
2779
2780-};
2781
2782 %} // end Implementation
2783
2784-class DocumentManager
2785-{
2786-public:
2787- void put(const std::string& aName, Item aDoc);
2788-
2789- void remove(const std::string& aName);
2790-
2791- Item document(const std::string& aName);
2792-
2793- bool isAvailableDocument(const std::string& aName);
2794-};
2795-
2796-
2797-class XmlDataManager
2798-{
2799-public:
2800- DocumentManager getDocumentManager();
2801-
2802- Iterator parseXML(const std::string& aDoc);
2803-
2804-}; // class XmlDataManager
2805+%include "XmlDataManager.h"
2806
2807=== modified file 'swig/Zorba.i'
2808--- swig/Zorba.i 2012-03-23 17:32:07 +0000
2809+++ swig/Zorba.i 2012-03-26 20:16:18 +0000
2810@@ -15,27 +15,26 @@
2811 {
2812 return Zorba(zorba::Zorba::getInstance(aStore.getStore()));
2813 }
2814-
2815 ItemFactory getItemFactory()
2816 {
2817 return ItemFactory(theZorba->getItemFactory());
2818 }
2819-
2820+
2821 StaticContext createStaticContext()
2822 {
2823 return StaticContext(theZorba->createStaticContext());
2824 }
2825
2826+ XQuery createQuery()
2827+ {
2828+ return XQuery(theZorba->createQuery());
2829+ }
2830+
2831 XQuery compileQuery(const std::string& aStr)
2832 {
2833 return XQuery(theZorba->compileQuery(aStr));
2834 }
2835
2836- XQuery createQuery()
2837- {
2838- return XQuery(theZorba->createQuery());
2839- }
2840-
2841 XQuery compileQuery(
2842 const std::string& aStr,
2843 StaticContext &aStaticContext )
2844@@ -47,6 +46,22 @@
2845 )
2846 );
2847 }
2848+/*
2849+ XQuery compileQuery(const ZIStreamHelper& aZorbaStream)
2850+ {
2851+ zorbabuffer *buffer = new zorbabuffer(&const_cast<ZIStreamHelper &> (aZorbaStream));
2852+ std::istream stream = std::istream(buffer);
2853+ //zistream stream = zistream(buffer);
2854+ return XQuery(theZorba->compileQuery(stream));
2855+ }
2856+
2857+ XQuery compileQuery(const ZIStreamHelper& aZorbaStream, StaticContext &aStaticContext )
2858+ {
2859+ zorbabuffer *buffer = new zorbabuffer(&const_cast<ZIStreamHelper &> (aZorbaStream));
2860+ std::istream stream = std::istream(buffer);
2861+ return XQuery(theZorba->compileQuery(stream, aStaticContext.theStaticContext));
2862+ }
2863+*/
2864
2865 /*
2866 //--->> DiagnosticHandler implementations are postponed
2867@@ -95,6 +110,18 @@
2868 {
2869 theZorba->shutdown();
2870 }
2871+ std::string getVersion() {
2872+ return zorba::Zorba::version().getVersion();
2873+ }
2874+ int getMajorVersion() {
2875+ return zorba::Zorba::version().getMajorVersion();
2876+ }
2877+ int getMinorVersion() {
2878+ return zorba::Zorba::version().getMinorVersion();
2879+ }
2880+ int getPatchVersion() {
2881+ return zorba::Zorba::version().getPatchVersion();
2882+ }
2883
2884 }; // class Zorba
2885
2886@@ -111,8 +138,9 @@
2887 XQuery createQuery();
2888 XQuery compileQuery(const std::string& aStr);
2889 XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext );
2890+ //XQuery compileQuery(const ZIStreamHelper& aZorbaStream);
2891+ //XQuery compileQuery(const ZIStreamHelper& aZorbaStream, StaticContext &aStaticContext );
2892 ItemFactory getItemFactory();
2893-
2894 /*
2895 XQuery compileQuery(const std::string& aStr, DiagnosticHandler* aDiagnosticHandler);
2896 XQuery compileQuery(const std::string& aStr, StaticContext &aStaticContext,
2897@@ -122,5 +150,9 @@
2898 */
2899 XmlDataManager getXmlDataManager();
2900 void shutdown();
2901+ std::string getVersion();
2902+ int getMajorVersion();
2903+ int getMinorVersion();
2904+ int getPatchVersion();
2905
2906 }; // class Zorba
2907
2908=== modified file 'swig/java/CMakeLists.txt'
2909--- swig/java/CMakeLists.txt 2012-03-23 17:32:07 +0000
2910+++ swig/java/CMakeLists.txt 2012-03-26 20:16:18 +0000
2911@@ -60,8 +60,21 @@
2912 MESSAGE(STATUS "Java module install path: " ${JAVA_SITEARCH_DIR})
2913
2914 FILE(GLOB JAVA_SWIG_FILES "${CMAKE_CURRENT_BINARY_DIR}/*.java")
2915- CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")
2916- CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")
2917+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h" COPYONLY)
2918+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h" COPYONLY)
2919+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h" COPYONLY)
2920+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h" COPYONLY)
2921+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h" COPYONLY)
2922+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h" COPYONLY)
2923+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h" COPYONLY)
2924+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h" COPYONLY)
2925+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../SerializationOptions.h" "${CMAKE_CURRENT_BINARY_DIR}/SerializationOptions.h" COPYONLY)
2926+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Collection.h" "${CMAKE_CURRENT_BINARY_DIR}/Collection.h" COPYONLY)
2927+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY)
2928+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY)
2929+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY)
2930+# CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZInputStream.java" "${CMAKE_CURRENT_BINARY_DIR}/ZInputStream.java" COPYONLY)
2931+# CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/zistream.java" "${CMAKE_CURRENT_BINARY_DIR}/zistream.java" COPYONLY)
2932
2933 IF ( APPLE )
2934 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_SWIG_LIB_PREFIX}libzorba_api.jnilib DESTINATION ${JAVA_SITEARCH_DIR})
2935
2936=== modified file 'swig/java/zorba_api.i'
2937--- swig/java/zorba_api.i 2012-03-23 17:32:07 +0000
2938+++ swig/java/zorba_api.i 2012-03-26 20:16:18 +0000
2939@@ -20,5 +20,6 @@
2940 // don't do a JNI call for constants and enums.
2941 %javaconst(1);
2942
2943+
2944+
2945 %include ../zorba_api.i
2946-
2947
2948=== modified file 'swig/php/CMakeLists.txt'
2949--- swig/php/CMakeLists.txt 2012-03-23 17:32:07 +0000
2950+++ swig/php/CMakeLists.txt 2012-03-26 20:16:18 +0000
2951@@ -35,6 +35,8 @@
2952 ENDIF (APPLE)
2953
2954 IF (WIN32)
2955+ STRING(REGEX REPLACE "\\\\" "/" PHP5_LIBRARY "${PHP5_LIBRARY}")
2956+ MESSAGE (STATUS "SWIG PHP: Link library: " ${PHP5_LIBRARY})
2957 SWIG_LINK_LIBRARIES (zorba_api ${PHP5_LIBRARY})
2958 ENDIF (WIN32)
2959
2960@@ -47,6 +49,17 @@
2961
2962 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")
2963 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")
2964+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h")
2965+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h")
2966+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h")
2967+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h")
2968+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h")
2969+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h")
2970+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../SerializationOptions.h" "${CMAKE_CURRENT_BINARY_DIR}/SerializationOptions.h" COPYONLY)
2971+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Collection.h" "${CMAKE_CURRENT_BINARY_DIR}/Collection.h" COPYONLY)
2972+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY)
2973+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY)
2974+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY)
2975
2976 # The following fix was added because of the changes in CMake 2.8, which have the
2977 # result of naming the java binding library "liblibzorba_api.so" instead of "libzorba_api.so"
2978@@ -84,4 +97,5 @@
2979 DESTINATION share/php )
2980 ENDIF (MSVC_IDE)
2981 ENDIF (NOT WIN32 OR CYGWIN)
2982+ ADD_SUBDIRECTORY (tests)
2983 ENDIF (NOT PHP5_FOUND)
2984
2985=== added directory 'swig/php/tests'
2986=== added file 'swig/php/tests/CMakeLists.txt'
2987--- swig/php/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
2988+++ swig/php/tests/CMakeLists.txt 2012-03-26 20:16:18 +0000
2989@@ -0,0 +1,90 @@
2990+# Copyright 2006-2011 The FLWOR Foundation.
2991+#
2992+# Licensed under the Apache License, Version 2.0 (the "License");
2993+# you may not use this file except in compliance with the License.
2994+# You may obtain a copy of the License at
2995+#
2996+# http://www.apache.org/licenses/LICENSE-2.0
2997+#
2998+# Unless required by applicable law or agreed to in writing, software
2999+# distributed under the License is distributed on an "AS IS" BASIS,
3000+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3001+# See the License for the specific language governing permissions and
3002+# limitations under the License.
3003+MESSAGE(STATUS "Adding tests for PHP Binding")
3004+
3005+SET(phpPath ${CMAKE_BINARY_DIR}/swig/php)
3006+IF (MSVC_IDE)
3007+ SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php/@CMAKE_BUILD_TYPE@)
3008+ELSE (MSVC_IDE)
3009+ SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php)
3010+ENDIF (MSVC_IDE)
3011+SET(phpIncludePath ${CMAKE_BINARY_DIR}/swig/php)
3012+MESSAGE(STATUS "PHP Path:" ${phpPath})
3013+MESSAGE(STATUS "PHP Extension Path: " ${phpExtensionPath})
3014+MESSAGE(STATUS "PHP Include Path: " ${phpExtensionPath})
3015+
3016+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/php.ini.in ${CMAKE_CURRENT_BINARY_DIR}/php.ini)
3017+
3018+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/books.xml ${CMAKE_CURRENT_BINARY_DIR}/books.xml COPYONLY)
3019+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/compilerHints.xq ${CMAKE_CURRENT_BINARY_DIR}/compilerHints.xq COPYONLY)
3020+
3021+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test01.php ${CMAKE_CURRENT_BINARY_DIR}/test01.php)
3022+ADD_TEST("php_test01" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test01.php)
3023+SET_TESTS_PROPERTIES("php_test01" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
3024+
3025+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test02.php ${CMAKE_CURRENT_BINARY_DIR}/test02.php)
3026+ADD_TEST("php_test02" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test02.php)
3027+SET_TESTS_PROPERTIES("php_test02" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
3028+
3029+#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test03.php ${CMAKE_CURRENT_BINARY_DIR}/test03.php)
3030+#ADD_TEST("php_test03" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test03.php)
3031+#SET_TESTS_PROPERTIES("php_test03" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
3032+
3033+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test04.php ${CMAKE_CURRENT_BINARY_DIR}/test04.php)
3034+ADD_TEST("php_test04" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test04.php)
3035+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test04.xq ${CMAKE_CURRENT_BINARY_DIR}/test04.xq COPYONLY)
3036+SET_TESTS_PROPERTIES("php_test04" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
3037+
3038+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test05.php ${CMAKE_CURRENT_BINARY_DIR}/test05.php)
3039+ADD_TEST("php_test05" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test05.php)
3040+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test05.xq ${CMAKE_CURRENT_BINARY_DIR}/test05.xq COPYONLY)
3041+SET_TESTS_PROPERTIES("php_test05" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
3042+
3043+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test06.php ${CMAKE_CURRENT_BINARY_DIR}/test06.php)
3044+ADD_TEST("php_test06" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test06.php)
3045+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test06.xq ${CMAKE_CURRENT_BINARY_DIR}/test06.xq COPYONLY)
3046+SET_TESTS_PROPERTIES("php_test06" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
3047+
3048+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test07.php ${CMAKE_CURRENT_BINARY_DIR}/test07.php)
3049+ADD_TEST("php_test07" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test07.php)
3050+SET_TESTS_PROPERTIES("php_test07" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
3051+
3052+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test08.php ${CMAKE_CURRENT_BINARY_DIR}/test08.php)
3053+ADD_TEST("php_test08" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test08.php)
3054+SET_TESTS_PROPERTIES("php_test08" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
3055+
3056+#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test09.php ${CMAKE_CURRENT_BINARY_DIR}/test09.php)
3057+#ADD_TEST("php_test09" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test09.php)
3058+#SET_TESTS_PROPERTIES("php_test09" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
3059+
3060+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test10.php ${CMAKE_CURRENT_BINARY_DIR}/test10.php)
3061+ADD_TEST("php_test10" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test10.php)
3062+SET_TESTS_PROPERTIES("php_test10" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
3063+
3064+#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test11.php ${CMAKE_CURRENT_BINARY_DIR}/test11.php)
3065+#ADD_TEST("php_test11" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test11.php)
3066+#SET_TESTS_PROPERTIES("php_test11" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
3067+
3068+#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test12.php ${CMAKE_CURRENT_BINARY_DIR}/test12.php)
3069+#ADD_TEST("php_test12" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test12.php)
3070+#SET_TESTS_PROPERTIES("php_test12" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
3071+
3072+#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test13.php ${CMAKE_CURRENT_BINARY_DIR}/test13.php)
3073+#ADD_TEST("php_test13" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test13.php)
3074+#SET_TESTS_PROPERTIES("php_test13" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
3075+
3076+#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test14.php ${CMAKE_CURRENT_BINARY_DIR}/test14.php)
3077+#ADD_TEST("php_test14" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} test14.php)
3078+#SET_TESTS_PROPERTIES("php_test14" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
3079+
3080
3081=== added file 'swig/php/tests/books.xml'
3082--- swig/php/tests/books.xml 1970-01-01 00:00:00 +0000
3083+++ swig/php/tests/books.xml 2012-03-26 20:16:18 +0000
3084@@ -0,0 +1,11 @@
3085+<?xml version="1.0" encoding="UTF-8" ?>
3086+<books>
3087+ <book>
3088+ <title>Book 1</title>
3089+ <author>Author 1</author>
3090+ </book>
3091+ <book featured="YES">
3092+ <title>Book 2</title>
3093+ <author>Author 2</author>
3094+ </book>
3095+</books>
3096
3097=== added file 'swig/php/tests/compilerHints.xq'
3098--- swig/php/tests/compilerHints.xq 1970-01-01 00:00:00 +0000
3099+++ swig/php/tests/compilerHints.xq 2012-03-26 20:16:18 +0000
3100@@ -0,0 +1,4 @@
3101+for tumbling window $w in (2, 4, 6, 8, 10, 12, 14)
3102+ start at $s when fn:true()
3103+ only end at $e when $e - $s eq 2
3104+return avg($w)
3105
3106=== added file 'swig/php/tests/php.ini.in'
3107--- swig/php/tests/php.ini.in 1970-01-01 00:00:00 +0000
3108+++ swig/php/tests/php.ini.in 2012-03-26 20:16:18 +0000
3109@@ -0,0 +1,3 @@
3110+enable_dl=On
3111+extension_dir=@phpExtensionPath@
3112+include_path=".:@phpIncludePath@"
3113\ No newline at end of file
3114
3115=== added file 'swig/php/tests/test01.php'
3116--- swig/php/tests/test01.php 1970-01-01 00:00:00 +0000
3117+++ swig/php/tests/test01.php 2012-03-26 20:16:18 +0000
3118@@ -0,0 +1,29 @@
3119+<?
3120+/*
3121+ * Copyright 2006-2012 The FLWOR Foundation.
3122+ *
3123+ * Licensed under the Apache License, Version 2.0 (the "License");
3124+ * you may not use this file except in compliance with the License.
3125+ * You may obtain a copy of the License at
3126+ *
3127+ * http://www.apache.org/licenses/LICENSE-2.0
3128+ *
3129+ * Unless required by applicable law or agreed to in writing, software
3130+ * distributed under the License is distributed on an "AS IS" BASIS,
3131+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3132+ * See the License for the specific language governing permissions and
3133+ * limitations under the License.
3134+ */
3135+
3136+require '@phpPath@/Zorba/zorba_api_wrapper.php';
3137+
3138+print "Running: Get zorba instance and shutdown\n";
3139+
3140+$store = InMemoryStore::getInstance();
3141+$zorba = Zorba::getInstance($store);
3142+
3143+$zorba->shutdown();
3144+InMemoryStore::shutdown($store);
3145+
3146+print "Success";
3147+?>
3148\ No newline at end of file
3149
3150=== added file 'swig/php/tests/test02.php'
3151--- swig/php/tests/test02.php 1970-01-01 00:00:00 +0000
3152+++ swig/php/tests/test02.php 2012-03-26 20:16:18 +0000
3153@@ -0,0 +1,44 @@
3154+<?
3155+/*
3156+ * Copyright 2006-2012 The FLWOR Foundation.
3157+ *
3158+ * Licensed under the Apache License, Version 2.0 (the "License");
3159+ * you may not use this file except in compliance with the License.
3160+ * You may obtain a copy of the License at
3161+ *
3162+ * http://www.apache.org/licenses/LICENSE-2.0
3163+ *
3164+ * Unless required by applicable law or agreed to in writing, software
3165+ * distributed under the License is distributed on an "AS IS" BASIS,
3166+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3167+ * See the License for the specific language governing permissions and
3168+ * limitations under the License.
3169+ */
3170+
3171+require '@phpPath@/Zorba/zorba_api_wrapper.php';
3172+
3173+function test(Zorba $aZorba) {
3174+ $lQuery = $aZorba->compileQuery("(1,2,3,4,5)");
3175+ $iter = $lQuery->iterator();
3176+ $iter->open();
3177+ $item = Item::createEmptyItem();
3178+ while ($iter->next($item)) {
3179+ print $item->getStringValue()."\n";
3180+ }
3181+ $iter->close();
3182+ $iter->destroy();
3183+ return true;
3184+}
3185+
3186+
3187+$store = InMemoryStore::getInstance();
3188+$zorba = Zorba::getInstance($store);
3189+
3190+print "Running: Compile query string\n";
3191+test($zorba);
3192+print "Success";
3193+
3194+$zorba->shutdown();
3195+InMemoryStore::shutdown($store);
3196+
3197+?>
3198\ No newline at end of file
3199
3200=== added file 'swig/php/tests/test03.php'
3201--- swig/php/tests/test03.php 1970-01-01 00:00:00 +0000
3202+++ swig/php/tests/test03.php 2012-03-26 20:16:18 +0000
3203@@ -0,0 +1,48 @@
3204+<?
3205+/*
3206+ * Copyright 2006-2012 The FLWOR Foundation.
3207+ *
3208+ * Licensed under the Apache License, Version 2.0 (the "License");
3209+ * you may not use this file except in compliance with the License.
3210+ * You may obtain a copy of the License at
3211+ *
3212+ * http://www.apache.org/licenses/LICENSE-2.0
3213+ *
3214+ * Unless required by applicable law or agreed to in writing, software
3215+ * distributed under the License is distributed on an "AS IS" BASIS,
3216+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3217+ * See the License for the specific language governing permissions and
3218+ * limitations under the License.
3219+ */
3220+
3221+require '@phpPath@/Zorba/zorba_api_wrapper.php';
3222+
3223+class MyDiagnosticHandler(DiagnosticHandler handler) {
3224+ funtion error(self, *args) {
3225+ print "Error args: ", args;
3226+ }
3227+}
3228+
3229+function test(Zorba $aZorba)
3230+{
3231+ diagnosticHandler = MyDiagnosticHandler()
3232+ try {
3233+ xquery = zorba.compileQuery("1 div 0", diagnosticHandler);
3234+ print xquery.execute()
3235+ } catch (Exception e) {
3236+ print "Caught error: ";
3237+ }
3238+ return
3239+}
3240+
3241+$store = InMemoryStore::getInstance();
3242+$zorba = Zorba::getInstance($store);
3243+
3244+print "Running: Compile query string using Diagnostic Handler"
3245+test($zorba);
3246+print "Success";
3247+
3248+$zorba->shutdown();
3249+InMemoryStore::shutdown($store);
3250+
3251+?>
3252\ No newline at end of file
3253
3254=== added file 'swig/php/tests/test04.php'
3255--- swig/php/tests/test04.php 1970-01-01 00:00:00 +0000
3256+++ swig/php/tests/test04.php 2012-03-26 20:16:18 +0000
3257@@ -0,0 +1,43 @@
3258+<?
3259+/*
3260+ * Copyright 2006-2012 The FLWOR Foundation.
3261+ *
3262+ * Licensed under the Apache License, Version 2.0 (the "License");
3263+ * you may not use this file except in compliance with the License.
3264+ * You may obtain a copy of the License at
3265+ *
3266+ * http://www.apache.org/licenses/LICENSE-2.0
3267+ *
3268+ * Unless required by applicable law or agreed to in writing, software
3269+ * distributed under the License is distributed on an "AS IS" BASIS,
3270+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3271+ * See the License for the specific language governing permissions and
3272+ * limitations under the License.
3273+ */
3274+
3275+require '@phpPath@/Zorba/zorba_api_wrapper.php';
3276+
3277+function test(Zorba $aZorba) {
3278+ #Read and write result
3279+ $filename = 'test04.xq';
3280+ print "Executing: $filename\n";
3281+ $f = fopen($filename, 'r');
3282+ $contents = fread($f, filesize($filename));
3283+ fclose($f);
3284+ $xquery = $aZorba->compileQuery($contents);
3285+ $result = $xquery->execute();
3286+ print $result."\n";
3287+ return;
3288+}
3289+
3290+$store = InMemoryStore::getInstance();
3291+$zorba = Zorba::getInstance($store);
3292+
3293+print "Running: XQuery execute\n";
3294+test($zorba);
3295+print "Success";
3296+
3297+$zorba->shutdown();
3298+InMemoryStore::shutdown($store);
3299+
3300+?>
3301\ No newline at end of file
3302
3303=== added file 'swig/php/tests/test04.xq'
3304--- swig/php/tests/test04.xq 1970-01-01 00:00:00 +0000
3305+++ swig/php/tests/test04.xq 2012-03-26 20:16:18 +0000
3306@@ -0,0 +1,4 @@
3307+for tumbling window $w in (2, 4, 6, 8, 10, 12, 14)
3308+ start at $s when fn:true()
3309+ only end at $e when $e - $s eq 2
3310+return avg($w)
3311
3312=== added file 'swig/php/tests/test05.php'
3313--- swig/php/tests/test05.php 1970-01-01 00:00:00 +0000
3314+++ swig/php/tests/test05.php 2012-03-26 20:16:18 +0000
3315@@ -0,0 +1,43 @@
3316+<?
3317+/*
3318+ * Copyright 2006-2012 The FLWOR Foundation.
3319+ *
3320+ * Licensed under the Apache License, Version 2.0 (the "License");
3321+ * you may not use this file except in compliance with the License.
3322+ * You may obtain a copy of the License at
3323+ *
3324+ * http://www.apache.org/licenses/LICENSE-2.0
3325+ *
3326+ * Unless required by applicable law or agreed to in writing, software
3327+ * distributed under the License is distributed on an "AS IS" BASIS,
3328+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3329+ * See the License for the specific language governing permissions and
3330+ * limitations under the License.
3331+ */
3332+
3333+require '@phpPath@/Zorba/zorba_api_wrapper.php';
3334+
3335+function test(Zorba $aZorba) {
3336+ #Read and write result
3337+ $filename = 'test05.xq';
3338+ print "Executing: $filename\n";
3339+ $f = fopen($filename, 'r');
3340+ $contents = fread($f, filesize($filename));
3341+ fclose($f);
3342+ $xquery = $aZorba->compileQuery($contents);
3343+ $result = $xquery->printPlanAsXML();
3344+ print $result."\n";
3345+ return;
3346+}
3347+
3348+$store = InMemoryStore::getInstance();
3349+$zorba = Zorba::getInstance($store);
3350+
3351+print "Running: XQuery execute - printPlanAsXML\n";
3352+test($zorba);
3353+print "Success";
3354+
3355+$zorba->shutdown();
3356+InMemoryStore::shutdown($store);
3357+
3358+?>
3359\ No newline at end of file
3360
3361=== added file 'swig/php/tests/test05.xq'
3362--- swig/php/tests/test05.xq 1970-01-01 00:00:00 +0000
3363+++ swig/php/tests/test05.xq 2012-03-26 20:16:18 +0000
3364@@ -0,0 +1,7 @@
3365+for $x in (5,6,7,1,2,3,4)
3366+where $x < 4
3367+for $y in (4,9,6,8,2)
3368+let $z := $x * $y
3369+where $z > 20
3370+return
3371+<value x="{$x}" y="{$y}">{$z}</value>
3372\ No newline at end of file
3373
3374=== added file 'swig/php/tests/test06.php'
3375--- swig/php/tests/test06.php 1970-01-01 00:00:00 +0000
3376+++ swig/php/tests/test06.php 2012-03-26 20:16:18 +0000
3377@@ -0,0 +1,43 @@
3378+<?
3379+/*
3380+ * Copyright 2006-2012 The FLWOR Foundation.
3381+ *
3382+ * Licensed under the Apache License, Version 2.0 (the "License");
3383+ * you may not use this file except in compliance with the License.
3384+ * You may obtain a copy of the License at
3385+ *
3386+ * http://www.apache.org/licenses/LICENSE-2.0
3387+ *
3388+ * Unless required by applicable law or agreed to in writing, software
3389+ * distributed under the License is distributed on an "AS IS" BASIS,
3390+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3391+ * See the License for the specific language governing permissions and
3392+ * limitations under the License.
3393+ */
3394+
3395+require '@phpPath@/Zorba/zorba_api_wrapper.php';
3396+
3397+function test(Zorba $aZorba) {
3398+ #Read and write result
3399+ $filename = 'test06.xq';
3400+ print "Executing: $filename\n";
3401+ $f = fopen($filename, 'r');
3402+ $contents = fread($f, filesize($filename));
3403+ fclose($f);
3404+ $xquery = $aZorba->compileQuery($contents);
3405+ $result = $xquery->printPlanAsDOT();
3406+ print $result."\n";
3407+ return;
3408+}
3409+
3410+$store = InMemoryStore::getInstance();
3411+$zorba = Zorba::getInstance($store);
3412+
3413+print "Running: XQuery execute - printPlanAsDOT\n";
3414+test($zorba);
3415+print "Success";
3416+
3417+$zorba->shutdown();
3418+InMemoryStore::shutdown($store);
3419+
3420+?>
3421\ No newline at end of file
3422
3423=== added file 'swig/php/tests/test06.xq'
3424--- swig/php/tests/test06.xq 1970-01-01 00:00:00 +0000
3425+++ swig/php/tests/test06.xq 2012-03-26 20:16:18 +0000
3426@@ -0,0 +1,7 @@
3427+for $x in (5,6,7,1,2,3,4)
3428+where $x < 4
3429+for $y in (4,9,6,8,2)
3430+let $z := $x * $y
3431+where $z > 20
3432+return
3433+<value x="{$x}" y="{$y}">{$z}</value>
3434\ No newline at end of file
3435
3436=== added file 'swig/php/tests/test07.php'
3437--- swig/php/tests/test07.php 1970-01-01 00:00:00 +0000
3438+++ swig/php/tests/test07.php 2012-03-26 20:16:18 +0000
3439@@ -0,0 +1,56 @@
3440+<?
3441+/*
3442+ * Copyright 2006-2012 The FLWOR Foundation.
3443+ *
3444+ * Licensed under the Apache License, Version 2.0 (the "License");
3445+ * you may not use this file except in compliance with the License.
3446+ * You may obtain a copy of the License at
3447+ *
3448+ * http://www.apache.org/licenses/LICENSE-2.0
3449+ *
3450+ * Unless required by applicable law or agreed to in writing, software
3451+ * distributed under the License is distributed on an "AS IS" BASIS,
3452+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3453+ * See the License for the specific language governing permissions and
3454+ * limitations under the License.
3455+ */
3456+
3457+require '@phpPath@/Zorba/zorba_api_wrapper.php';
3458+
3459+function test(Zorba $aZorba) {
3460+ $filename = 'books.xml';
3461+ $f = fopen($filename, 'r');
3462+ $contents = fread($f, filesize($filename));
3463+ fclose($f);
3464+
3465+ $dataManager = $aZorba->getXmlDataManager();
3466+ $docIter = $dataManager->parseXML($contents);
3467+ $docIter->open();
3468+
3469+ $doc = Item::createEmptyItem();
3470+ $docIter->next($doc);
3471+
3472+ $docIter->close();
3473+ $docIter->destroy();
3474+
3475+ $docManager = $dataManager->getDocumentManager();
3476+ $docManager->put("my_fake_books.xml", $doc);
3477+ $xquery = $aZorba->compileQuery("doc('my_fake_books.xml')");
3478+
3479+ $result = $xquery->execute();
3480+ print $result."\n";
3481+
3482+ return;
3483+}
3484+
3485+$store = InMemoryStore::getInstance();
3486+$zorba = Zorba::getInstance($store);
3487+
3488+print "Running: XQuery execute - parsing XML\n";
3489+test($zorba);
3490+print "Success";
3491+
3492+$zorba->shutdown();
3493+InMemoryStore::shutdown($store);
3494+
3495+?>
3496\ No newline at end of file
3497
3498=== added file 'swig/php/tests/test08.php'
3499--- swig/php/tests/test08.php 1970-01-01 00:00:00 +0000
3500+++ swig/php/tests/test08.php 2012-03-26 20:16:18 +0000
3501@@ -0,0 +1,120 @@
3502+<?
3503+/*
3504+ * Copyright 2006-2012 The FLWOR Foundation.
3505+ *
3506+ * Licensed under the Apache License, Version 2.0 (the "License");
3507+ * you may not use this file except in compliance with the License.
3508+ * You may obtain a copy of the License at
3509+ *
3510+ * http://www.apache.org/licenses/LICENSE-2.0
3511+ *
3512+ * Unless required by applicable law or agreed to in writing, software
3513+ * distributed under the License is distributed on an "AS IS" BASIS,
3514+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3515+ * See the License for the specific language governing permissions and
3516+ * limitations under the License.
3517+ */
3518+
3519+require '@phpPath@/Zorba/zorba_api_wrapper.php';
3520+
3521+function println($string) {
3522+ print $string."\n";
3523+}
3524+
3525+function test(Zorba $aZorba) {
3526+ #Read and write result
3527+ println ("Executing: test08.xq");
3528+ $lines = '(1, xs:int(2),"bla", <a><b att="{(3, xs:int(4),"foo", "bar")}"/>text<!--a comment--><?pi?></a>)';
3529+ $xquery = $aZorba->compileQuery($lines);
3530+ $result = $xquery->execute();
3531+ println ($result);
3532+
3533+ println ("Iterator:");
3534+ $iterator = $xquery->iterator();
3535+
3536+ printIterator($iterator, "");
3537+
3538+ $handle = fopen('test8_result.xml', 'w');
3539+ fwrite($handle, $result);
3540+ fclose($handle);
3541+ return;
3542+}
3543+
3544+function printIterator($iterator, $pre) {
3545+ $item = Item::createEmptyItem();
3546+ $iterator->open();
3547+ while ($iterator->next($item)) {
3548+ printItem($item, $pre);
3549+ }
3550+ $iterator->close();
3551+}
3552+
3553+function printItem($item, $pre) {
3554+ if ($item->isAtomic()) {
3555+ $typeItem = $item->getType();
3556+ println ($pre . "Leaf Atomic: '" . $item->getStringValue() . "' \ttype:" . $typeItem->getStringValue());
3557+ return;
3558+ }
3559+
3560+ if ($item->isNode()) {
3561+ $kind = $item->getNodeKind();
3562+
3563+ if ($kind == 0) { # anyNode
3564+ println ($pre . 'Any node');
3565+ println ($pre . " Children:");
3566+ printIterator($item->getChildren() . $pre." ");
3567+ }
3568+ if ($kind == 1) { # doc
3569+ println ($pre . 'Doc');
3570+ println ($pre . " Children:");
3571+ printIterator($item->getChildren() . $pre." ");
3572+ }
3573+ if ($kind == 2) { # element
3574+ $nodeName = Item::createEmptyItem();
3575+ $item->getNodeName($nodeName);
3576+ $typeItem = $item->getType();
3577+ println ($pre . "Start Element: " . $nodeName->getStringValue() . " \ttype:" . $typeItem->getStringValue());
3578+ println ($pre . " Attributes:");
3579+ printIterator($item->getAttributes(), $pre." ");
3580+ println ($pre . " Children:");
3581+ printIterator($item->getChildren(), $pre." ");
3582+ println ($pre . "End Element: " . $nodeName->getStringValue());
3583+ }
3584+ if ($kind == 3) { # attribute
3585+ $nodeName = Item::createEmptyItem();
3586+ $item->getNodeName($nodeName);
3587+ $typeItem = $item->getType();
3588+ println ($pre . "Attribute: " . $nodeName->getStringValue() . "= '" . $item->getStringValue() . " \ttype:" . $typeItem->getStringValue());
3589+ println ($pre." Atomization value:");
3590+ printIterator($item->getAtomizationValue(), $pre." ");
3591+ }
3592+ if ($kind == 4) { # text
3593+ $typeItem = $item->getType();
3594+ println ($pre . "Text: " . $item->getStringValue() . " \ttype:" . $typeItem->getStringValue());
3595+ println ($pre." Atomization value:");
3596+ printIterator($item->getAtomizationValue(), $pre." ");
3597+ }
3598+ if ($kind == 5) { # pi
3599+ $nodeName = Item::createEmptyItem();
3600+ $item->getNodeName($nodeName);
3601+ println ($pre . "Pi: " . $nodeName->getStringValue());
3602+ }
3603+ if ($kind == 6) { # comment
3604+ println ($pre . "Comment: " . $item->getStringValue());
3605+ }
3606+ } else {
3607+ println ($pre."Item not Node, not Atomic");
3608+ }
3609+}
3610+
3611+$store = InMemoryStore::getInstance();
3612+$zorba = Zorba::getInstance($store);
3613+
3614+println ("Running: XQuery execute - Get Iterator and println (info from its items\n");
3615+test($zorba);
3616+println ("Success");
3617+
3618+$zorba->shutdown();
3619+InMemoryStore::shutdown($store);
3620+
3621+?>
3622\ No newline at end of file
3623
3624=== added file 'swig/php/tests/test09.php'
3625--- swig/php/tests/test09.php 1970-01-01 00:00:00 +0000
3626+++ swig/php/tests/test09.php 2012-03-26 20:16:18 +0000
3627@@ -0,0 +1,92 @@
3628+<?
3629+/*
3630+ * Copyright 2006-2012 The FLWOR Foundation.
3631+ *
3632+ * Licensed under the Apache License, Version 2.0 (the "License");
3633+ * you may not use this file except in compliance with the License.
3634+ * You may obtain a copy of the License at
3635+ *
3636+ * http://www.apache.org/licenses/LICENSE-2.0
3637+ *
3638+ * Unless required by applicable law or agreed to in writing, software
3639+ * distributed under the License is distributed on an "AS IS" BASIS,
3640+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3641+ * See the License for the specific language governing permissions and
3642+ * limitations under the License.
3643+ */
3644+
3645+require '@phpPath@/Zorba/zorba_api_wrapper.php';
3646+
3647+function test(Zorba $aZorba) {
3648+ $xquery = $aZorba->compileQuery("<a>text-a1<b at1='att1' at2='{1+2}'>text-b1</b>text-a2</a>");
3649+
3650+
3651+ $saxHandler = new SAX2ContentHandlerProxy();
3652+ $saxHandler->setStartDocumentHandler(startDocumentHandler);
3653+ $saxHandler->setEndDocumentHandler(endDocumentHandler);
3654+ $saxHandler->setStartElementHandler(startElementHandler);
3655+ $saxHandler->setEndElementHandler(endElementHandler);
3656+ $saxHandler->setCharactersHandler(charactersHandler);
3657+ $saxHandler->setProcessingInstructionHandler(processingInstructionHandler);
3658+ $saxHandler->setIgnorableWhitespaceHandler(ignorableWhitespaceHandler);
3659+ $saxHandler->setStartPrefixMappingHandler(startPrefixMappingHandler);
3660+ $saxHandler->setEndPrefixMappingHandler(endPrefixMappingHandler);
3661+ $saxHandler->setSkippedEntityHandler(skippedEntityHandler);
3662+ $xquery->executeSAX($saxHandler);
3663+
3664+ return;
3665+}
3666+
3667+function startDocumentHandler() {
3668+ print "Start Document";
3669+ return;
3670+}
3671+function endDocumentHandler() {
3672+ print "End Document";
3673+ return;
3674+}
3675+function startElementHandler($URI, $localName, $QName, $SAXAttributes) {
3676+ print "Start Element - " . $QName;
3677+ return;
3678+}
3679+function endElementHandler($URI, $localName, $QName) {
3680+ print "End Element - " . $QName;
3681+ return;
3682+}
3683+function charactersHandler($text) {
3684+ print "Characters - " . $text;
3685+ return;
3686+}
3687+function processingInstructionHandler($target, $data) {
3688+ print "Processing Instruction";
3689+ return;
3690+}
3691+function ignorableWhitespaceHandler($text) {
3692+ print "Ignorable Whitespace - " . $text;
3693+ return;
3694+}
3695+function startPrefixMappingHandler($prefix, $URI) {
3696+ print "Start Prefix Mapping - " . $prefix;
3697+ return;
3698+}
3699+function endPrefixMappingHandler($prefix) {
3700+ print "End Prefix Mapping - " . $prefix;
3701+ return;
3702+}
3703+function skippedEntityHandler($name) {
3704+ print "Skipped Entity - " . $name;
3705+ return;
3706+}
3707+
3708+
3709+$store = InMemoryStore::getInstance();
3710+$zorba = Zorba::getInstance($store);
3711+
3712+print "Running: XQuery execute - executeSAX\n";
3713+test($zorba);
3714+print "Success";
3715+
3716+$zorba->shutdown();
3717+InMemoryStore::shutdown($store);
3718+
3719+?>
3720\ No newline at end of file
3721
3722=== added file 'swig/php/tests/test10.php'
3723--- swig/php/tests/test10.php 1970-01-01 00:00:00 +0000
3724+++ swig/php/tests/test10.php 2012-03-26 20:16:18 +0000
3725@@ -0,0 +1,55 @@
3726+<?
3727+/*
3728+ * Copyright 2006-2012 The FLWOR Foundation.
3729+ *
3730+ * Licensed under the Apache License, Version 2.0 (the "License");
3731+ * you may not use this file except in compliance with the License.
3732+ * You may obtain a copy of the License at
3733+ *
3734+ * http://www.apache.org/licenses/LICENSE-2.0
3735+ *
3736+ * Unless required by applicable law or agreed to in writing, software
3737+ * distributed under the License is distributed on an "AS IS" BASIS,
3738+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3739+ * See the License for the specific language governing permissions and
3740+ * limitations under the License.
3741+ */
3742+
3743+require '@phpPath@/Zorba/zorba_api_wrapper.php';
3744+
3745+function test(Zorba $aZorba) {
3746+ $filename = 'books.xml';
3747+ $f = fopen($filename, 'r');
3748+ $contents = fread($f, filesize($filename));
3749+ fclose($f);
3750+
3751+ $dataManager = $aZorba->getXmlDataManager();
3752+ $docIter = $dataManager->parseXML($contents);
3753+ $docIter->open();
3754+
3755+ $doc = Item::createEmptyItem();
3756+ $docIter->next($doc);
3757+
3758+ $docIter->close();
3759+ $docIter->destroy();
3760+
3761+ $xquery = $aZorba->compileQuery(".");
3762+ $dynCtx = $xquery->getDynamicContext();
3763+ $dynCtx->setContextItem($doc);
3764+ print $xquery->execute()."\n";
3765+
3766+ return;
3767+}
3768+
3769+
3770+$store = InMemoryStore::getInstance();
3771+$zorba = Zorba::getInstance($store);
3772+
3773+print "Running: XQuery execute - Get Iterator and print info from its items\n";
3774+test($zorba);
3775+print "Success";
3776+
3777+$zorba->shutdown();
3778+InMemoryStore::shutdown($store);
3779+
3780+?>
3781\ No newline at end of file
3782
3783=== added file 'swig/php/tests/test11.php'
3784--- swig/php/tests/test11.php 1970-01-01 00:00:00 +0000
3785+++ swig/php/tests/test11.php 2012-03-26 20:16:18 +0000
3786@@ -0,0 +1,52 @@
3787+<?
3788+/*
3789+ * Copyright 2006-2012 The FLWOR Foundation.
3790+ *
3791+ * Licensed under the Apache License, Version 2.0 (the "License");
3792+ * you may not use this file except in compliance with the License.
3793+ * You may obtain a copy of the License at
3794+ *
3795+ * http://www.apache.org/licenses/LICENSE-2.0
3796+ *
3797+ * Unless required by applicable law or agreed to in writing, software
3798+ * distributed under the License is distributed on an "AS IS" BASIS,
3799+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3800+ * See the License for the specific language governing permissions and
3801+ * limitations under the License.
3802+ */
3803+
3804+//require '@phpPath@/Zorba/zorba_api_wrapper.php';
3805+require 'C:/dev/zapi/build/swig/php/Zorba/zorba_api_wrapper.php';
3806+
3807+class MyDiagnosticHandler(zorba_api.DiagnosticHandler):
3808+ def error(self, *args):
3809+ print "Error args: ", args
3810+
3811+def test(zorba):
3812+ #Read and write result
3813+ print 'Executing: compilerHints.xq'
3814+ f = open('compilerHints.xq', 'r')
3815+ lines = f.read()
3816+ f.close()
3817+ diagnosticHandler = MyDiagnosticHandler()
3818+ compilerHints = zorba_api.CompilerHints()
3819+ compilerHints.setOptimizationLevel(0)
3820+ xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler)
3821+
3822+ result = xquery.execute()
3823+ print result
3824+ return
3825+
3826+
3827+store = zorba_api.InMemoryStore_getInstance()
3828+zorba = zorba_api.Zorba_getInstance(store)
3829+
3830+print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 0"
3831+test(zorba)
3832+print "Success"
3833+
3834+
3835+zorba.shutdown()
3836+zorba_api.InMemoryStore_shutdown(store)
3837+
3838+?>
3839\ No newline at end of file
3840
3841=== added file 'swig/php/tests/test12.php'
3842--- swig/php/tests/test12.php 1970-01-01 00:00:00 +0000
3843+++ swig/php/tests/test12.php 2012-03-26 20:16:18 +0000
3844@@ -0,0 +1,52 @@
3845+<?
3846+/*
3847+ * Copyright 2006-2012 The FLWOR Foundation.
3848+ *
3849+ * Licensed under the Apache License, Version 2.0 (the "License");
3850+ * you may not use this file except in compliance with the License.
3851+ * You may obtain a copy of the License at
3852+ *
3853+ * http://www.apache.org/licenses/LICENSE-2.0
3854+ *
3855+ * Unless required by applicable law or agreed to in writing, software
3856+ * distributed under the License is distributed on an "AS IS" BASIS,
3857+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3858+ * See the License for the specific language governing permissions and
3859+ * limitations under the License.
3860+ */
3861+
3862+//require '@phpPath@/Zorba/zorba_api_wrapper.php';
3863+require 'C:/dev/zapi/build/swig/php/Zorba/zorba_api_wrapper.php';
3864+
3865+class MyDiagnosticHandler(zorba_api.DiagnosticHandler):
3866+ def error(self, *args):
3867+ print "Error args: ", args
3868+
3869+def test(zorba):
3870+ #Read and write result
3871+ print 'Executing: compilerHints.xq'
3872+ f = open('compilerHints.xq', 'r')
3873+ lines = f.read()
3874+ f.close()
3875+ diagnosticHandler = MyDiagnosticHandler()
3876+ compilerHints = zorba_api.CompilerHints()
3877+ compilerHints.setOptimizationLevel(1)
3878+ xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler)
3879+
3880+ result = xquery.execute()
3881+ print result
3882+ return
3883+
3884+
3885+store = zorba_api.InMemoryStore_getInstance()
3886+zorba = zorba_api.Zorba_getInstance(store)
3887+
3888+print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 1"
3889+test(zorba)
3890+print "Success"
3891+
3892+
3893+zorba.shutdown()
3894+zorba_api.InMemoryStore_shutdown(store)
3895+
3896+?>
3897\ No newline at end of file
3898
3899=== added file 'swig/php/tests/test13.php'
3900--- swig/php/tests/test13.php 1970-01-01 00:00:00 +0000
3901+++ swig/php/tests/test13.php 2012-03-26 20:16:18 +0000
3902@@ -0,0 +1,53 @@
3903+<?
3904+/*
3905+ * Copyright 2006-2012 The FLWOR Foundation.
3906+ *
3907+ * Licensed under the Apache License, Version 2.0 (the "License");
3908+ * you may not use this file except in compliance with the License.
3909+ * You may obtain a copy of the License at
3910+ *
3911+ * http://www.apache.org/licenses/LICENSE-2.0
3912+ *
3913+ * Unless required by applicable law or agreed to in writing, software
3914+ * distributed under the License is distributed on an "AS IS" BASIS,
3915+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3916+ * See the License for the specific language governing permissions and
3917+ * limitations under the License.
3918+ */
3919+
3920+//require '@phpPath@/Zorba/zorba_api_wrapper.php';
3921+require 'C:/dev/zapi/build/swig/php/Zorba/zorba_api_wrapper.php';
3922+
3923+class MyDiagnosticHandler(zorba_api.DiagnosticHandler):
3924+ def error(self, *args):
3925+ print "Error args: ", args
3926+
3927+def test(zorba):
3928+ #Read and write result
3929+ print 'Executing: compilerHints.xq'
3930+ f = open('compilerHints.xq', 'r')
3931+ lines = f.read()
3932+ f.close()
3933+ diagnosticHandler = MyDiagnosticHandler()
3934+ compilerHints = zorba_api.CompilerHints()
3935+ compilerHints.setLibModule(True)
3936+ compilerHints.setOptimizationLevel(0)
3937+ xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler)
3938+
3939+ result = xquery.execute()
3940+ print result
3941+ return
3942+
3943+
3944+store = zorba_api.InMemoryStore_getInstance()
3945+zorba = zorba_api.Zorba_getInstance(store)
3946+
3947+print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 0 - setLibModule(True)"
3948+test(zorba)
3949+print "Success"
3950+
3951+
3952+zorba.shutdown()
3953+zorba_api.InMemoryStore_shutdown(store)
3954+
3955+?>
3956\ No newline at end of file
3957
3958=== added file 'swig/php/tests/test14.php'
3959--- swig/php/tests/test14.php 1970-01-01 00:00:00 +0000
3960+++ swig/php/tests/test14.php 2012-03-26 20:16:18 +0000
3961@@ -0,0 +1,53 @@
3962+<?
3963+/*
3964+ * Copyright 2006-2012 The FLWOR Foundation.
3965+ *
3966+ * Licensed under the Apache License, Version 2.0 (the "License");
3967+ * you may not use this file except in compliance with the License.
3968+ * You may obtain a copy of the License at
3969+ *
3970+ * http://www.apache.org/licenses/LICENSE-2.0
3971+ *
3972+ * Unless required by applicable law or agreed to in writing, software
3973+ * distributed under the License is distributed on an "AS IS" BASIS,
3974+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3975+ * See the License for the specific language governing permissions and
3976+ * limitations under the License.
3977+ */
3978+
3979+//require '@phpPath@/Zorba/zorba_api_wrapper.php';
3980+require 'C:/dev/zapi/build/swig/php/Zorba/zorba_api_wrapper.php';
3981+
3982+class MyDiagnosticHandler(zorba_api.DiagnosticHandler):
3983+ def error(self, *args):
3984+ print "Error args: ", args
3985+
3986+def test(zorba):
3987+ #Read and write result
3988+ print 'Executing: compilerHints.xq'
3989+ f = open('compilerHints.xq', 'r')
3990+ lines = f.read()
3991+ f.close()
3992+ diagnosticHandler = MyDiagnosticHandler()
3993+ compilerHints = zorba_api.CompilerHints()
3994+ compilerHints.setLibModule(True)
3995+ compilerHints.setOptimizationLevel(1)
3996+ xquery = zorba.compileQuery(lines, compilerHints, diagnosticHandler)
3997+
3998+ result = xquery.execute()
3999+ print result
4000+ return
4001+
4002+
4003+store = zorba_api.InMemoryStore_getInstance()
4004+zorba = zorba_api.Zorba_getInstance(store)
4005+
4006+print "Running: CompileQuery string + Dignostinc handler + CompilerHint - with optimization 1 - setLibModule(True)"
4007+test(zorba)
4008+print "Success"
4009+
4010+
4011+zorba.shutdown()
4012+zorba_api.InMemoryStore_shutdown(store)
4013+
4014+?>
4015\ No newline at end of file
4016
4017=== added file 'swig/php/tests/zorba_api.php'
4018--- swig/php/tests/zorba_api.php 1970-01-01 00:00:00 +0000
4019+++ swig/php/tests/zorba_api.php 2012-03-26 20:16:18 +0000
4020@@ -0,0 +1,178 @@
4021+<?php
4022+/*
4023+ * Copyright 2006-2012 The FLWOR Foundation.
4024+ *
4025+ * Licensed under the Apache License, Version 2.0 (the "License");
4026+ * you may not use this file except in compliance with the License.
4027+ * You may obtain a copy of the License at
4028+ *
4029+ * http://www.apache.org/licenses/LICENSE-2.0
4030+ *
4031+ * Unless required by applicable law or agreed to in writing, software
4032+ * distributed under the License is distributed on an "AS IS" BASIS,
4033+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4034+ * See the License for the specific language governing permissions and
4035+ * limitations under the License.
4036+ */
4037+
4038+// Try to load our extension if it's not already loaded.
4039+if (!extension_loaded("zorba_api")) {
4040+ if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
4041+ if (!dl('zorba_api.dll')) return;
4042+ } else {
4043+ // PHP_SHLIB_SUFFIX is available as of PHP 4.3.0, for older PHP assume 'so'.
4044+ // It gives 'dylib' on MacOS X which is for libraries, modules are 'so'.
4045+ if (PHP_SHLIB_SUFFIX === 'PHP_SHLIB_SUFFIX' || PHP_SHLIB_SUFFIX === 'dylib') {
4046+ if (!dl('zorba_api.so')) return;
4047+ } else {
4048+ if (!dl('zorba_api.'.PHP_SHLIB_SUFFIX)) return;
4049+ }
4050+ }
4051+}
4052+
4053+class Item {
4054+ public $_cPtr=null;
4055+
4056+ static function createEmptyItem() {
4057+ $r=Item_createEmptyItem();
4058+ return is_resource($r) ? new Item($r) : $r;
4059+ }
4060+
4061+ function getStringValue() {
4062+ return Item_getStringValue($this->_cPtr);
4063+ }
4064+
4065+ function __construct() {
4066+ $this->_cPtr=new_Item();
4067+ }
4068+}
4069+
4070+class Iterator {
4071+ public $_cPtr=null;
4072+
4073+ function open() {
4074+ Iterator_open($this->_cPtr);
4075+ }
4076+
4077+ function next($arg1) {
4078+ return Iterator_next($this->_cPtr,$arg1);
4079+ }
4080+
4081+ function close() {
4082+ Iterator_close($this->_cPtr);
4083+ }
4084+
4085+ function destroy() {
4086+ Iterator_destroy($this->_cPtr);
4087+ }
4088+
4089+ function __construct($cPtr) {
4090+ $this->_cPtr=$cPtr;
4091+ }
4092+
4093+ public function __destruct() {
4094+ $this->destroy();
4095+ }
4096+}
4097+
4098+class XQuery {
4099+ public $_cPtr=null;
4100+
4101+ function execute() {
4102+ return XQuery_execute($this->_cPtr);
4103+ }
4104+
4105+ function isUpdateQuery() {
4106+ return XQuery_isUpdateQuery($this->_cPtr);
4107+ }
4108+
4109+ function applyUpdates() {
4110+ XQuery_applyUpdates($this->_cPtr);
4111+ }
4112+
4113+ function destroy() {
4114+ XQuery_destroy($this->_cPtr);
4115+ }
4116+
4117+ function iterator() {
4118+ $r=XQuery_iterator($this->_cPtr);
4119+ return is_resource($r) ? new Iterator($r) : $r;
4120+ }
4121+
4122+ function __construct($cPtr) {
4123+ $this->_cPtr=$cPtr;
4124+ }
4125+
4126+ function __destruct() {
4127+ $this->destroy();
4128+ }
4129+}
4130+
4131+class Store {
4132+ //public $_cPtr=null;
4133+
4134+ //function __construct() {
4135+ // $this->_cPtr=new_Store();
4136+ //}
4137+}
4138+
4139+class InMemoryStore extends Store {
4140+ public $_cPtr=null;
4141+
4142+ static function getInstance() {
4143+ $r=InMemoryStore_getInstance();
4144+ return is_resource($r) ? new InMemoryStore($r) : $r;
4145+ }
4146+
4147+ static function shutdown($arg1) {
4148+ InMemoryStore_shutdown($arg1);
4149+ }
4150+
4151+ private function __construct($cPtr) {
4152+ $this->_cPtr=$cPtr;
4153+ }
4154+}
4155+
4156+class XmlDataManager {
4157+ public $_cPtr=null;
4158+
4159+ function loadDocument($aName,$aContent) {
4160+ XmlDataManager_loadDocument($this->_cPtr,$aName,$aContent);
4161+ }
4162+
4163+ function deleteDocument($aName) {
4164+ return XmlDataManager_deleteDocument($this->_cPtr,$aName);
4165+ }
4166+
4167+ function __construct($cPtr) {
4168+ $this->_cPtr=$cPtr;
4169+ }
4170+}
4171+
4172+class Zorba {
4173+ public $_cPtr=null;
4174+
4175+ static function getInstance($arg1) {
4176+ $r=Zorba_getInstance($arg1->_cPtr);
4177+ return is_resource($r) ? new Zorba($r) : $r;
4178+ }
4179+
4180+ function compileQuery($aStr) {
4181+ $r=Zorba_compileQuery($this->_cPtr,$aStr);
4182+ return is_resource($r) ? new XQuery($r) : $r;
4183+ }
4184+
4185+ function getXmlDataManager() {
4186+ $r=Zorba_getXmlDataManager($this->_cPtr);
4187+ return is_resource($r) ? new XmlDataManager($r) : $r;
4188+ }
4189+
4190+ function shutdown() {
4191+ Zorba_shutdown($this->_cPtr);
4192+ }
4193+
4194+ private function __construct($cPtr) {
4195+ $this->_cPtr=$cPtr;
4196+ }
4197+}
4198+?>
4199
4200=== modified file 'swig/python/CMakeLists.txt'
4201--- swig/python/CMakeLists.txt 2012-03-23 17:32:07 +0000
4202+++ swig/python/CMakeLists.txt 2012-03-26 20:16:18 +0000
4203@@ -20,8 +20,13 @@
4204 SWIG_ADD_MODULE (zorba_api_python python zorba_api.i)
4205 SWIG_LINK_LIBRARIES (zorba_api_python zorba_simplestore ${PYTHON_LIBRARIES})
4206 SET_TARGET_PROPERTIES (_zorba_api_python PROPERTIES OUTPUT_NAME "_zorba_api")
4207- SET_PROPERTY( TARGET _zorba_api_python PROPERTY PROJECT_LABEL "Api_Python" )
4208-
4209+
4210+ IF (MSVC_IDE)
4211+ SET_PROPERTY( TARGET _zorba_api_python PROPERTY PROJECT_LABEL "Api_Python" )
4212+ SET_PROPERTY( TARGET _zorba_api_python PROPERTY LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/swig/python )
4213+ SET_PROPERTY( TARGET _zorba_api_python PROPERTY LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/swig/python )
4214+ ENDIF (MSVC_IDE)
4215+
4216 EXECUTE_PROCESS (
4217 COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig;print sysconfig.get_python_lib(0)"
4218 OUTPUT_VARIABLE PYTHON_INSTALL_PATH
4219@@ -31,6 +36,18 @@
4220 SET (PYTHON_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/share/python")
4221 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")
4222 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")
4223+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h")
4224+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h")
4225+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h")
4226+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h")
4227+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h")
4228+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h")
4229+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../SerializationOptions.h" "${CMAKE_CURRENT_BINARY_DIR}/SerializationOptions.h" COPYONLY)
4230+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Collection.h" "${CMAKE_CURRENT_BINARY_DIR}/Collection.h" COPYONLY)
4231+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY)
4232+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY)
4233+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY)
4234+
4235 MESSAGE (STATUS "SWIG Python: Python module install path: " ${PYTHON_INSTALL_PATH})
4236
4237 IF (NOT WIN32)
4238@@ -41,17 +58,10 @@
4239 DESTINATION ${PYTHON_INSTALL_PATH}
4240 )
4241 ELSE(NOT WIN32)
4242- IF (MSVC_IDE)
4243- INSTALL ( FILES
4244- ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/_zorba_api.pyd
4245- DESTINATION share/python
4246- COMPONENT "python_swig" )
4247- ELSE (MSVC_IDE)
4248 INSTALL ( FILES
4249 ${CMAKE_CURRENT_BINARY_DIR}/_zorba_api.pyd
4250 DESTINATION share/python
4251 COMPONENT "python_swig" )
4252- ENDIF (MSVC_IDE)
4253 ENDIF(NOT WIN32)
4254
4255 ADD_SUBDIRECTORY (tests)
4256
4257=== modified file 'swig/ruby/CMakeLists.txt'
4258--- swig/ruby/CMakeLists.txt 2012-03-23 17:32:07 +0000
4259+++ swig/ruby/CMakeLists.txt 2012-03-26 20:16:18 +0000
4260@@ -23,8 +23,9 @@
4261 IF (WIN32)
4262 SWIG_ADD_MODULE(zorba_api_ruby ruby zorba_api.i)
4263 SWIG_LINK_LIBRARIES(zorba_api_ruby zorba_simplestore ${RUBY_LIBRARY})
4264- SET_TARGET_PROPERTIES (zorba_api_ruby PROPERTIES OUTPUT_NAME "zorba_api")
4265+ SET_TARGET_PROPERTIES( zorba_api_ruby PROPERTIES OUTPUT_NAME "zorba_api")
4266 SET_TARGET_PROPERTIES( zorba_api_ruby PROPERTIES PROJECT_LABEL "Api_Ruby" )
4267+ SET_TARGET_PROPERTIES( zorba_api_ruby PROPERTIES SUFFIX ".so" )
4268 ELSE (WIN32)
4269 SWIG_ADD_MODULE(zorba_api ruby zorba_api.i)
4270 SWIG_LINK_LIBRARIES(zorba_api zorba_simplestore ${RUBY_LIBRARY})
4271@@ -52,7 +53,18 @@
4272 #STRING(REPLACE "/usr/" "" RUBY_SITEARCH_DIR "${RUBY_SITEARCH_DIR}" )
4273 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")
4274 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")
4275-
4276+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Item.h" "${CMAKE_CURRENT_BINARY_DIR}/Item.h")
4277+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Iterator.h" "${CMAKE_CURRENT_BINARY_DIR}/Iterator.h")
4278+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XQuery.h" "${CMAKE_CURRENT_BINARY_DIR}/XQuery.h")
4279+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DynamicContext.h" "${CMAKE_CURRENT_BINARY_DIR}/DynamicContext.h")
4280+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../XmlDataManager.h" "${CMAKE_CURRENT_BINARY_DIR}/XmlDataManager.h")
4281+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../TypeIdentifier.h" "${CMAKE_CURRENT_BINARY_DIR}/TypeIdentifier.h")
4282+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../SerializationOptions.h" "${CMAKE_CURRENT_BINARY_DIR}/SerializationOptions.h" COPYONLY)
4283+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../Collection.h" "${CMAKE_CURRENT_BINARY_DIR}/Collection.h" COPYONLY)
4284+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../CollectionManager.h" "${CMAKE_CURRENT_BINARY_DIR}/CollectionManager.h" COPYONLY)
4285+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../DocumentManager.h" "${CMAKE_CURRENT_BINARY_DIR}/DocumentManager.h" COPYONLY)
4286+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemSequence.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemSequence.h" COPYONLY)
4287+
4288 SET (RUBY_SITEARCH_DIR "${CMAKE_INSTALL_PREFIX}/share/ruby")
4289
4290 IF ( APPLE )
4291@@ -77,6 +89,8 @@
4292 ENDIF ( LINUX )
4293 ENDIF ( APPLE )
4294
4295+ ADD_SUBDIRECTORY (tests)
4296+
4297 ELSE (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
4298 MESSAGE(STATUS "SWIG Ruby: binding not generated because library and include files are not installed.")
4299 ENDIF (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
4300
4301=== added directory 'swig/ruby/tests'
4302=== added file 'swig/ruby/tests/CMakeLists.txt'
4303--- swig/ruby/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
4304+++ swig/ruby/tests/CMakeLists.txt 2012-03-26 20:16:18 +0000
4305@@ -0,0 +1,83 @@
4306+# Copyright 2006-2011 The FLWOR Foundation.
4307+#
4308+# Licensed under the Apache License, Version 2.0 (the "License");
4309+# you may not use this file except in compliance with the License.
4310+# You may obtain a copy of the License at
4311+#
4312+# http://www.apache.org/licenses/LICENSE-2.0
4313+#
4314+# Unless required by applicable law or agreed to in writing, software
4315+# distributed under the License is distributed on an "AS IS" BASIS,
4316+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4317+# See the License for the specific language governing permissions and
4318+# limitations under the License.
4319+MESSAGE(STATUS "Adding tests for Ruby Binding")
4320+
4321+IF (MSVC_IDE)
4322+ SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby/@CMAKE_BUILD_TYPE@)
4323+ELSE (MSVC_IDE)
4324+ SET(rubyPath ${CMAKE_BINARY_DIR}/swig/ruby)
4325+ENDIF (MSVC_IDE)
4326+
4327+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/books.xml ${CMAKE_CURRENT_BINARY_DIR}/books.xml COPYONLY)
4328+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/compilerHints.xq ${CMAKE_CURRENT_BINARY_DIR}/compilerHints.xq COPYONLY)
4329+
4330+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test01.rb ${CMAKE_CURRENT_BINARY_DIR}/test01.rb)
4331+ADD_TEST("ruby_test01" ${RUBY_EXECUTABLE} test01.rb)
4332+SET_TESTS_PROPERTIES("ruby_test01" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
4333+
4334+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test02.rb ${CMAKE_CURRENT_BINARY_DIR}/test02.rb)
4335+ADD_TEST("ruby_test02" ${RUBY_EXECUTABLE} test02.rb)
4336+SET_TESTS_PROPERTIES("ruby_test02" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
4337+
4338+#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test03.rb ${CMAKE_CURRENT_BINARY_DIR}/test03.rb)
4339+#ADD_TEST("ruby_test03" ${RUBY_EXECUTABLE} test03.rb)
4340+#SET_TESTS_PROPERTIES("ruby_test03" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
4341+
4342+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test04.rb ${CMAKE_CURRENT_BINARY_DIR}/test04.rb)
4343+ADD_TEST("ruby_test04" ${RUBY_EXECUTABLE} test04.rb)
4344+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test04.xq ${CMAKE_CURRENT_BINARY_DIR}/test04.xq COPYONLY)
4345+SET_TESTS_PROPERTIES("ruby_test04" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
4346+
4347+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test05.rb ${CMAKE_CURRENT_BINARY_DIR}/test05.rb)
4348+ADD_TEST("ruby_test05" ${RUBY_EXECUTABLE} test05.rb)
4349+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test05.xq ${CMAKE_CURRENT_BINARY_DIR}/test05.xq COPYONLY)
4350+SET_TESTS_PROPERTIES("ruby_test05" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
4351+
4352+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test06.rb ${CMAKE_CURRENT_BINARY_DIR}/test06.rb)
4353+ADD_TEST("ruby_test06" ${RUBY_EXECUTABLE} test06.rb)
4354+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test06.xq ${CMAKE_CURRENT_BINARY_DIR}/test06.xq COPYONLY)
4355+SET_TESTS_PROPERTIES("ruby_test06" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
4356+
4357+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test07.rb ${CMAKE_CURRENT_BINARY_DIR}/test07.rb)
4358+ADD_TEST("ruby_test07" ${RUBY_EXECUTABLE} test07.rb)
4359+SET_TESTS_PROPERTIES("ruby_test07" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
4360+
4361+# CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test08.rb ${CMAKE_CURRENT_BINARY_DIR}/test08.rb)
4362+# ADD_TEST("ruby_test08" ${RUBY_EXECUTABLE} test08.rb)
4363+# SET_TESTS_PROPERTIES("ruby_test08" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
4364+
4365+# CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test09.rb ${CMAKE_CURRENT_BINARY_DIR}/test09.rb)
4366+# ADD_TEST("ruby_test09" ${RUBY_EXECUTABLE} test09.rb)
4367+# SET_TESTS_PROPERTIES("ruby_test09" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
4368+
4369+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test10.rb ${CMAKE_CURRENT_BINARY_DIR}/test10.rb)
4370+ADD_TEST("ruby_test10" ${RUBY_EXECUTABLE} test10.rb)
4371+SET_TESTS_PROPERTIES("ruby_test10" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
4372+
4373+#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test11.rb ${CMAKE_CURRENT_BINARY_DIR}/test11.rb)
4374+#ADD_TEST("ruby_test11" ${RUBY_EXECUTABLE} test11.rb)
4375+#SET_TESTS_PROPERTIES("ruby_test11" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
4376+
4377+#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test12.rb ${CMAKE_CURRENT_BINARY_DIR}/test12.rb)
4378+#ADD_TEST("ruby_test12" ${RUBY_EXECUTABLE} test12.rb)
4379+#SET_TESTS_PROPERTIES("ruby_test12" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
4380+
4381+#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test13.rb ${CMAKE_CURRENT_BINARY_DIR}/test13.rb)
4382+#ADD_TEST("ruby_test13" ${RUBY_EXECUTABLE} test13.rb)
4383+#SET_TESTS_PROPERTIES("ruby_test13" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
4384+
4385+#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test14.rb ${CMAKE_CURRENT_BINARY_DIR}/test14.rb)
4386+#ADD_TEST("ruby_test14" ${RUBY_EXECUTABLE} test14.rb)
4387+#SET_TESTS_PROPERTIES("ruby_test14" PROPERTIES PASS_REGULAR_EXPRESSION "Success")
4388+
4389
4390=== added file 'swig/ruby/tests/books.xml'
4391--- swig/ruby/tests/books.xml 1970-01-01 00:00:00 +0000
4392+++ swig/ruby/tests/books.xml 2012-03-26 20:16:18 +0000
4393@@ -0,0 +1,11 @@
4394+<?xml version="1.0" encoding="UTF-8" ?>
4395+<books>
4396+ <book>
4397+ <title>Book 1</title>
4398+ <author>Author 1</author>
4399+ </book>
4400+ <book featured="YES">
4401+ <title>Book 2</title>
4402+ <author>Author 2</author>
4403+ </book>
4404+</books>
4405
4406=== added file 'swig/ruby/tests/compilerHints.xq'
4407--- swig/ruby/tests/compilerHints.xq 1970-01-01 00:00:00 +0000
4408+++ swig/ruby/tests/compilerHints.xq 2012-03-26 20:16:18 +0000
4409@@ -0,0 +1,4 @@
4410+for tumbling window $w in (2, 4, 6, 8, 10, 12, 14)
4411+ start at $s when fn:true()
4412+ only end at $e when $e - $s eq 2
4413+return avg($w)
4414
4415=== added file 'swig/ruby/tests/test01.rb'
4416--- swig/ruby/tests/test01.rb 1970-01-01 00:00:00 +0000
4417+++ swig/ruby/tests/test01.rb 2012-03-26 20:16:18 +0000
4418@@ -0,0 +1,24 @@
4419+# Copyright 2006-2012 The FLWOR Foundation.
4420+#
4421+# Licensed under the Apache License, Version 2.0 (the "License");
4422+# you may not use this file except in compliance with the License.
4423+# You may obtain a copy of the License at
4424+#
4425+# http://www.apache.org/licenses/LICENSE-2.0
4426+#
4427+# Unless required by applicable law or agreed to in writing, software
4428+# distributed under the License is distributed on an "AS IS" BASIS,
4429+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4430+# See the License for the specific language governing permissions and
4431+# limitations under the License.
4432+
4433+require '@rubyPath@/zorba_api'
4434+
4435+print "Running: Get zorba instance and shutdown"
4436+
4437+store = Zorba_api::InMemoryStore.getInstance()
4438+zorba = Zorba_api::Zorba.getInstance(store)
4439+zorba.shutdown()
4440+Zorba_api::InMemoryStore.shutdown(store)
4441+
4442+print "Success"
4443
4444=== added file 'swig/ruby/tests/test02.rb'
4445--- swig/ruby/tests/test02.rb 1970-01-01 00:00:00 +0000
4446+++ swig/ruby/tests/test02.rb 2012-03-26 20:16:18 +0000
4447@@ -0,0 +1,39 @@
4448+# Copyright 2006-2012 The FLWOR Foundation.
4449+#
4450+# Licensed under the Apache License, Version 2.0 (the "License");
4451+# you may not use this file except in compliance with the License.
4452+# You may obtain a copy of the License at
4453+#
4454+# http://www.apache.org/licenses/LICENSE-2.0
4455+#
4456+# Unless required by applicable law or agreed to in writing, software
4457+# distributed under the License is distributed on an "AS IS" BASIS,
4458+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4459+# See the License for the specific language governing permissions and
4460+# limitations under the License.
4461+
4462+require '@rubyPath@/zorba_api'
4463+
4464+def test(zorba)
4465+ xquery = zorba.compileQuery("(1,2,3,4,5)")
4466+ iter = xquery.iterator()
4467+ iter.open()
4468+ item = Zorba_api::Item.createEmptyItem()
4469+ while iter.next(item) do
4470+ print item.getStringValue()
4471+ print "\n"
4472+ end
4473+ iter.close()
4474+ iter.destroy()
4475+ xquery.destroy()
4476+end
4477+
4478+store = Zorba_api::InMemoryStore.getInstance()
4479+zorba = Zorba_api::Zorba.getInstance(store)
4480+
4481+print "Running: Compile query string"
4482+test(zorba)
4483+print "Success"
4484+
4485+zorba.shutdown()
4486+Zorba_api::InMemoryStore.shutdown(store)
4487
4488=== added file 'swig/ruby/tests/test03.rb'
4489--- swig/ruby/tests/test03.rb 1970-01-01 00:00:00 +0000
4490+++ swig/ruby/tests/test03.rb 2012-03-26 20:16:18 +0000
4491@@ -0,0 +1,43 @@
4492+# Copyright 2006-2012 The FLWOR Foundation.
4493+#
4494+# Licensed under the Apache License, Version 2.0 (the "License");
4495+# you may not use this file except in compliance with the License.
4496+# You may obtain a copy of the License at
4497+#
4498+# http://www.apache.org/licenses/LICENSE-2.0
4499+#
4500+# Unless required by applicable law or agreed to in writing, software
4501+# distributed under the License is distributed on an "AS IS" BASIS,
4502+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4503+# See the License for the specific language governing permissions and
4504+# limitations under the License.
4505+
4506+require '@rubyPath@/zorba_api'
4507+
4508+class MyDiagnosticHandler < Zorba_api.DiagnosticHandler
4509+ def error(self, *args)
4510+ print "Error args: " + args
4511+ end
4512+end
4513+
4514+def test(zorba):
4515+ diagnosticHandler = MyDiagnosticHandler.new
4516+ begin
4517+ xquery = zorba.compileQuery("1 div 0", diagnosticHandler)
4518+ print xquery.execute()
4519+ rescue => e
4520+ print "Caught error: " + e.message
4521+ ensure
4522+ xquery.destroy()
4523+ end
4524+end
4525+
4526+store = Zorba_api::InMemoryStore.getInstance()
4527+zorba = Zorba_api::Zorba.getInstance(store)
4528+
4529+print "Running: Capturing error with DiagnosticHandler"
4530+test(zorba)
4531+print "Success"
4532+
4533+zorba.shutdown()
4534+Zorba_api::InMemoryStore.shutdown(store)
4535
4536=== added file 'swig/ruby/tests/test04.rb'
4537--- swig/ruby/tests/test04.rb 1970-01-01 00:00:00 +0000
4538+++ swig/ruby/tests/test04.rb 2012-03-26 20:16:18 +0000
4539@@ -0,0 +1,35 @@
4540+# Copyright 2006-2012 The FLWOR Foundation.
4541+#
4542+# Licensed under the Apache License, Version 2.0 (the "License");
4543+# you may not use this file except in compliance with the License.
4544+# You may obtain a copy of the License at
4545+#
4546+# http://www.apache.org/licenses/LICENSE-2.0
4547+#
4548+# Unless required by applicable law or agreed to in writing, software
4549+# distributed under the License is distributed on an "AS IS" BASIS,
4550+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4551+# See the License for the specific language governing permissions and
4552+# limitations under the License.
4553+
4554+require '@rubyPath@/zorba_api'
4555+
4556+def test(zorba)
4557+ print 'Executing: test04.xq'
4558+ file = File.open("test04.xq", "rb")
4559+ contents = file.read
4560+ xquery = zorba.compileQuery(contents)
4561+ result = xquery.execute()
4562+ print result
4563+ xquery.destroy()
4564+end
4565+
4566+store = Zorba_api::InMemoryStore.getInstance()
4567+zorba = Zorba_api::Zorba.getInstance(store)
4568+
4569+print "Running: XQuery execute"
4570+test(zorba)
4571+print "Success"
4572+
4573+zorba.shutdown()
4574+Zorba_api::InMemoryStore.shutdown(store)
4575
4576=== added file 'swig/ruby/tests/test04.xq'
4577--- swig/ruby/tests/test04.xq 1970-01-01 00:00:00 +0000
4578+++ swig/ruby/tests/test04.xq 2012-03-26 20:16:18 +0000
4579@@ -0,0 +1,4 @@
4580+for tumbling window $w in (2, 4, 6, 8, 10, 12, 14)
4581+ start at $s when fn:true()
4582+ only end at $e when $e - $s eq 2
4583+return avg($w)
4584
4585=== added file 'swig/ruby/tests/test05.rb'
4586--- swig/ruby/tests/test05.rb 1970-01-01 00:00:00 +0000
4587+++ swig/ruby/tests/test05.rb 2012-03-26 20:16:18 +0000
4588@@ -0,0 +1,35 @@
4589+# Copyright 2006-2011 The FLWOR Foundation.
4590+#
4591+# Licensed under the Apache License, Version 2.0 (the "License");
4592+# you may not use this file except in compliance with the License.
4593+# You may obtain a copy of the License at
4594+#
4595+# http://www.apache.org/licenses/LICENSE-2.0
4596+#
4597+# Unless required by applicable law or agreed to in writing, software
4598+# distributed under the License is distributed on an "AS IS" BASIS,
4599+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4600+# See the License for the specific language governing permissions and
4601+# limitations under the License.
4602+
4603+require '@rubyPath@/zorba_api'
4604+
4605+def test(zorba)
4606+ print 'Executing: test05.xq'
4607+ file = File.open("test05.xq", "rb")
4608+ contents = file.read
4609+ xquery = zorba.compileQuery(contents)
4610+ result = xquery.printPlanAsXML()
4611+ print result
4612+ xquery.destroy()
4613+end
4614+
4615+store = Zorba_api::InMemoryStore.getInstance()
4616+zorba = Zorba_api::Zorba.getInstance(store)
4617+
4618+print "Running: XQuery execute - printPlanAsXML"
4619+test(zorba)
4620+print "Success"
4621+
4622+zorba.shutdown()
4623+Zorba_api::InMemoryStore.shutdown(store)
4624
4625=== added file 'swig/ruby/tests/test05.xq'
4626--- swig/ruby/tests/test05.xq 1970-01-01 00:00:00 +0000
4627+++ swig/ruby/tests/test05.xq 2012-03-26 20:16:18 +0000
4628@@ -0,0 +1,7 @@
4629+for $x in (5,6,7,1,2,3,4)
4630+where $x < 4
4631+for $y in (4,9,6,8,2)
4632+let $z := $x * $y
4633+where $z > 20
4634+return
4635+<value x="{$x}" y="{$y}">{$z}</value>
4636\ No newline at end of file
4637
4638=== added file 'swig/ruby/tests/test06.rb'
4639--- swig/ruby/tests/test06.rb 1970-01-01 00:00:00 +0000
4640+++ swig/ruby/tests/test06.rb 2012-03-26 20:16:18 +0000
4641@@ -0,0 +1,35 @@
4642+# Copyright 2006-2011 The FLWOR Foundation.
4643+#
4644+# Licensed under the Apache License, Version 2.0 (the "License");
4645+# you may not use this file except in compliance with the License.
4646+# You may obtain a copy of the License at
4647+#
4648+# http://www.apache.org/licenses/LICENSE-2.0
4649+#
4650+# Unless required by applicable law or agreed to in writing, software
4651+# distributed under the License is distributed on an "AS IS" BASIS,
4652+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4653+# See the License for the specific language governing permissions and
4654+# limitations under the License.
4655+
4656+require '@rubyPath@/zorba_api'
4657+
4658+def test(zorba)
4659+ print 'Executing: test06.xq'
4660+ file = File.open("test06.xq", "rb")
4661+ contents = file.read
4662+ xquery = zorba.compileQuery(contents)
4663+ result = xquery.printPlanAsDOT()
4664+ print result
4665+ xquery.destroy()
4666+end
4667+
4668+store = Zorba_api::InMemoryStore.getInstance()
4669+zorba = Zorba_api::Zorba.getInstance(store)
4670+
4671+print "Running: XQuery execute - printPlanAsDOT"
4672+test(zorba)
4673+print "Success"
4674+
4675+zorba.shutdown()
4676+Zorba_api::InMemoryStore.shutdown(store)
4677
4678=== added file 'swig/ruby/tests/test06.xq'
4679--- swig/ruby/tests/test06.xq 1970-01-01 00:00:00 +0000
4680+++ swig/ruby/tests/test06.xq 2012-03-26 20:16:18 +0000
4681@@ -0,0 +1,7 @@
4682+for $x in (5,6,7,1,2,3,4)
4683+where $x < 4
4684+for $y in (4,9,6,8,2)
4685+let $z := $x * $y
4686+where $z > 20
4687+return
4688+<value x="{$x}" y="{$y}">{$z}</value>
4689\ No newline at end of file
4690
4691=== added file 'swig/ruby/tests/test07.rb'
4692--- swig/ruby/tests/test07.rb 1970-01-01 00:00:00 +0000
4693+++ swig/ruby/tests/test07.rb 2012-03-26 20:16:18 +0000
4694@@ -0,0 +1,48 @@
4695+# Copyright 2006-2011 The FLWOR Foundation.
4696+#
4697+# Licensed under the Apache License, Version 2.0 (the "License");
4698+# you may not use this file except in compliance with the License.
4699+# You may obtain a copy of the License at
4700+#
4701+# http://www.apache.org/licenses/LICENSE-2.0
4702+#
4703+# Unless required by applicable law or agreed to in writing, software
4704+# distributed under the License is distributed on an "AS IS" BASIS,
4705+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4706+# See the License for the specific language governing permissions and
4707+# limitations under the License.
4708+
4709+require '@rubyPath@/zorba_api'
4710+
4711+def test(zorba)
4712+ file = File.open("books.xml", "rb")
4713+ contents = file.read
4714+
4715+ dataManager = zorba.getXmlDataManager()
4716+ docIter = dataManager.parseXML(contents)
4717+ docIter.open()
4718+
4719+ doc = Zorba_api::Item.createEmptyItem()
4720+ docIter.next(doc)
4721+
4722+ docIter.close()
4723+ docIter.destroy()
4724+
4725+ docManager = dataManager.getDocumentManager()
4726+ docManager.put("my_fake_books.xml", doc)
4727+ xquery = zorba.compileQuery("doc('my_fake_books.xml')")
4728+
4729+ result = xquery.execute()
4730+ print result
4731+ xquery.destroy()
4732+end
4733+
4734+store = Zorba_api::InMemoryStore.getInstance()
4735+zorba = Zorba_api::Zorba.getInstance(store)
4736+
4737+print "Running: XQuery execute - parsing XML"
4738+test(zorba)
4739+print "Success"
4740+
4741+zorba.shutdown()
4742+Zorba_api::InMemoryStore.shutdown(store)
4743
4744=== added file 'swig/ruby/tests/test08.rb'
4745--- swig/ruby/tests/test08.rb 1970-01-01 00:00:00 +0000
4746+++ swig/ruby/tests/test08.rb 2012-03-26 20:16:18 +0000
4747@@ -0,0 +1,108 @@
4748+# Copyright 2006-2011 The FLWOR Foundation.
4749+#
4750+# Licensed under the Apache License, Version 2.0 (the "License");
4751+# you may not use this file except in compliance with the License.
4752+# You may obtain a copy of the License at
4753+#
4754+# http://www.apache.org/licenses/LICENSE-2.0
4755+#
4756+# Unless required by applicable law or agreed to in writing, software
4757+# distributed under the License is distributed on an "AS IS" BASIS,
4758+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4759+# See the License for the specific language governing permissions and
4760+# limitations under the License.
4761+
4762+require '@rubyPath@/zorba_api'
4763+
4764+def test(zorba)
4765+ print 'Executing: test08.xq' + "\n"
4766+ lines = '(1, xs:int(2),"bla", <a><b att="{(3, xs:int(4),"foo", "bar")}"/>text<!--a comment--><?pi?></a>)'
4767+ xquery = zorba.compileQuery(lines)
4768+ result = xquery.execute()
4769+ print result + "\n"
4770+
4771+ print "Iterator:" + "\n"
4772+ iterator = xquery.iterator()
4773+ printIterator(iterator, "")
4774+ xquery.destroy()
4775+
4776+end
4777+
4778+
4779+def printIterator(iterator, pre)
4780+ item = Zorba_api::Item.createEmptyItem()
4781+ iterator.open()
4782+ while iterator.next(item)
4783+ printItem(item, pre)
4784+ end
4785+ iterator.close()
4786+ iterator.destroy()
4787+end
4788+
4789+def printItem(item, pre)
4790+ if item.isAtomic():
4791+ typeItem = item.getType()
4792+ print pre + "Leaf Atomic: '" + item.getStringValue() + "' \ttype:", typeItem.getStringValue() + "\n"
4793+ return
4794+ end
4795+
4796+ if item.isNode():
4797+ kind = item.getNodeKind()
4798+
4799+ if kind == 0 # anyNode
4800+ print pre + 'Any node' + "\n"
4801+ print pre + " Children:" + "\n"
4802+ printIterator(item.getChildren(), pre+" ")
4803+ end
4804+ if kind == 1 # doc
4805+ print pre + 'Doc' + "\n"
4806+ print pre + " Children:" + "\n"
4807+ printIterator(item.getChildren(), pre+" ")
4808+ end
4809+ if kind == 2 # element
4810+ nodeName = Zorba_api::Item.createEmptyItem()
4811+ item.getNodeName(nodeName)
4812+ typeItem = item.getType()
4813+ print pre + "Start Element: ", nodeName.getStringValue() + " \ttype:", typeItem.getStringValue() + "\n"
4814+ print pre + " Attributes:" + "\n"
4815+ printIterator(item.getAttributes(), pre+" ")
4816+ print pre + " Children:" + "\n"
4817+ printIterator(item.getChildren(), pre+" ")
4818+ print pre + "End Element: " + nodeName.getStringValue() + "\n"
4819+ end
4820+ if kind == 3 # attribute
4821+ nodeName = Zorba_api::Item.createEmptyItem()
4822+ item.getNodeName(nodeName)
4823+ typeItem = item.getType()
4824+ print pre + "Attribute: " + nodeName.getStringValue() + "= '" + item.getStringValue() + "'"" \ttype:" + typeItem.getStringValue() + "\n"
4825+ print pre+" Atomization value:" + "\n"
4826+ printIterator(item.getAtomizationValue(), pre+" ")
4827+ end
4828+ if kind == 4 # text
4829+ typeItem = item.getType()
4830+ print pre + "Text: " + item.getStringValue() + " \ttype:", typeItem.getStringValue() + "\n"
4831+ print pre+" Atomization value:" + "\n"
4832+ printIterator(item.getAtomizationValue(), pre+" ")
4833+ end
4834+ if kind == 5 # pi
4835+ nodeName = Zorba_api::Item.createEmptyItem()
4836+ item.getNodeName(nodeName)
4837+ print pre + "Pi: " + nodeName.getStringValue() + "\n"
4838+ end
4839+ if kind == 6 # comment
4840+ print pre + "Comment: " + item.getStringValue() + "\n"
4841+ end
4842+ else
4843+ print pre+"Item not Node, not Atomic" + "\n"
4844+ end
4845+end
4846+
4847+store = Zorba_api::InMemoryStore.getInstance()
4848+zorba = Zorba_api::Zorba.getInstance(store)
4849+
4850+print "Running: XQuery execute - Get Iterator and print info from its items" + "\n"
4851+test(zorba)
4852+print "Success" + "\n"
4853+
4854+zorba.shutdown()
4855+Zorba_api::InMemoryStore.shutdown(store)
4856
4857=== added file 'swig/ruby/tests/test09.rb'
4858--- swig/ruby/tests/test09.rb 1970-01-01 00:00:00 +0000
4859+++ swig/ruby/tests/test09.rb 2012-03-26 20:16:18 +0000
4860@@ -0,0 +1,81 @@
4861+# Copyright 2006-2011 The FLWOR Foundation.
4862+#
4863+# Licensed under the Apache License, Version 2.0 (the "License");
4864+# you may not use this file except in compliance with the License.
4865+# You may obtain a copy of the License at
4866+#
4867+# http://www.apache.org/licenses/LICENSE-2.0
4868+#
4869+# Unless required by applicable law or agreed to in writing, software
4870+# distributed under the License is distributed on an "AS IS" BASIS,
4871+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4872+# See the License for the specific language governing permissions and
4873+# limitations under the License.
4874+
4875+import sys
4876+sys.path.insert(0, '@pythonPath@')
4877+import zorba_api
4878+
4879+
4880+def test(zorba)
4881+ xquery = zorba.compileQuery("<a>text-a1<b at1='att1' at2='{1+2}'>text-b1</b>text-a2</a>")
4882+
4883+ saxHandler = zorba_api.SAX2ContentHandlerProxy()
4884+ saxHandler.setStartDocumentHandler(startDocumentHandler);
4885+ saxHandler.setEndDocumentHandler(endDocumentHandler);
4886+ saxHandler.setStartElementHandler(startElementHandler);
4887+ saxHandler.setEndElementHandler(endElementHandler);
4888+ saxHandler.setCharactersHandler(charactersHandler);
4889+ saxHandler.setProcessingInstructionHandler(processingInstructionHandler);
4890+ saxHandler.setIgnorableWhitespaceHandler(ignorableWhitespaceHandler);
4891+ saxHandler.setStartPrefixMappingHandler(startPrefixMappingHandler);
4892+ saxHandler.setEndPrefixMappingHandler(endPrefixMappingHandler);
4893+ saxHandler.setSkippedEntityHandler(skippedEntityHandler);
4894+ xquery.executeSAX(saxHandler)
4895+
4896+ return
4897+
4898+
4899+def startDocumentHandler():
4900+ print "Start Document"
4901+ return
4902+def endDocumentHandler():
4903+ print "End Document"
4904+ return
4905+def startElementHandler(URI, localName, QName, SAXAttributes):
4906+ print "Start Element - ", QName
4907+ return
4908+def endElementHandler(URI, localName, QName):
4909+ print "End Element - ", QName
4910+ return
4911+def charactersHandler(text):
4912+ print "Characters - ", text
4913+ return
4914+def processingInstructionHandler(target, data):
4915+ print "Processing Instruction"
4916+ return
4917+def ignorableWhitespaceHandler(text):
4918+ print "Ignorable Whitespace - ", text
4919+ return
4920+def startPrefixMappingHandler(prefix, URI):
4921+ print "Start Prefix Mapping - ", prefix
4922+ return
4923+def endPrefixMappingHandler(prefix):
4924+ print "End Prefix Mapping - ", prefix
4925+ return
4926+def skippedEntityHandler(name):
4927+ print "Skipped Entity - ", name
4928+ return
4929+
4930+
4931+store = zorba_api.InMemoryStore_getInstance()
4932+zorba = zorba_api.Zorba_getInstance(store)
4933+
4934+print "Running: XQuery execute - executeSAX"
4935+test(zorba)
4936+print "Success"
4937+
4938+
4939+zorba.shutdown()
4940+zorba_api.InMemoryStore_shutdown(store)
4941+
4942
4943=== added file 'swig/ruby/tests/test10.rb'
4944--- swig/ruby/tests/test10.rb 1970-01-01 00:00:00 +0000
4945+++ swig/ruby/tests/test10.rb 2012-03-26 20:16:18 +0000
4946@@ -0,0 +1,46 @@
4947+# Copyright 2006-2011 The FLWOR Foundation.
4948+#
4949+# Licensed under the Apache License, Version 2.0 (the "License");
4950+# you may not use this file except in compliance with the License.
4951+# You may obtain a copy of the License at
4952+#
4953+# http://www.apache.org/licenses/LICENSE-2.0
4954+#
4955+# Unless required by applicable law or agreed to in writing, software
4956+# distributed under the License is distributed on an "AS IS" BASIS,
4957+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4958+# See the License for the specific language governing permissions and
4959+# limitations under the License.
4960+
4961+require '@rubyPath@/zorba_api'
4962+
4963+def test(zorba)
4964+ file = File.open("books.xml", "rb")
4965+ contents = file.read
4966+
4967+ dataManager = zorba.getXmlDataManager()
4968+ docIter = dataManager.parseXML(contents)
4969+ docIter.open();
4970+
4971+ doc = Zorba_api::Item.createEmptyItem()
4972+ docIter.next(doc)
4973+
4974+ docIter.close()
4975+ docIter.destroy()
4976+
4977+ xquery = zorba.compileQuery(".")
4978+ dynCtx = xquery.getDynamicContext()
4979+ dynCtx.setContextItem(doc)
4980+ print xquery.execute()
4981+ xquery.destroy()
4982+end
4983+
4984+store = Zorba_api::InMemoryStore.getInstance()
4985+zorba = Zorba_api::Zorba.getInstance(store)
4986+
4987+print "Running: XQuery execute - Get Iterator and print info from its items"
4988+test(zorba)
4989+print "Success"
4990+
4991+zorba.shutdown()
4992+Zorba_api::InMemoryStore.shutdown(store)
4993
4994=== added file 'swig/ruby/tests/test11.rb'
4995--- swig/ruby/tests/test11.rb 1970-01-01 00:00:00 +0000
4996+++ swig/ruby/tests/test11.rb 2012-03-26 20:16:18 +0000
4997@@ -0,0 +1,49 @@
4998+# Copyright 2006-2011 The FLWOR Foundation.
4999+#
5000+# 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