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

Proposed by William Candillon
Status: Superseded
Proposed branch: lp:~zorba-coders/zorba/phpapi
Merge into: lp:zorba
Diff against target: 628 lines (+507/-10)
8 files modified
doc/php/examples/CMakeLists.txt (+10/-3)
doc/php/examples/php.ini.in (+1/-0)
doc/php/examples/simple.php.in (+1/-1)
doc/php/examples/test.php.in (+122/-0)
swig/php/CMakeLists.txt (+18/-5)
swig/php/XQueryProcessor.php (+353/-0)
swig/php/generate_proxy.php.in (+1/-1)
swig/php/test.xq (+1/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/phpapi
Reviewer Review Type Date Requested Status
Rodolfo Ochoa Pending
Matthias Brantner Pending
David Graf Pending
Review via email: mp+87718@code.launchpad.net

This proposal supersedes a proposal from 2011-12-24.

This proposal has been superseded by a proposal from 2012-01-07.

Description of the change

This merge adds the PHP API that was introduced at the PHP Tour 2011.
It contains a test for it (php2).

From the last merge proposal, the following things have been done:
- Revert bogus change in swig/php/generate_proxy.php.in (renaming of libPrefix to prefix).
- Introduce a STD Iterator for streaming results.
- Make the parseXML() method private.
- Improve importQueryFromURI

The two key tests are:
- php1
- php2

To post a comment you must log in.
Revision history for this message
Matthias Brantner (matthias-brantner) wrote : Posted in a previous version of this proposal

- One thing that I don't understand is the relationship with the existing PHP binding.
- The first three changes in swig/php/generate_proxy.php.in should be reverted (renaming of libPrefix to prefix)
- executeToURI is only capable of writing to files. Also, it currently doesn't stream.
- importQueryFromURI only works for file URIs.
- The parse functionality should probably be removed. It merges two functionalities which don't really belong together (retrieving of data and parsing xml). The latter can also be done in XQuery. If this philosophy is to push more functionality into XQuery, the parse functionality should be removed or made symmetric to the existing C++ and XQuery data manager APIs.
- getItem doesn't have a comment and is incomplete. Shouldn't it support more/all XQuery types?

review: Needs Fixing
Revision history for this message
William Candillon (wcandillon) wrote :

> - One thing that I don't understand is the relationship with the existing PHP binding.
The low level API enables us to extend/debug the XQueryProcessor API more easily.

> - The first three changes in swig/php/generate_proxy.php.in should be reverted (renaming of libPrefix to prefix)
This is fixed in commit 10597.

> - executeToURI is only capable of writing to files. Also, it currently doesn't stream.
This is fixed in commit 10598.

> - importQueryFromURI only works for file URIs.
This is fixed in commit 10600. There is a test for it in commit 10601.

> - The parse functionality should probably be removed. It merges two functionalities which don't really belong together (retrieving of data and parsing xml). The latter can also be done in XQuery. If this philosophy is to push more functionality into XQuery, the parse functionality should be removed or made symmetric to the existing C++ and XQuery data manager APIs.

This is fixed in commit 10598. Unfortunately there two orthogonal things in commit 10598.

> - getItem doesn't have a comment and is incomplete. Shouldn't it support more/all XQuery types?
It should support any kind of PHP type. Currently objects are not supported. Maybe in the futur we will introduce support for objects.

lp:~zorba-coders/zorba/phpapi updated
10607. By Matthias Brantner

Bug #911956: Zorba fails to build with gcc 4.7.0 Approved: Till Westmann, Matthias Brantner

10608. By Markos Zaharioudakis

fixed bug in no-copy rule + made zorba cmd use the for-serialization-only mode Approved: Markos Zaharioudakis

10609. By Gabriel Petrovay

Fixed libedit search on mac issue.
Added history support from libedit for UNIX platforms.
 Approved: David Graf, Gabriel Petrovay

10610. By Markos Zaharioudakis

moved atomic type codes enum to the store api Approved: Markos Zaharioudakis

10611. By Chris Hillery

Expose Item::getNamespaceBindings() through the public API. Approved: Matthias Brantner, Chris Hillery

10612. By Daniel Turcanu

Removed test versioning/link1 to avoid bug 908062 on Windows Approved: Daniel Turcanu, Chris Hillery

10613. By Gabriel Petrovay

Implemented the stop command.
Fixed termination on Windows.
TODO: still a problem on Windows when quitting the debugger client: a zorba store is shut down and in the store destructor a lock hangs the execution of xqdb forever. Not even Ctrl-C helps (probably because everything is called from the exit function in main.cpp) Approved: David Graf, Gabriel Petrovay

10614. By Markos Zaharioudakis

types-related optimization for the general comparison operator Approved: Markos Zaharioudakis

10615. By Chris Hillery

Ensure clean test run when Zorba build with ZORBA_WITH_BIG_INTEGER. Approved: Matthias Brantner, Chris Hillery

10616. By Markos Zaharioudakis

fixed timing bug in zorbacmd Approved: Markos Zaharioudakis

10617. By Markos Zaharioudakis

fixed bug in detecting mutually recursive functions Approved: Markos Zaharioudakis

10618. By Markos Zaharioudakis

fixed bug in no-copy rule Approved: Markos Zaharioudakis

10619. By Markos Zaharioudakis

Fixed bug 917923 (bug in copying outer var values into the eval dynamic context) Approved: Markos Zaharioudakis

10620. By Gabriel Petrovay

Added Ctrl-C hooking in the debugger. Ctrl-C can not kill the debugger anymore. It will only stop the running query. Approved: David Graf, Gabriel Petrovay

10621. By William Candillon

This merge adds the PHP API that was introduced at the PHP Tour 2011. Approved: Rodolfo Ochoa, William Candillon

10622. By Chris Hillery

This merge adds the PHP API that was introduced at the PHP Tour 2011. Approved: Rodolfo Ochoa, William Candillon

10623. By Sorin Marian Nasoi <email address hidden>

Added the information about the Zorba module version in the generated XQDoc documentation. Approved: William Candillon, Sorin Marian Nasoi

10624. By Markos Zaharioudakis

fix for bug #919189 Approved: Markos Zaharioudakis

10625. By Markos Zaharioudakis

fix for bug #866423 Approved: Markos Zaharioudakis

10626. By Matthias Brantner

fn:serialize avoids copying the result but returns a streamable string instead Approved: Till Westmann, Matthias Brantner

10627. By Matthias Brantner

Implemented StaticContext::getNamespaceBindings to resolve bug #905035. In the same commit, the function getNamespaceURIByPrefix was deprecated because it's superseded by the new function. Approved: Rodolfo Ochoa, Markos Zaharioudakis

10628. By Markos Zaharioudakis

fix for bug #866932 (string pool not empty on shutdown)
 Approved: Markos Zaharioudakis

10629. By Chris Hillery

Remove test case sc3_ex3 in order to merge the removal of the non-core JSON module. sc3_ex3 will be re-added along with the core JSON module. Approved: Paul J. Lucas, Chris Hillery

10630. By Markos Zaharioudakis

More types-related optimizations for the comparison operators Approved: Markos Zaharioudakis

10631. By Markos Zaharioudakis

Fixed bug involving positional var and groupby Approved: Markos Zaharioudakis

10632. By Chris Hillery

- updated the import scripts to use the latest version of XQTS, XQUTS and XQFTTS as of 25.01.2012
- added EXPECTED_FAILURES for XQFTTS XQuery and XQueryX tests
- updated the W3C conformance documentation
- included fix for the XQFTTS XQueryX tests created by Daniel in lp:~zorba-coders/zorba/xqueryx_fulltext branch Approved: Chris Hillery, Sorin Marian Nasoi

10633. By Markos Zaharioudakis

type-related optimizagtions of boolean iterators Approved: Markos Zaharioudakis

10634. By Paul J. Lucas

Migrated several unit tests to libunittest. Approved: Chris Hillery, Paul J. Lucas

10635. By Chris Hillery

Fix filename when creating library for unversioned module. Approved: Dennis Knochenwefel, Chris Hillery

10636. By Markos Zaharioudakis

type-related optimizations for sequence-type iterators Approved: Markos Zaharioudakis

10637. By Paul J. Lucas

Fixed bug 924063 (sentence is incorrectly incremented when token characters end without sentence terminator) Approved: Matthias Brantner, Paul J. Lucas

10638. By Chris Hillery

Install the XHTML DTD locally so we don't ask w3.org for it. Approved: Chris Hillery, Sorin Marian Nasoi

10639. By Chris Hillery

Added DECLARE_ZORBA_URI_FILE() for installing files of any type that we would like to load by URI. Also made built-in URI mappers look on the filesystem for any kind of URIs, not just modules and schemas. Approved: Cezar Andrei, Chris Hillery

10640. By Daniel Turcanu

several fixes for the plan serializer + implemented materialize_clause::clone() Approved: Matthias Brantner, Chris Hillery

10641. By Markos Zaharioudakis

w3c test modules-schema-context now passes Approved: Markos Zaharioudakis

10642. By Ghislain Fourny

Correcting two typos (parameter name and document debug output). Approved: Ghislain Fourny, Matthias Brantner

10643. By William Candillon

Fix for bug #918592 Approved: Chris Hillery, Rodolfo Ochoa

10644. By Chris Hillery

Several fixes related to test breakages caused by zorba-xquery.com changes:
1. Don't attempt HTTP resolution w/ HttpStream if Zorba compiled without CURL.
2. store/example_3 test: load content from zorbatest site like other tests.
3. fetch_bogus2 and impot5 test: change "ver" test module to be identified with a flworfound.org URI, so we'll get a 404 when loading it wrong. (Both example.com and zorba-xquery.com don't return 404 for unknown URLs.)
 Approved: Matthias Brantner, Chris Hillery

