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: 611 lines (+503/-8)
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 (+14/-3)
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
Matthias Brantner Needs Fixing
David Graf Pending
Rodolfo Ochoa Pending
Review via email: mp+86856@code.launchpad.net

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

Commit message

Add XQPHP

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).
It also fix issues with the PHP include paths to ease the deployment of the API into PHP apps.

The two key tests are:
- php1
- php2

To post a comment you must log in.
lp:~zorba-coders/zorba/phpapi updated
10595. By Gabriel Petrovay

Fixes one issue and a couple of warnings in the debugger.
Removes the ZORBA_WITH_DEBUGGER_CLIENT cmake variable. Approved: David Graf, Gabriel Petrovay

10596. By Daniel Turcanu

Fixing plan serializer memory leaks Approved: Daniel Turcanu, Matthias Brantner

10597. By Markos Zaharioudakis

fixed a bug in the cloning of a var_expr Approved: Markos Zaharioudakis

10598. By Markos Zaharioudakis

fixed bug in destruction of exit_catcher_expr Approved: Markos Zaharioudakis

10599. By Matthias Brantner

fix for bug #907872 (segfault when returning an input ItemSequence from an external function) Approved: Markos Zaharioudakis, Matthias Brantner

10600. By Markos Zaharioudakis

fixed wrong assertion in var_expr::remove_set_expr Approved: Markos Zaharioudakis

10601. By Paul J. Lucas

The bug was fixed in november. Paul did a fix, and the user had to do a clean rebuild.
The bug was not related to Windows 8. Approved: Matthias Brantner, Daniel Turcanu

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

- 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
lp:~zorba-coders/zorba/phpapi updated
10602. By Matthias Brantner

implementation of string:split function that doesn't accept regular expressions but allows for streamable processing of the input (resolves bug #898074) Approved: Matthias Brantner, William Candillon

10603. By Gabriel Petrovay

Fixes the two problems on mac that break the build:
- usage of wait() without parameters
- moved the "sys/wait" include in "process_listener.h" since that uses pid_t that is available once this header is included. Approved: Paul J. Lucas, Gabriel Petrovay

10604. By Markos Zaharioudakis

during destruction, var_decl_expr must remove itself from associated var_expr Approved: Markos Zaharioudakis

10605. By Matthias Brantner

fixed bug #911585 (management of variables during eval) Approved: Markos Zaharioudakis

10606. By Paul J. Lucas

