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: 691 lines (+523/-16)
11 files modified
doc/php/CMakeLists.txt (+1/-1)
doc/php/examples/CMakeLists.txt (+11/-4)
doc/php/examples/php.ini.in (+1/-0)
doc/php/examples/simple.php.in (+2/-2)
doc/php/examples/test.php.in (+120/-0)
doc/php/examples/zorba_api.php (+1/-1)
swig/php/CMakeLists.txt (+19/-6)
swig/php/XQueryProcessor.php (+365/-0)
swig/php/generate_proxy.php.in (+1/-1)
swig/php/test.xq (+1/-0)
swig/php/zorba_api.i (+1/-1)
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+88315@code.launchpad.net

This proposal supersedes a proposal from 2012-01-11.

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

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 : Posted in a previous version of this proposal

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

Revision history for this message
Matthias Brantner (matthias-brantner) wrote : Posted in a previous version of this proposal

Here are some more comments and questions:

* Copyright 2006-2008 The FLWOR Foundation.
=> * Copyright 2006-2012 The FLWOR Foundation.

* Iterate over an instance of the XML Data Model (i.e, a sequence of items).
* This class implements the SPL Iterator interface.

You can only iterate over a sequence of instances of the XDM. The sequence
is not an instance by itself.

* The XQueryProcessor class allows to invoke
* <a href="http://www.zorba-xquery.com">Zorba XQuery Processor</a>.

to invoke _the_ ...

* Instruction to install the extension can be found at <a href=""></a>.

Instruction_s_

* Shutdowns

Shuts down

* In the following code snippet, the following code snippets imports and execute an <em>Hello World</em> query:

confusing sentence

* Import a query to execute from its filename.

Import a query to execute from a file with the given name.

* $xquery->importQueryiFromURI('hello_world.xq');

$xquery->importQueryFromURI('hello_world.xq');

* Filename of the query to execute.

Filename containing the query to execute.

* Set value for an external variable.

Set a value for an external variable.

* The following code snippet sets the value of the variable
* <em>$i</em> with <em>1</em>.

The following code snippet sets the value of the variable
<em>$i</em> to <em>1</em> with type xs:integer.

* The following code snippet sets the value of the variable <em>$i</em> in
* the local namespace with the value <em>1</em>.

The following code snippet sets the value of the variable <em>$i</em> in
the local namespace to the value <em>1</em>.

getIterator and compile() don't have comments. Also, the indentation of compile() and getItem() seem to be broken

Why do you repeat the conversion rules from setVariable in the comment of getItem. Why does one rule include SimpleXMLElement and the other one doesn't?

Did you drop the streaming execution for execute()? If so, why?

review: Needs Fixing
Revision history for this message
William Candillon (wcandillon) wrote : Posted in a previous version of this proposal

Copyright statements are updated in r10603.
All the typos you sent are fixed in r10604.
PHPDoc docs comments are added for compile() and getIterator() in r10605.
The indentation of the compile() and getItem() is fixed in r10606.
r10607 is a fix for the duplicate and inconsistent description of the PHP to XQuery type mapping.
William finds out about IteratorAggregate in r10608 (http://php.net/manual/en/class.iteratoraggregate.php).

Revision history for this message
Matthias Brantner (matthias-brantner) wrote : Posted in a previous version of this proposal

- Is it on purpose that the only thing that is returned by the iterator is a serialized version of the item? For example, this will return an error for attribute nodes.

- There is a tab at the beginning of

  /**
   * Internal

- Is this wrapper supposed to be merged before the implementation of execute() can stream?

review: Needs Information
Revision history for this message
William Candillon (wcandillon) wrote : Posted in a previous version of this proposal

> - Is it on purpose that the only thing that is returned by the iterator is a
> serialized version of the item? For example, this will return an error for
> attribute nodes.
Yes.
We have two use cases for XQPHP:
- The mobile app which uses execute().
- The google earth demo which uses the iterator.

>
> - There is a tab at the beginning of
>
> /**
> * Internal
>
> - Is this wrapper supposed to be merged before the implementation of execute()
> can stream?
Yes

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

This new proposal is removing unwanted tabs.

lp:~zorba-coders/zorba/phpapi updated
10616. By Markos Zaharioudakis

fixed timing bug in zorbacmd Approved: Markos Zaharioudakis

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

I'm fine with it now. Before merging, please make sure the change is contained in the ChangeLog. Also, don't mention the obsolete comment in the description or commit message "- Revert bogus change in swig/php/generate_proxy.php.in (renaming of libPrefix to prefix).".

As an aside, importQueryFromURI still allows file system access only. I saw that the comment mentions that but it's still strange.

lp:~zorba-coders/zorba/phpapi updated
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

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

importQueryFromURI() can read any kind of stream and there is even a test for it.
It is commented out so the php tests don't rely on http connections.

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

Subscribers

People subscribed via source and target branches