10645. By Rodolfo Ochoa

Added recognition for URIs without authority, this is a JAVA URI case. Approved: Rodolfo Ochoa, Cezar Andrei

10646. By Rodolfo Ochoa

added
#include "stdafx.h"

and changed uri_util.h having
ZORBA_DLL_PUBLIC extern char const uri_safe[];
ZORBA_DLL_PUBLIC extern signed char const hex2dec[]; Approved: Cezar Andrei, Matthias Brantner

10647. By Sorin Marian Nasoi <email address hidden>

Downloaded the latest version of the W3C Working Draft 13 December 2011for XQuery 3.0 F&O to be used in test "xquery_3_0". Approved: Juan Zacarias, Sorin Marian Nasoi

10648. By Ghislain Fourny

Using GET_PUL_FACTORY macro. Approved: Markos Zaharioudakis

10649. By Markos Zaharioudakis

optimization for the Item::add/removeReference methods Approved: Markos Zaharioudakis

10650. By Chris Hillery

Ensure same module is not declared twice with the same version number (including twice with no declared version).
 Approved: Sorin Marian Nasoi, Chris Hillery

10651. By Chris Hillery

Download v1.0 of http-client. Approved: Sorin Marian Nasoi, Chris Hillery

10652. By Ghislain Fourny

Made same-directory simple store includes. Approved: Matthias Brantner, Markos Zaharioudakis

10653. By Paul J. Lucas

Simple fix. Approved: William Candillon, Paul J. Lucas

10654. By Markos Zaharioudakis

use SUBSEQUENCE_INT function, instead of SUBSEQUENCE_INT in partial_eval_eq rewrite rule Approved: Markos Zaharioudakis

10655. By Paul J. Lucas

Added clone(). Approved: Matthias Brantner, William Candillon

