logo PHP XML Classes
A collection of classes and resources to process XML using PHP

Description: This is a class to access an Xindice XML database server from PHP, the class uses the XML-RPC API of Xindice. You can find information about Xindice here

Xindice (class_xindice.php)
PHP XML Classes
Xindice (class_xindice.php)

Description: This is a class to access an Xindice 1.0 xml database, the class uses the Xindice XML-RPC plugin so you need to check/install the Xindice XML-RPC plugin.

NEWS:
  • 07-04-2002 Documentation updated and package rebuilt.
  • 05-15-2002 Version 1.0 of this class is released.
This class code as well as documentation are hosted at SourceForge please visit our SourceForge page for releases, documentation, bug-tracking, support forums and mailing lists.

Resources Requirements
  • PHP 4.0.5+

Features To-dos
  • Full Xindice XML-RPC API implemented.

Contact:

Detailed description and usage:
include_once("class_xindice.php");
// Create the Xindice access object
$xi=new Xindice("$server",$port); //Default port is 4080
if(!$xi) {
  die("Cannot create Xindice object, check servername and port
"); } $xi->setXmlRpcDebug(0);

Once the class is instantiated use the object to call Xindice's RPC methods, check the following documentation for a complete listing of methods that can be called and what they do. The test.php script in this distribution checks the correct working of the class and the Xindice RPC Api.

Documentation

Classes

class_xindice

Extends: None
Description: This class implements the Xindice 1.0 XML-RPC API as class methods allowing PHP scripts to use an Xindice database server

Method Summary
 void Xindice(string $server_uri, int $server_port)
          Constructor
 string getError(string $server_uri, int $server_port)
          Returns the error message when a method fails
 void setXmlRpcDebug(boolean $debug)
          Sets the debug method of the XML-RPC library
 boolean createCollection(string $base, string $collectionName)
          Creates a collection from a base collection
 array listCollections(string $collection)
          Lists collections under a parent collection
 int getDocumentCount(string $collectionPath)
          Returns the number of documents in a collection
 boolean dropCollection(string $collectionPath)
          Drops a collection
 boolean insertDocument(string $collection, string $id, string $content)
          Inserts a new document in a collection
 boolean setDocument(string $collection, string $id, string $content)
          Updates/sets a document
 string getDocument(string $collection, string $id)
          Retrieves a document from the database
 array listDocuments(string $collection)
          Lists the documents under a collection
 boolean removeDocument(string $collection, string $id)
          Removes a document from a collection
 boolean createIndexer(string $collection, string $indexName, string $pattern)
          Creates an index
 boolean dropIndexer(string $collection, string $indexName)
          Drops an index
 Array listIndexers(string $collection)
          List indexes created on a collection
 string queryDocument(string $collection, string $type, string $query, string $id)
          Queries a document
 string queryCollection(string $collection, string $type, string $query)
          Queries a collection
 

Method Detail

Xindice

void Xindice(string $server_uri, int $server_port)
Constructor, must receive the URI of the Xindice server an optionally the port that the server uses (default=4080)
 
Parameters:
$server_uri - URI of the Xindice server, use "localhost" if local.
$server_port - Optional parameter indicating the Xindice server's port, defaulted to 4080 if not present.
Returns:
Nothing
Throws:
None

getError

string getError(string $server_uri, int $server_port)
If a method fails returning false you can check the value returned from this method for a description of an error.
 
Parameters:
Returns:
Error message
Throws:
None

setXmlRpcDebug

void setXmlRpcDebug(boolean $debug)
This class uses an XML-RPC library, if something goes wrong you can turn the XML-RPC debug of the library on using this method.
 
Parameters:
$debug - Set it ti true to turn debug mode on or false tu turn it off
Returns:
Nothing
Throws:
None

createCollection

boolean createCollection(string $base, string $collectionName)
Creates a collection from a base collection
 
Parameters:
$base - Name of the base collection where the new collection will be created
$collectionName - Name of the new creation to be created
Returns:
Throws:
None

listCollections

array listCollections(string $collection)
This method returns an array of strings with the names of collections under the parent collection passed as argument only child collections are returned not all the descendant collections
 
Parameters:
$collection - Name of the parent collection to be used
Returns:
An array with the name of the collections under the collection passed as argument
Throws:
None

getDocumentCount

int getDocumentCount(string $collectionPath)
Returns the number of documents present in the collection passed as argument
 
Parameters:
$collectionPath - Collection name
Returns:
The number of documents held by the collection
Throws:
None

dropCollection

boolean dropCollection(string $collectionPath)
Drops a collection all documents and subcollections under the collection are removed as well
 
Parameters:
$collectionPath - Path to the collection to be removed
Returns:
Throws:
None

insertDocument

boolean insertDocument(string $collection, string $id, string $content)
Inserts a new document in a collection
 
Parameters:
$collection - Name of the collection where the document will be inserted
$id - A string identifying the document inside the collection
$content - The XML document to be inserted
Returns:
Throws:
None

setDocument

boolean setDocument(string $collection, string $id, string $content)
Updates/sets a document
 
Parameters:
$collection - Name of the collection where the document resides
$id - Id of the document to be updated
$content - New XML content to be set
Returns:
Throws:
None

getDocument

string getDocument(string $collection, string $id)
Retrieves a document from the database
 
Parameters:
$collection - Collection name
$id - Document id
Returns:
The XML document or false if it not found
Throws:
None

listDocuments

array listDocuments(string $collection)
Returns an array of document names blonging to the given collection
 
Parameters:
$collection - Name of the collection
Returns:
An array of strings containing the documents' names
Throws:
None

removeDocument

boolean removeDocument(string $collection, string $id)
Removes a document from a collection
 
Parameters:
$collection - Name of the collection
$id - Id of the document to be removed
Returns:
Throws:
None

createIndexer

boolean createIndexer(string $collection, string $indexName, string $pattern)
This method creates an index on a collection given a pattern
 
Parameters:
$collection - Name of the collection where the index will be created
$indexName - Name of the index that will be created
$pattern - Pattern for the index
Returns:
Throws:
None

dropIndexer

boolean dropIndexer(string $collection, string $indexName)
Drops an index created for a collection
 
Parameters:
$collection - Name of the collection
$indexName - Name of the index to be dropped from the collection
Returns:
Throws:
None

listIndexers

Array listIndexers(string $collection)
List indexes created on a collection
 
Parameters:
$collection - Name of the collection
Returns:
An array of indexNames existing for the collection
Throws:
None

queryDocument

string queryDocument(string $collection, string $type, string $query, string $id)
This method is used to execute a query on a document from some collection, it can execute Xpath or XUpdate queries.
 
Parameters:
$collection - Name of the collection where the document belongs
$type - Name of the type of query (XPath or XUpdate)
$query - Query to be executed
$id - Id of the document to be queried
Returns:
The result of the query
Throws:
None

queryCollection

string queryCollection(string $collection, string $type, string $query)
This method is used to query all the documents in a collection
 
Parameters:
$collection - Name of the collection
$type - Type of query (XPath or XUpdate)
$query - Query to be executed on the collection
Returns:
Query result
Throws:
None


Contribute!: If you want to contribute a class to this project or help with new versions of existing classes please let me know it by emaill Hosted at:
SourceForge.net Logo
Contact & credits
Luis Argerich
Rogerio

OSI Certified Open Source Software
OSI
RSS FEED XHTML