Added missing #ifndef ZORBA_NO_FULL_TEXT. Approved: Matthias Brantner, Paul J. Lucas

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
1=== modified file 'doc/php/examples/CMakeLists.txt'
2--- doc/php/examples/CMakeLists.txt 2011-08-19 00:03:31 +0000
3+++ doc/php/examples/CMakeLists.txt 2012-01-06 10:08:25 +0000
4@@ -20,14 +20,21 @@
5 MESSAGE(STATUS "PHP Path:" ${phpPath})
6 SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php)
7 MESSAGE(STATUS "PHP Extension Path: " ${phpExtensionPath})
8+ SET(phpIncludePath ${CMAKE_BINARY_DIR}/swig/php)
9+ MESSAGE(STATUS "PHP Include Path: " ${phpExtensionPath})
10 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/php.ini.in ${CMAKE_CURRENT_BINARY_DIR}/php.ini)
11 MESSAGE(STATUS "Configuration file: " ${CMAKE_CURRENT_BINARY_DIR}/php.ini)
12 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/simple.php.in ${CMAKE_CURRENT_BINARY_DIR}/simple.php)
13 MESSAGE(STATUS "Simple configuration file: " ${CMAKE_CURRENT_BINARY_DIR}/simple.php)
14- ADD_TEST("php" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/simple.php)
15+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test.php.in ${CMAKE_CURRENT_BINARY_DIR}/test.php)
16+ MESSAGE(STATUS "PHP test file configured: " ${CMAKE_CURRENT_BINARY_DIR}/test.php)
17+ ADD_TEST("php1" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/simple.php)
18 MESSAGE(STATUS "Installing: " ${CMAKE_CURRENT_BINARY_DIR}/simple.php)
19-
20- INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/simple.php
21+ ADD_TEST("php2" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/test.php)
22+ MESSAGE(STATUS "Installing: " ${CMAKE_CURRENT_BINARY_DIR}/test.php)
23+
24+
25+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/simple.php ${CMAKE_CURRENT_BINARY_DIR}/test.php
26 COMPONENT "php_examples"
27 DESTINATION
28 share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/php/examples)
29
30=== modified file 'doc/php/examples/php.ini.in'
31--- doc/php/examples/php.ini.in 2009-10-30 16:34:37 +0000
32+++ doc/php/examples/php.ini.in 2012-01-06 10:08:25 +0000
33@@ -1,2 +1,3 @@
34 enable_dl=On
35 extension_dir=@phpExtensionPath@
36+include_path=".:@phpIncludePath@"
37\ No newline at end of file
38
39=== modified file 'doc/php/examples/simple.php.in'
40--- doc/php/examples/simple.php.in 2011-08-04 02:14:56 +0000
41+++ doc/php/examples/simple.php.in 2012-01-06 10:08:25 +0000
42@@ -14,7 +14,7 @@
43 * See the License for the specific language governing permissions and
44 * limitations under the License.
45 */
46-require '@phpPath@/zorba_api_wrapper.php';
47+require '@phpPath@/Zorba/zorba_api_wrapper.php';
48
49 function example_1(Zorba $aZorba)
50 {
51
52=== added file 'doc/php/examples/test.php.in'
53--- doc/php/examples/test.php.in 1970-01-01 00:00:00 +0000
54+++ doc/php/examples/test.php.in 2012-01-06 10:08:25 +0000
55@@ -0,0 +1,122 @@
56+<?php
57+/*
58+ * Copyright 2006-2008 The FLWOR Foundation.
59+ *
60+ * Licensed under the Apache License, Version 2.0 (the "License");
61+ * you may not use this file except in compliance with the License.
62+ * You may obtain a copy of the License at
63+ *
64+ * http://www.apache.org/licenses/LICENSE-2.0
65+ *
66+ * Unless required by applicable law or agreed to in writing, software
67+ * distributed under the License is distributed on an "AS IS" BASIS,
68+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
69+ * See the License for the specific language governing permissions and
70+ * limitations under the License.
71+ */
72+require '@phpPath@/Zorba/XQueryProcessor.php';
73+
74+function omitXMLDecl($xml)
75+{
76+ $xml = str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $xml);
77+ $xml = trim($xml);
78+ return $xml;
79+}
80+
81+function assertEquality($test, $reference, $label)
82+{
83+ $test = omitXMLDecl($test);
84+ echo "=====================================\n";
85+ var_dump($test);
86+ var_dump($reference);
87+ if($test != $reference) {
88+ throw new Exception(
89+ "Test "
90+ . $label
91+ . " failed. Result:\n"
92+ . $test
93+ . "\nDoesn't match reference:\n"
94+ . $reference
95+ );
96+ }
97+}
98+/* Test 1 */
99+$xquery = new XQueryProcessor();
100+$xquery->importQuery('1+1');
101+$result = $xquery->execute();
102+assertEquality($result, '2', "1+1");
103+
104+/* Test 2 */
105+$query = <<<'XQ'
106+declare variable $foo as xs:string external;
107+declare variable $bar as xs:integer external;
108+declare variable $doc1 as document-node() external;
109+declare variable $doc2-str as xs:string external;
110+declare variable $doc2 as document-node() := parse-xml($doc2-str);
111+
112+$foo, $bar, $doc1 , $doc2
113+XQ;
114+
115+$xquery->importQuery($query);
116+
117+$xquery->setVariable("foo", "bar");
118+$xquery->setVariable("bar", 3);
119+
120+$doc = simplexml_load_string('<root />');
121+$xquery->setVariable("doc1", $doc);
122+
123+$doc = "<root />";
124+$xquery->setVariable("doc2-str", $doc);
125+
126+$result = trim($xquery->execute());
127+assertEquality($result, "bar 3<root/><root/>", "Test PHP Types Mapping");
128+
129+/* Test 3 */
130+$xquery->importQuery("(1, 2, <foo bar='bar' />)");
131+$it = $xquery->getIterator();
132+
133+foreach($it as $pos => $value) {
134+ switch($pos) {
135+ case 0:
136+ assertEquality($value, "1", "Consume the item at position {$pos}");
137+ break;
138+ case 1:
139+ assertEquality($value, "2", "Consume the item at position {$pos}");
140+ break;
141+ case 3:
142+ assertEquality($value, '<foo bar="bar"/>', "Consume the item at position {$pos}");
143+ break;
144+ }
145+}
146+
147+//Let's do it again
148+$it = $xquery->getIterator();
149+
150+foreach($it as $pos => $value) {
151+ switch($pos) {
152+ case 0:
153+ assertEquality($value, "1", "Consume the item at position {$pos}");
154+ break;
155+ case 1:
156+ assertEquality($value, "2", "Consume the item at position {$pos}");
157+ break;
158+ case 3:
159+ assertEquality($value, '<foo bar="bar"/>', "Consume the item at position {$pos}");
160+ break;
161+ }
162+}
163+
164+//Try the same query with execute
165+$result = $xquery->execute();
166+assertEquality($result, "1 2<foo bar=\"bar\"/>", "Execute To URI");
167+
168+/* Test 4 */
169+$xquery->importQueryFromURI("@phpPath@/test.xq");
170+$result = $xquery->execute();
171+assertEquality($result, "2", "Test importQueryFromURI");
172+
173+/* Test 5 */
174+//$xquery->importQueryFromURI("http://zorba.s3.amazonaws.com/test.xq");
175+//$result = $xquery->execute();
176+//assertEquality($result, "2", "Test importQueryFromURI");
177+?>
178
179=== modified file 'swig/php/CMakeLists.txt'
180--- swig/php/CMakeLists.txt 2011-12-21 14:40:33 +0000
181+++ swig/php/CMakeLists.txt 2012-01-06 10:08:25 +0000
182@@ -38,6 +38,9 @@
183 SWIG_LINK_LIBRARIES (zorba_api ${PHP5_LIBRARY})
184 ENDIF (WIN32)
185
186+ #Copy test to the build folder
187+ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/test.xq" "${CMAKE_CURRENT_BINARY_DIR}/test.xq")
188+
189 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../StaticContext.h" "${CMAKE_CURRENT_BINARY_DIR}/StaticContext.h")
190 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/../ItemFactory.h" "${CMAKE_CURRENT_BINARY_DIR}/ItemFactory.h")
191
192@@ -55,7 +58,8 @@
193
194 INSTALL (
195 FILES
196- ${CMAKE_CURRENT_BINARY_DIR}/zorba_api_wrapper.php
197+ ${CMAKE_CURRENT_BINARY_DIR}/Zorba/XQueryProcessor.php
198+ ${CMAKE_CURRENT_BINARY_DIR}/Zorba/zorba_api_wrapper.php
199 ${CMAKE_CURRENT_BINARY_DIR}/${ZORBA_SWIG_LIB_PREFIX}zorba_api.so
200 DESTINATION ${PHP5_INSTALL_PATH}
201 )
202@@ -77,6 +81,7 @@
203
204 ### Start PHP proxy generation
205 # Configure the test file
206+ SET (phpLibPrefix ${ZORBA_SWIG_LIB_PREFIX})
207 SET (phpAPIPath ${CMAKE_CURRENT_BINARY_DIR})
208 SET (phpLibPrefix ${ZORBA_SWIG_LIB_PREFIX})
209 CONFIGURE_FILE (
210@@ -84,8 +89,13 @@
211 ${CMAKE_CURRENT_BINARY_DIR}/generate_proxy.php
212 )
213
214+ CONFIGURE_FILE (
215+ ${CMAKE_CURRENT_SOURCE_DIR}/XQueryProcessor.php
216+ ${CMAKE_CURRENT_BINARY_DIR}/Zorba/XQueryProcessor.php
217+ )
218+
219 ADD_CUSTOM_COMMAND (
220- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zorba_api_wrapper.php
221+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Zorba/zorba_api_wrapper.php
222 # the following addes a dependency to the *.cxx file that is generated by swig
223 DEPENDS ${swig_generated_file_fullname}
224 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generate_proxy.php.in
225@@ -94,7 +104,8 @@
226 )
227 ADD_CUSTOM_TARGET (
228 Api_PHP_Wrapper ALL
229- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/zorba_api_wrapper.php
230+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Zorba/zorba_api_wrapper.php
231+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Zorba/XQueryProcessor.php
232 )
233 ### End PHP proxy generation
234
235
236=== added file 'swig/php/XQueryProcessor.php'
237--- swig/php/XQueryProcessor.php 1970-01-01 00:00:00 +0000
238+++ swig/php/XQueryProcessor.php 2012-01-06 10:08:25 +0000
239@@ -0,0 +1,353 @@
240+<?php
241+require_once 'Zorba/zorba_api_wrapper.php';
242+
243+class XQueryCompilerException extends Exception{}
244+class XQueryProcessorException extends Exception{}
245+
246+/**
247+ * Iterate over an instance of the XML Data Model (i.e, a sequence of items).
248+ * This class implements the SPL Iterator interface.
249+ *
250+ * The following code snippet iterates over a small sequence of items.
251+ * <code>
252+ * <?php
253+ * require_once 'Zorba/XQueryProcessor.php';
254+ *
255+ * $xquery = new XQueryProcessor();
256+ * $xquery->importQuery('(1, 2, 3)');
257+ *
258+ * $iterator = $xquery->getIterator();
259+ * foreach($it as $key => $value) {
260+ * echo $value."\n";
261+ * }
262+ * ?>
263+ * </code>
264+ */
265+class XQueryIterator implements Iterator {
266+
267+ private $xquery = null;
268+ private $iterator = null;
269+ private $item = null;
270+ private $position = 0;
271+ private $valid = false;
272+
273+ public function __construct(XQuery $xquery)
274+ {
275+ $this->xquery = $xquery;
276+ $this->item = Item::createEmptyItem();
277+ }
278+
279+ public function __destruct()
280+ {
281+ $this->xquery->destroy();
282+ }
283+
284+ public function rewind()
285+ {
286+ if ($this->iterator != null) {
287+ $this->iterator->close();
288+ $this->iterator->destroy();
289+ }
290+
291+ $this->position = 0;
292+ $this->iterator = $this->xquery->iterator();
293+ $this->iterator->open();
294+ $this->valid = $this->iterator->next($this->item);
295+ }
296+
297+ public function current()
298+ {
299+ return $this->item->serialize();
300+ }
301+
302+ public function key()
303+ {
304+ return $this->position;
305+ }
306+
307+ public function next()
308+ {
309+ ++$this->position;
310+ $this->valid = $this->iterator->next($this->item);
311+ }
312+
313+ public function valid()
314+ {
315+ return $this->valid;
316+ }
317+}
318+
319+/**
320+ * The XQueryProcessor class allows to invoke
321+ * <a href="http://www.zorba-xquery.com">Zorba XQuery Processor</a>.
322+ *
323+ * Instruction to install the extension can be found at <a href=""></a>.
324+ *
325+ * The following code snippet executes a small <em>Hello World</em> program:
326+ * <code>
327+ * <?php
328+ * require_once 'ZorbaXQueryProcessor.php';
329+ *
330+ * $xquery = new XQueryProcessor();
331+ *
332+ * $query = <<<'XQ'
333+ * declare variable $name external;
334+ *
335+ * <h1>Hello {$name}</h1>
336+ * XQ;
337+ *
338+ * $xquery->importQuery($query);
339+ *
340+ * $xquery->setVariable('name', 'World');
341+ *
342+ * echo $xquery->execute();
343+ * ?>
344+ * </code>
345+ */
346+class XQueryProcessor {
347+
348+ private $store = null;
349+ private $zorba = null;
350+ private $query = null;
351+ private $variables = array();
352+
353+ /**
354+ * Creates an XQueryProcessor instance.
355+ */
356+ public function __construct(){
357+ $this->store = InMemoryStore::getInstance();
358+ $this->zorba = Zorba::getInstance($this->store);
359+ }
360+
361+ /**
362+ * Shutdowns the XQueryProcessor instance.
363+ */
364+ public function __destruct() {
365+ $this->zorba->shutdown();
366+ InMemoryStore::shutdown($this->store);
367+ }
368+
369+ /**
370+ * Import a query to execute.
371+ * For instance, the following code snippets imports and executes the query '1+1':
372+ * <code>
373+ * $xquery = new ZorbaXQueryProcessor();
374+ *
375+ * $xquery->importQuery('1+1');
376+ *
377+ * echo $xquery->execute() . '\n';
378+ * </code>
379+ * In the following code snippet, the following code snippets imports and execute an <em>Hello World</em> query:
380+ * <code>
381+ * <?php
382+ * $xquery = new XQueryProcessor();
383+ *
384+ * $query = <<<'XQ'
385+ * let $world := 'World'
386+ * return <h1>Hello {$world}</h1>
387+ * XQ;
388+ *
389+ * $xquery->importQuery($query);
390+ *
391+ * echo $xquery->execute() . '\n';
392+ * ?>
393+ * </code>
394+ *
395+ * @param $query Query to execute.
396+ * @return ZorbaXQueryProcessor instance.
397+ */
398+ public function importQuery($query) {
399+ if(!is_string($query)) {
400+ throw new XQueryProcessorException('The query parameter must be a string. For instance: XQueryProcessor->importQuery("1+1")');
401+ }
402+ $this->query = $query;
403+ return $this;
404+ }
405+
406+ /**
407+ * Import a query to execute from its filename.
408+ * For instance, the following code snippet imports the query file named <em>hello_word.xq</em>:
409+ * <code>
410+ * $xquery = new ZorbaXQueryProcessor();
411+ *
412+ * $xquery->importQueryiFromURI('hello_world.xq');
413+ *
414+ * echo $xquery->execute() . '\n';
415+ * </code>
416+ *
417+ * @param $filename Filename of the query to execute.
418+ * @return ZorbaXQueryProcessor instance.
419+ */
420+ public function importQueryFromURI($filename) {
421+ $ctx = null;
422+ if(func_num_args() == 2) {
423+ $ctx = func_get_arg(1);
424+ }
425+ $query = file_get_contents($filename, FILE_USE_INCLUDE_PATH, $ctx);
426+ $this->importQuery($query);
427+ return $this;
428+ }
429+
430+ /**
431+ * Set value for an external variable.
432+ *
433+ * The following code snippet sets the value of the variable
434+ * <em>$i</em> with <em>1</em>.
435+ * <code>
436+ * $xquery = new ZorbaXQueryProcessor();
437+ *
438+ * $query = <<<'XQ'
439+ * declare variable $i as xs:integer external;
440+ *
441+ * $i + 1
442+ * 'XQ';
443+ *
444+ * $xquery->importQuery($query);
445+ * $xquery->setVariable($i, 1);
446+ *
447+ * echo $xquery->execute() . '\n';
448+ * </code>
449+ *
450+ * The following code snippet sets the value of the variable <em>$i</em> in
451+ * the local namespace with the value <em>1</em>.
452+ * <code>
453+ * $xquery = new ZorbaXQueryProcessor();
454+ *
455+ * $query = <<<'XQ'
456+ * declare variable $local:i as xs:integer external;
457+ *
458+ * $i + 1
459+ * 'XQ';
460+ *
461+ * $xquery->importQuery($query);
462+ * $xquery->setVariable("http://www.w3.org/2005/xquery-local-functions", $i, 1);
463+ *
464+ * echo $xquery->execute() . '\n';
465+ * </code>
466+ *
467+ * PHP types are converted to the following XML types:
468+ * - <b>string</b>: xs:string
469+ * - <b>float</b>: xs:float
470+ * - <b>long</b>: xs:long
471+ * - <b>integer</b>: xs:integer
472+ * - <b>boolean</b>: xs:boolean
473+ * - <b>DOMDocument</b>: document-node()
474+ *
475+ * @param string $namespace optional Namespace URI of the external variable.
476+ * @param string $name Local name of the external variable.
477+ * @param mixed $value of the external variable.
478+ *
479+ * return ZorbaXQueryProcessor instance.
480+ */
481+ public function setVariable($arg1, $arg2) {
482+ $count = func_num_args();
483+ if($count == 2) {
484+ $name = func_get_arg(0);
485+ $value = func_get_arg(1);
486+ $this->variables['_'][$name] = $value;
487+ } else {
488+ $ns = func_get_arg(0);
489+ $name = func_get_arg(1);
490+ $value = func_get_arg(2);
491+ $this->variables[$ns][$name] = $value;
492+ }
493+ return $this;
494+ }
495+
496+ /**
497+ * Execute the Query.
498+ *
499+ * @return Query result.
500+ */
501+ public function execute() {
502+ //Execute
503+ $query = $this->compile();
504+ $result = $query->execute();
505+ $query->destroy();
506+ return $result;
507+ }
508+
509+ public function getIterator() {
510+ return new XQueryIterator($this->compile());
511+ }
512+ /**
513+ *
514+ */
515+ private function compile()
516+ {
517+ if(!is_string($this->query)) {
518+ throw new XQueryCompilerException('No Query Imported. Use XQueryProcessor->importQuery($query).');
519+ }
520+ //Compile Query
521+ $query = $this->zorba->compileQuery($this->query);
522+ //Set Variables
523+ $dctx = $query->getDynamicContext();
524+ foreach($this->variables as $ns => $variables){
525+ foreach($variables as $name => $value) {
526+ if($ns == "_") $ns = "";
527+ $param = $this->zorba->compileQuery(".");
528+ $value = $this->getItem($value);
529+ $param->getDynamicContext()->setContextItem($value);
530+ $dctx->setVariable($ns, $name, $param->iterator());
531+ }
532+ }
533+ return $query;
534+ }
535+
536+ /*
537+ * Converts a PHP value to an XQuery Item.
538+ * - DOMDocument & SimpleXMLElement: document-node()
539+ * - String: xs:string
540+ * - Integer: xs:integer
541+ * - Boolean: xs:boolean
542+ * - Float: xs:float
543+ * - Long: xs:long
544+ */
545+ private function getItem($value) {
546+ $itemFactory = $this->zorba->getItemFactory();
547+
548+ if($value instanceof DOMDocument or $value instanceof SimpleXMLElement) {
549+ $value = $this->parseXML($value->saveXML());
550+ } else if(is_string($value)) {
551+ $value = $itemFactory->createString($value);
552+ } else if(is_int($value)) {
553+ $value = $itemFactory->createInteger($value);
554+ } else if(is_bool($value)) {
555+ $value = $itemFactory->createBoolean($value);
556+ } else if(is_float($value)) {
557+ $value = $itemFactory->createFloat($value);
558+ } else if(is_long($value)) {
559+ $value = $itemFactory->createLong($value);
560+ } else {
561+ throw new XQueryCompilerException("Unsupported variable type: ".gettype($value));
562+ }
563+
564+ assert($value instanceof Item);
565+
566+ return $value;
567+ }
568+
569+ /**
570+ * Parse an XML string to an XQuery Item.
571+ * This function is used internally only.
572+ * @param $xml string XML string to parse.
573+ *
574+ * @return Item instance.
575+ */
576+ private function parseXML($xml)
577+ {
578+ $lDataManager = $this->zorba->getXmlDataManager();
579+ $lDocMgr = $lDataManager->getDocumentManager();
580+ $iter = $lDataManager->parseXML($xml);
581+
582+ $iter->open();
583+ $doc = Item::createEmptyItem();
584+
585+ $iter->next($doc);
586+ $iter->close();
587+ $iter->destroy();
588+
589+ return $doc;
590+ }
591+}
592+?>
593
594=== modified file 'swig/php/generate_proxy.php.in'
595--- swig/php/generate_proxy.php.in 2011-12-21 14:40:33 +0000
596+++ swig/php/generate_proxy.php.in 2012-01-06 10:08:25 +0000
597@@ -164,7 +164,7 @@
598 }
599 }
600
601-file_put_contents('zorba_api_wrapper.php', $wrapper);
602+file_put_contents('Zorba/zorba_api_wrapper.php', $wrapper);
603
604 function getRefParameters(ReflectionMethod $method, array $params) {
605 $result = "";
606
607=== added file 'swig/php/test.xq'
608--- swig/php/test.xq 1970-01-01 00:00:00 +0000
609+++ swig/php/test.xq 2012-01-06 10:08:25 +0000
610@@ -0,0 +1,1 @@
611+1+1

Subscribers

People subscribed via source and target branches