10656. By Markos Zaharioudakis

small optimization for subsequence iterators Approved: Markos Zaharioudakis

10657. By Markos Zaharioudakis

1. Optimization: preallocate and reuse temp sequence iterator for LetVarITerator and CtxVarIterator.
2. Optimization: enhanced push-down of positional predicate into LetVarITerator and CtxVarIterator. Approved: Markos Zaharioudakis

10658. By Markos Zaharioudakis

Fixed bug #872288 Approved: Markos Zaharioudakis

10659. By Till Westmann

added a new unit test for the plan serializer Approved: Matthias Brantner, Till Westmann

10660. By Markos Zaharioudakis

Fixed bug #867022 Approved: Markos Zaharioudakis

10661. By Markos Zaharioudakis

fix for bug #867266 Approved: Markos Zaharioudakis

10662. By Paul J. Lucas

New JSON parser and module. Approved: Sorin Marian Nasoi, Paul J. Lucas

10663. By Paul J. Lucas

- Added transcode_streambuf
- file:read-text now respects encodings
- http:send-request now respects encodings Approved: Matthias Brantner, Paul J. Lucas

10664. By Markos Zaharioudakis

Optimization: changed the implementation of the free-vars annotation and got rid of the annotations map in expressions Approved: Markos Zaharioudakis

10665. By Matthias Brantner

Put the state file written by the uuid functionality into the system's temp directory (temporary solution). Approved: Till Westmann, Matthias Brantner

10666. By Paul J. Lucas

Fixed return type. Approved: Juan Zacarias, Matthias Brantner, Paul J. Lucas

10667. By Matthias Brantner

added two api functions to introspect the functions of a static context Approved: Till Westmann, Matthias Brantner

10668. By William Candillon <email address hidden>

Fix typos in doxygen documentation. Approved: Cezar Andrei, Matthias Brantner

10669. By William Candillon

Update the XQDDF ebnf to fit with XQuery 3.0 syntax. Approved: William Candillon, Matthias Brantner

10670. By William Candillon

Add support for return and parameters elements in XQDoc. Approved: William Candillon, Sorin Marian Nasoi

10671. By Rodolfo Ochoa

Just some precompiled headers included Approved: Matthias Brantner, Cezar Andrei

10672. By William Candillon

XQuery 3.0 concat operator Approved: Matthias Brantner, William Candillon

10673. By David Graf

Added the new external variable value tests that will be added to the w3c testsuite to the zorba rbkt tests. Inclusive the failing once. Added launchpad entries for them and marked the tests as expected failures. Approved: Matthias Brantner, David Graf

10674. By Chris Hillery

Update data-cleaning module to release 1.0 (fixes conversion tests).
 Approved: Sorin Marian Nasoi, Chris Hillery

10675. By William Candillon

Add --compile-plan and --execute-plan option to zorba command line.
Example:
zorba -q 1+1 --compile-plan > test.xqc
zorba -q test.xqc -f --execute-plan Approved: William Candillon, Matthias Brantner

10676. By Chris Hillery

Error checking for DownloadModules.cmake; try three times on failures.
 Approved: Sorin Marian Nasoi, Chris Hillery

10677. By Matthias Brantner

more efficient implementation of xs:base64Binary items Approved: Till Westmann, Matthias Brantner

10678. By Ghislain Fourny

Makes same-directory store includes in the headers as well. Approved: Till Westmann, Matthias Brantner

10679. By Markos Zaharioudakis

Fixed bug in codegen: do not create a materialize clause if one exists already Approved: Markos Zaharioudakis

10680. By William Candillon

Remove conflicting shortcut -e for --execute-plan option. Approved: Matthias Brantner, William Candillon

10681. By Ghislain Fourny

Replacing ulong positions with xs_integer for positions in collections. Approved: Ghislain Fourny, Matthias Brantner

10682. By Ghislain Fourny

Refactored CollectionSet class. zorba::store::CollectionSet is abstract, zorba::simplestore::SimpleCollectionSet is its implementation for the simple store. Approved: Matthias Brantner, Till Westmann

10683. By Paul J. Lucas

Fixed bug 942808. Approved: Matthias Brantner, Paul J. Lucas

10684. By Markos Zaharioudakis

removed properties-generating scripts and restored zorba_properties.h and store_properties.h files. Approved: Markos Zaharioudakis

10685. By Daniel Turcanu

Making https work on Windows. Approved: Gabriel Petrovay, Sorin Marian Nasoi

10686. By Ghislain Fourny

Refactored QName pool and QNameItem class. Approved: Markos Zaharioudakis

10687. By Sorin Marian Nasoi <email address hidden>

Updated the web crawler tutorial. Approved: Nicolae Brinza, Sorin Marian Nasoi

10688. By William Candillon

Optimize iterator generation for the concat operator (fixes bug #942011) Approved: Matthias Brantner, Markos Zaharioudakis

10689. By Paul J. Lucas

Better implementation of ZORBA_WITH_BIG_INTEGER=OFF: now limited to 63 bits (for a 64-bit implementation of a long long). Also added build_options.dox. Approved: Markos Zaharioudakis, Matthias Brantner

10690. By Markos Zaharioudakis

fixed bug involing eval and the no-copy rule Approved: Markos Zaharioudakis

10691. By Matthias Brantner

fix for bug #943788 (streamable string is not seekable) Approved: Till Westmann, Matthias Brantner

10692. By Federico Cavalieri <federico@M702X>

Fixed bug #912579 (validate-in-place on non-root elements)
Fixed merge of updput primitives
Fixed merge conflict. Approved: Markos Zaharioudakis, Cezar Andrei

10693. By Markos Zaharioudakis

Added test that illustrates bug #944002 Approved: Markos Zaharioudakis

10694. By Markos Zaharioudakis

Fixed another bug involving eval and the no-copy rule Approved: Markos Zaharioudakis

10695. By Paul J. Lucas

Added ~XmlNodeTokenizerCallback() to destroy tokenizers. Approved: Matthias Brantner, Paul J. Lucas

10696. By Ghislain Fourny

Introduces an abstract layer between zorba::store::collection and zorba::simplestore::SimpleCollection. Approved: Matthias Brantner, Markos Zaharioudakis

10697. By Markos Zaharioudakis

fixed bug #944002
 Approved: Markos Zaharioudakis

10698. By Ghislain Fourny

Making two non-abstract functions in simplecollection API also non-virtual. Approved: Matthias Brantner, Markos Zaharioudakis

10699. By Ghislain Fourny

Added default constructors for index classes in simple store. Approved: Markos Zaharioudakis, Matthias Brantner

10700. By Markos Zaharioudakis

Fixed bug #867024 Approved: Markos Zaharioudakis

10701. By Sorin Marian Nasoi <email address hidden>

Fixed bug lp:946896. Approved: William Candillon, Sorin Marian Nasoi

10702. By Markos Zaharioudakis

Fixed memory leak in no-copy rule Approved: Markos Zaharioudakis

10703. By Matthias Brantner

A new module that provides URL-related functions. Currently, it provides functions to do URL-decoding but other URL-related functions (e.g. to retrieve the scheme or path) will be added later. Approved: Matthias Brantner, Chris Hillery

10704. By Markos Zaharioudakis

fixes bug 924987
- extended TypeIdentifier to also support schema-element, schema-attribute
  and namespace-node sequence types
- fixed TypeOps::get_type_identifier
- added a test to the staticcollectionmanager unit test
- added operator<< for TypeIdentifier Approved: Markos Zaharioudakis, Till Westmann

10705. By Paul J. Lucas

Set dispose_data_using_delete_ = false in reserve(). Approved: Markos Zaharioudakis, Matthias Brantner

10706. By Cezar Andrei <email address hidden>

Fix for bug 891209 : validation with xsi:type returns untyped. Approved: Matthias Brantner, Markos Zaharioudakis, Cezar Andrei

10707. By Sorin Marian Nasoi <email address hidden>

- fixed the test 'moduleDocumentation': all modules that appear in ZorbaManifest.xml are checked for correct XQDoc documentation
- re-enabled the 'moduleDocumentation' test that was previously disabled. Approved: Sorin Marian Nasoi, Chris Hillery

10708. By Markos Zaharioudakis

bug fixes: some methods in atomic_item.h should have been virtual + use myChild local var in children iterators" Approved: Markos Zaharioudakis

10709. By Paul J. Lucas

Added links to full-text documentation. Approved: Matthias Brantner, Paul J. Lucas

10710. By Paul J. Lucas

fix Bug #949111: getUnsignedIntValue() not implemented for Integer Approved: Matthias Brantner, Paul J. Lucas

10711. By Paul J. Lucas

Added delete theSerStream; Approved: Matthias Brantner, Paul J. Lucas

10712. By Sorin Marian Nasoi <email address hidden>

Fix for bug lp:948712: Added a way for easy copy&paste of the import schema statements. Approved: Matthias Brantner, Sorin Marian Nasoi

10713. By Matthias Brantner

StaticCollectionManager::declaredIndexes() doesn't return temporary indexes anymore. Also isDeclaredIndex also doesn't return true if asked whether a temporary index is declared. Approved: Till Westmann, Matthias Brantner

10714. By Matthias Brantner

- fix bug #938934 "collection dml:truncate function missing"
- fixes documentation bug: raise zerr:ZDDY0003 instead of zerr:ZDDY0009 Approved: Till Westmann, Markos Zaharioudakis, Matthias Brantner

10715. By Matthias Brantner

fixed bug #951772 Comment node crashes serialization) Approved: William Candillon, Matthias Brantner

10716. By Matthias Brantner

Fixed bug #952829 (Nondeterministic annotation doesn't seem to be checked) Approved: Matthias Brantner, William Candillon

10717. By Rodolfo Ochoa

This fixes the error:
n strings remain in the pool.
and change it to a more comprehensive error with reference to document that helps to prevent the error. Approved: Matthias Brantner, Markos Zaharioudakis, Cezar Andrei

10718. By Markos Zaharioudakis

Fixed bug #948259 Approved: Markos Zaharioudakis

10719. By Ghislain Fourny

Introduced function OrdPathNode::getDescendantNodeByOrdPath (from Sausalito). Approved: Markos Zaharioudakis, Matthias Brantner

10720. By Matthias Brantner

2.2 release preparations Approved: Chris Hillery, Matthias Brantner

10721. By Rodolfo Ochoa

- Fixed bug for PHP wrapper pointing to a wrong DLL name
- Fixed precompiled headers bug
- Fixed warning -> Conversion Int to Bool - Performance warning Approved: Cezar Andrei, William Candillon, Matthias Brantner

10722. By William Candillon

Minor update of the PHP example page.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'doc/php/examples/CMakeLists.txt'
--- doc/php/examples/CMakeLists.txt 2011-08-19 00:03:31 +0000
+++ doc/php/examples/CMakeLists.txt 2012-01-07 17:53:24 +0000
@@ -20,14 +20,21 @@
20 MESSAGE(STATUS "PHP Path:" ${phpPath})20 MESSAGE(STATUS "PHP Path:" ${phpPath})
21 SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php)21 SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php)
22 MESSAGE(STATUS "PHP Extension Path: " ${phpExtensionPath})22 MESSAGE(STATUS "PHP Extension Path: " ${phpExtensionPath})
23 SET(phpIncludePath ${CMAKE_BINARY_DIR}/swig/php)
24 MESSAGE(STATUS "PHP Include Path: " ${phpExtensionPath})
23 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/php.ini.in ${CMAKE_CURRENT_BINARY_DIR}/php.ini)25 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/php.ini.in ${CMAKE_CURRENT_BINARY_DIR}/php.ini)
24 MESSAGE(STATUS "Configuration file: " ${CMAKE_CURRENT_BINARY_DIR}/php.ini)26 MESSAGE(STATUS "Configuration file: " ${CMAKE_CURRENT_BINARY_DIR}/php.ini)
25 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/simple.php.in ${CMAKE_CURRENT_BINARY_DIR}/simple.php)27 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/simple.php.in ${CMAKE_CURRENT_BINARY_DIR}/simple.php)
26 MESSAGE(STATUS "Simple configuration file: " ${CMAKE_CURRENT_BINARY_DIR}/simple.php)28 MESSAGE(STATUS "Simple configuration file: " ${CMAKE_CURRENT_BINARY_DIR}/simple.php)
27 ADD_TEST("php" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/simple.php)29 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test.php.in ${CMAKE_CURRENT_BINARY_DIR}/test.php)
30 MESSAGE(STATUS "PHP test file configured: " ${CMAKE_CURRENT_BINARY_DIR}/test.php)
31 ADD_TEST("php1" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/simple.php)
28 MESSAGE(STATUS "Installing: " ${CMAKE_CURRENT_BINARY_DIR}/simple.php)32 MESSAGE(STATUS "Installing: " ${CMAKE_CURRENT_BINARY_DIR}/simple.php)
29 33 ADD_TEST("php2" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/test.php)
30 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/simple.php34 MESSAGE(STATUS "Installing: " ${CMAKE_CURRENT_BINARY_DIR}/test.php)
35
36
37 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/simple.php ${CMAKE_CURRENT_BINARY_DIR}/test.php
31 COMPONENT "php_examples"38 COMPONENT "php_examples"
32 DESTINATION39 DESTINATION
33 share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/php/examples)40 share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/php/examples)
3441
=== modified file 'doc/php/examples/php.ini.in'
--- doc/php/examples/php.ini.in 2009-10-30 16:34:37 +0000
+++ doc/php/examples/php.ini.in 2012-01-07 17:53:24 +0000
@@ -1,2 +1,3 @@
1enable_dl=On1enable_dl=On
2extension_dir=@phpExtensionPath@2extension_dir=@phpExtensionPath@
3include_path=".:@phpIncludePath@"
3\ No newline at end of file4\ No newline at end of file
45
=== modified file 'doc/php/examples/simple.php.in'
--- doc/php/examples/simple.php.in 2011-08-04 02:14:56 +0000
+++ doc/php/examples/simple.php.in 2012-01-07 17:53:24 +0000
@@ -14,7 +14,7 @@
14 * See the License for the specific language governing permissions and14 * See the License for the specific language governing permissions and
15 * limitations under the License.15 * limitations under the License.
16 */16 */
17require '@phpPath@/zorba_api_wrapper.php';17require '@phpPath@/Zorba/zorba_api_wrapper.php';
1818
19function example_1(Zorba $aZorba)19function example_1(Zorba $aZorba)
20{20{
2121
=== added file 'doc/php/examples/test.php.in'
--- doc/php/examples/test.php.in 1970-01-01 00:00:00 +0000
+++ doc/php/examples/test.php.in 2012-01-07 17:53:24 +0000
@@ -0,0 +1,122 @@
1<?php
2/*
3 * Copyright 2006-2008 The FLWOR Foundation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17require '@phpPath@/Zorba/XQueryProcessor.php';
18
19function omitXMLDecl($xml)
20{
21 $xml = str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $xml);
22 $xml = trim($xml);
23 return $xml;
24}
25
26function assertEquality($test, $reference, $label)
27{
28 $test = omitXMLDecl($test);
29 echo "=====================================\n";
30 var_dump($test);
31 var_dump($reference);
32 if($test != $reference) {
33 throw new Exception(
34 "Test "
35 . $label
36 . " failed. Result:\n"
37 . $test
38 . "\nDoesn't match reference:\n"
39 . $reference
40 );
41 }
42}
43/* Test 1 */
44$xquery = new XQueryProcessor();
45$xquery->importQuery('1+1');
46$result = $xquery->execute();
47assertEquality($result, '2', "1+1");
48
49/* Test 2 */
50$query = <<<'XQ'
51declare variable $foo as xs:string external;
52declare variable $bar as xs:integer external;
53declare variable $doc1 as document-node() external;
54declare variable $doc2-str as xs:string external;
55declare variable $doc2 as document-node() := parse-xml($doc2-str);
56
57$foo, $bar, $doc1 , $doc2
58XQ;
59
60$xquery->importQuery($query);
61
62$xquery->setVariable("foo", "bar");
63$xquery->setVariable("bar", 3);
64
65$doc = simplexml_load_string('<root />');
66$xquery->setVariable("doc1", $doc);
67
68$doc = "<root />";
69$xquery->setVariable("doc2-str", $doc);
70
71$result = trim($xquery->execute());
72assertEquality($result, "bar 3<root/><root/>", "Test PHP Types Mapping");
73
74/* Test 3 */
75$xquery->importQuery("(1, 2, <foo bar='bar' />)");
76$it = $xquery->getIterator();
77
78foreach($it as $pos => $value) {
79 switch($pos) {
80 case 0:
81 assertEquality($value, "1", "Consume the item at position {$pos}");
82 break;
83 case 1:
84 assertEquality($value, "2", "Consume the item at position {$pos}");
85 break;
86 case 3:
87 assertEquality($value, '<foo bar="bar"/>', "Consume the item at position {$pos}");
88 break;
89 }
90}
91
92//Let's do it again
93$it = $xquery->getIterator();
94
95foreach($it as $pos => $value) {
96 switch($pos) {
97 case 0:
98 assertEquality($value, "1", "Consume the item at position {$pos}");
99 break;
100 case 1:
101 assertEquality($value, "2", "Consume the item at position {$pos}");
102 break;
103 case 3:
104 assertEquality($value, '<foo bar="bar"/>', "Consume the item at position {$pos}");
105 break;
106 }
107}
108
109//Try the same query with execute
110$result = $xquery->execute();
111assertEquality($result, "1 2<foo bar=\"bar\"/>", "Execute To URI");
112
113/* Test 4 */
114$xquery->importQueryFromURI("@phpPath@/test.xq");
115$result = $xquery->execute();
116assertEquality($result, "2", "Test importQueryFromURI");
117
118/* Test 5 */
119//$xquery->importQueryFromURI("http://zorba.s3.amazonaws.com/test.xq");
120//$result = $xquery->execute();
121//assertEquality($result, "2", "Test importQueryFromURI");
122?>
0123
=== modified file 'swig/php/CMakeLists.txt'
--- swig/php/CMakeLists.txt 2011-12-21 14:40:33 +0000
+++ swig/php/CMakeLists.txt 2012-01-07 17:53:24 +0000
@@ -38,6 +38,9 @@
38 SWIG_LINK_LIBRARIES (zorba_api ${PHP5_LIBRARY})38 SWIG_LINK_LIBRARIES (zorba_api ${PHP5_LIBRARY})
39 ENDIF (WIN32)39 ENDIF (WIN32)
4040
41 #Copy test to the build folder
42 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/test.xq" "${CMAKE_CURRENT_BINARY_DIR}/test.xq")
43
41 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")44 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")
42 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")45 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")
4346
@@ -55,20 +58,23 @@
5558
56 INSTALL (59 INSTALL (
57 FILES60 FILES
58 ${CMAKE_CURRENT_BINARY_DIR}/zorba_api_wrapper.php61 ${CMAKE_CURRENT_BINARY_DIR}/Zorba/XQueryProcessor.php
62 ${CMAKE_CURRENT_BINARY_DIR}/Zorba/zorba_api_wrapper.php
59 ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_SWIG_LIB_PREFIX}zorba_api.so63 ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_SWIG_LIB_PREFIX}zorba_api.so
60 DESTINATION ${PHP5_INSTALL_PATH}64 DESTINATION ${PHP5_INSTALL_PATH}
61 )65 )
62 ELSE (NOT WIN32 OR CYGWIN)66 ELSE (NOT WIN32 OR CYGWIN)
63 IF (MSVC_IDE)67 IF (MSVC_IDE)
64 INSTALL ( FILES 68 INSTALL ( FILES
65 ${CMAKE_CURRENT_BINARY_DIR}/zorba_api.php69 ${CMAKE_CURRENT_BINARY_DIR}/Zorba/XQueryProcessor.php
70 ${CMAKE_CURRENT_BINARY_DIR}/Zorba/zorba_api_wrapper.php
66 ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/zorba_api.dll71 ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/zorba_api.dll
67 COMPONENT "php_swig"72 COMPONENT "php_swig"
68 DESTINATION share/php )73 DESTINATION share/php )
69 ELSE (MSVC_IDE)74 ELSE (MSVC_IDE)
70 INSTALL ( FILES 75 INSTALL ( FILES
71 ${CMAKE_CURRENT_BINARY_DIR}/zorba_api.php76 ${CMAKE_CURRENT_BINARY_DIR}/Zorba/XQueryProcessor.php
77 ${CMAKE_CURRENT_BINARY_DIR}/Zorba/zorba_api_wrapper.php
72 ${CMAKE_CURRENT_BINARY_DIR}/php_zorba_api.dll78 ${CMAKE_CURRENT_BINARY_DIR}/php_zorba_api.dll
73 COMPONENT "php_swig"79 COMPONENT "php_swig"
74 DESTINATION share/php )80 DESTINATION share/php )
@@ -77,6 +83,7 @@
7783
78 ### Start PHP proxy generation84 ### Start PHP proxy generation
79 # Configure the test file85 # Configure the test file
86 SET (phpLibPrefix ${ZORBA_SWIG_LIB_PREFIX})
80 SET (phpAPIPath ${CMAKE_CURRENT_BINARY_DIR})87 SET (phpAPIPath ${CMAKE_CURRENT_BINARY_DIR})
81 SET (phpLibPrefix ${ZORBA_SWIG_LIB_PREFIX})88 SET (phpLibPrefix ${ZORBA_SWIG_LIB_PREFIX})
82 CONFIGURE_FILE (89 CONFIGURE_FILE (
@@ -84,8 +91,13 @@
84 ${CMAKE_CURRENT_BINARY_DIR}/generate_proxy.php91 ${CMAKE_CURRENT_BINARY_DIR}/generate_proxy.php
85 )92 )
8693
94 CONFIGURE_FILE (
95 ${CMAKE_CURRENT_SOURCE_DIR}/XQueryProcessor.php
96 ${CMAKE_CURRENT_BINARY_DIR}/Zorba/XQueryProcessor.php
97 )
98
87 ADD_CUSTOM_COMMAND (99 ADD_CUSTOM_COMMAND (
88 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zorba_api_wrapper.php100 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Zorba/zorba_api_wrapper.php
89 # the following addes a dependency to the *.cxx file that is generated by swig101 # the following addes a dependency to the *.cxx file that is generated by swig
90 DEPENDS ${swig_generated_file_fullname}102 DEPENDS ${swig_generated_file_fullname}
91 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generate_proxy.php.in103 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generate_proxy.php.in
@@ -94,7 +106,8 @@
94 )106 )
95 ADD_CUSTOM_TARGET (107 ADD_CUSTOM_TARGET (
96 Api_PHP_Wrapper ALL108 Api_PHP_Wrapper ALL
97 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/zorba_api_wrapper.php109 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Zorba/zorba_api_wrapper.php
110 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Zorba/XQueryProcessor.php
98 )111 )
99 ### End PHP proxy generation112 ### End PHP proxy generation
100113
101114
=== added file 'swig/php/XQueryProcessor.php'
--- swig/php/XQueryProcessor.php 1970-01-01 00:00:00 +0000
+++ swig/php/XQueryProcessor.php 2012-01-07 17:53:24 +0000
@@ -0,0 +1,353 @@
1<?php
2require_once 'Zorba/zorba_api_wrapper.php';
3
4class XQueryCompilerException extends Exception{}
5class XQueryProcessorException extends Exception{}
6
7/**
8 * Iterate over an instance of the XML Data Model (i.e, a sequence of items).
9 * This class implements the SPL Iterator interface.
10 *
11 * The following code snippet iterates over a small sequence of items.
12 * <code>
13 * <?php
14 * require_once 'Zorba/XQueryProcessor.php';
15 *
16 * $xquery = new XQueryProcessor();
17 * $xquery->importQuery('(1, 2, 3)');
18 *
19 * $iterator = $xquery->getIterator();
20 * foreach($it as $key => $value) {
21 * echo $value."\n";
22 * }
23 * ?>
24 * </code>
25 */
26class XQueryIterator implements Iterator {
27
28 private $xquery = null;
29 private $iterator = null;
30 private $item = null;
31 private $position = 0;
32 private $valid = false;
33
34 public function __construct(XQuery $xquery)
35 {
36 $this->xquery = $xquery;
37 $this->item = Item::createEmptyItem();
38 }
39
40 public function __destruct()
41 {
42 $this->xquery->destroy();
43 }
44
45 public function rewind()
46 {
47 if ($this->iterator != null) {
48 $this->iterator->close();
49 $this->iterator->destroy();
50 }
51
52 $this->position = 0;
53 $this->iterator = $this->xquery->iterator();
54 $this->iterator->open();
55 $this->valid = $this->iterator->next($this->item);
56 }
57
58 public function current()
59 {
60 return $this->item->serialize();
61 }
62
63 public function key()
64 {
65 return $this->position;
66 }
67
68 public function next()
69 {
70 ++$this->position;
71 $this->valid = $this->iterator->next($this->item);
72 }
73
74 public function valid()
75 {
76 return $this->valid;
77 }
78}
79
80/**
81 * The XQueryProcessor class allows to invoke
82 * <a href="http://www.zorba-xquery.com">Zorba XQuery Processor</a>.
83 *
84 * Instruction to install the extension can be found at <a href=""></a>.
85 *
86 * The following code snippet executes a small <em>Hello World</em> program:
87 * <code>
88 * <?php
89 * require_once 'ZorbaXQueryProcessor.php';
90 *
91 * $xquery = new XQueryProcessor();
92 *
93 * $query = <<<'XQ'
94 * declare variable $name external;
95 *
96 * <h1>Hello {$name}</h1>
97 * XQ;
98 *
99 * $xquery->importQuery($query);
100 *
101 * $xquery->setVariable('name', 'World');
102 *
103 * echo $xquery->execute();
104 * ?>
105 * </code>
106 */
107class XQueryProcessor {
108
109 private $store = null;
110 private $zorba = null;
111 private $query = null;
112 private $variables = array();
113
114 /**
115 * Creates an XQueryProcessor instance.
116 */
117 public function __construct(){
118 $this->store = InMemoryStore::getInstance();
119 $this->zorba = Zorba::getInstance($this->store);
120 }
121
122 /**
123 * Shutdowns the XQueryProcessor instance.
124 */
125 public function __destruct() {
126 $this->zorba->shutdown();
127 InMemoryStore::shutdown($this->store);
128 }
129
130 /**
131 * Import a query to execute.
132 * For instance, the following code snippets imports and executes the query '1+1':
133 * <code>
134 * $xquery = new ZorbaXQueryProcessor();
135 *
136 * $xquery->importQuery('1+1');
137 *
138 * echo $xquery->execute() . '\n';
139 * </code>
140 * In the following code snippet, the following code snippets imports and execute an <em>Hello World</em> query:
141 * <code>
142 * <?php
143 * $xquery = new XQueryProcessor();
144 *
145 * $query = <<<'XQ'
146 * let $world := 'World'
147 * return <h1>Hello {$world}</h1>
148 * XQ;
149 *
150 * $xquery->importQuery($query);
151 *
152 * echo $xquery->execute() . '\n';
153 * ?>
154 * </code>
155 *
156 * @param $query Query to execute.
157 * @return ZorbaXQueryProcessor instance.
158 */
159 public function importQuery($query) {
160 if(!is_string($query)) {
161 throw new XQueryProcessorException('The query parameter must be a string. For instance: XQueryProcessor->importQuery("1+1")');
162 }
163 $this->query = $query;
164 return $this;
165 }
166
167 /**
168 * Import a query to execute from its filename.
169 * For instance, the following code snippet imports the query file named <em>hello_word.xq</em>:
170 * <code>
171 * $xquery = new ZorbaXQueryProcessor();
172 *
173 * $xquery->importQueryiFromURI('hello_world.xq');
174 *
175 * echo $xquery->execute() . '\n';
176 * </code>
177 *
178 * @param $filename Filename of the query to execute.
179 * @return ZorbaXQueryProcessor instance.
180 */
181 public function importQueryFromURI($filename) {
182 $ctx = null;
183 if(func_num_args() == 2) {
184 $ctx = func_get_arg(1);
185 }
186 $query = file_get_contents($filename, FILE_USE_INCLUDE_PATH, $ctx);
187 $this->importQuery($query);
188 return $this;
189 }
190
191 /**
192 * Set value for an external variable.
193 *
194 * The following code snippet sets the value of the variable
195 * <em>$i</em> with <em>1</em>.
196 * <code>
197 * $xquery = new ZorbaXQueryProcessor();
198 *
199 * $query = <<<'XQ'
200 * declare variable $i as xs:integer external;
201 *
202 * $i + 1
203 * 'XQ';
204 *
205 * $xquery->importQuery($query);
206 * $xquery->setVariable($i, 1);
207 *
208 * echo $xquery->execute() . '\n';
209 * </code>
210 *
211 * The following code snippet sets the value of the variable <em>$i</em> in
212 * the local namespace with the value <em>1</em>.
213 * <code>
214 * $xquery = new ZorbaXQueryProcessor();
215 *
216 * $query = <<<'XQ'
217 * declare variable $local:i as xs:integer external;
218 *
219 * $i + 1
220 * 'XQ';
221 *
222 * $xquery->importQuery($query);
223 * $xquery->setVariable("http://www.w3.org/2005/xquery-local-functions", $i, 1);
224 *
225 * echo $xquery->execute() . '\n';
226 * </code>
227 *
228 * PHP types are converted to the following XML types:
229 * - <b>string</b>: xs:string
230 * - <b>float</b>: xs:float
231 * - <b>long</b>: xs:long
232 * - <b>integer</b>: xs:integer
233 * - <b>boolean</b>: xs:boolean
234 * - <b>DOMDocument</b>: document-node()
235 *
236 * @param string $namespace optional Namespace URI of the external variable.
237 * @param string $name Local name of the external variable.
238 * @param mixed $value of the external variable.
239 *
240 * return ZorbaXQueryProcessor instance.
241 */
242 public function setVariable($arg1, $arg2) {
243 $count = func_num_args();
244 if($count == 2) {
245 $name = func_get_arg(0);
246 $value = func_get_arg(1);
247 $this->variables['_'][$name] = $value;
248 } else {
249 $ns = func_get_arg(0);
250 $name = func_get_arg(1);
251 $value = func_get_arg(2);
252 $this->variables[$ns][$name] = $value;
253 }
254 return $this;
255 }
256
257 /**
258 * Execute the Query.
259 *
260 * @return Query result.
261 */
262 public function execute() {
263 //Execute
264 $query = $this->compile();
265 $result = $query->execute();
266 $query->destroy();
267 return $result;
268 }
269
270 public function getIterator() {
271 return new XQueryIterator($this->compile());
272 }
273 /**
274 *
275 */
276 private function compile()
277 {
278 if(!is_string($this->query)) {
279 throw new XQueryCompilerException('No Query Imported. Use XQueryProcessor->importQuery($query).');
280 }
281 //Compile Query
282 $query = $this->zorba->compileQuery($this->query);
283 //Set Variables
284 $dctx = $query->getDynamicContext();
285 foreach($this->variables as $ns => $variables){
286 foreach($variables as $name => $value) {
287 if($ns == "_") $ns = "";
288 $param = $this->zorba->compileQuery(".");
289 $value = $this->getItem($value);
290 $param->getDynamicContext()->setContextItem($value);
291 $dctx->setVariable($ns, $name, $param->iterator());
292 }
293 }
294 return $query;
295 }
296
297 /*
298 * Converts a PHP value to an XQuery Item.
299 * - DOMDocument & SimpleXMLElement: document-node()
300 * - String: xs:string
301 * - Integer: xs:integer
302 * - Boolean: xs:boolean
303 * - Float: xs:float
304 * - Long: xs:long
305 */
306 private function getItem($value) {
307 $itemFactory = $this->zorba->getItemFactory();
308
309 if($value instanceof DOMDocument or $value instanceof SimpleXMLElement) {
310 $value = $this->parseXML($value->saveXML());
311 } else if(is_string($value)) {
312 $value = $itemFactory->createString($value);
313 } else if(is_int($value)) {
314 $value = $itemFactory->createInteger($value);
315 } else if(is_bool($value)) {
316 $value = $itemFactory->createBoolean($value);
317 } else if(is_float($value)) {
318 $value = $itemFactory->createFloat($value);
319 } else if(is_long($value)) {
320 $value = $itemFactory->createLong($value);
321 } else {
322 throw new XQueryCompilerException("Unsupported variable type: ".gettype($value));
323 }
324
325 assert($value instanceof Item);
326
327 return $value;
328 }
329
330 /**
331 * Parse an XML string to an XQuery Item.
332 * This function is used internally only.
333 * @param $xml string XML string to parse.
334 *
335 * @return Item instance.
336 */
337 private function parseXML($xml)
338 {
339 $lDataManager = $this->zorba->getXmlDataManager();
340 $lDocMgr = $lDataManager->getDocumentManager();
341 $iter = $lDataManager->parseXML($xml);
342
343 $iter->open();
344 $doc = Item::createEmptyItem();
345
346 $iter->next($doc);
347 $iter->close();
348 $iter->destroy();
349
350 return $doc;
351 }
352}
353?>
0354
=== modified file 'swig/php/generate_proxy.php.in'
--- swig/php/generate_proxy.php.in 2011-12-21 14:40:33 +0000
+++ swig/php/generate_proxy.php.in 2012-01-07 17:53:24 +0000
@@ -164,7 +164,7 @@
164 }164 }
165}165}
166166
167file_put_contents('zorba_api_wrapper.php', $wrapper);167file_put_contents('Zorba/zorba_api_wrapper.php', $wrapper);
168168
169function getRefParameters(ReflectionMethod $method, array $params) {169function getRefParameters(ReflectionMethod $method, array $params) {
170 $result = "";170 $result = "";
171171
=== added file 'swig/php/test.xq'
--- swig/php/test.xq 1970-01-01 00:00:00 +0000
+++ swig/php/test.xq 2012-01-07 17:53:24 +0000
@@ -0,0 +1,1 @@
11+1

Subscribers

People subscribed via source and target branches