The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

XML::DB::Database - Abstract class for extension by XML:SimpleDB drivers

SYNOPSIS

  use XML::DB::Database;

DESCRIPTION

This is an abstract class implementing the interface Database from the XML:DB base specification. It should only be used indirectly, as superclass for a specific database driver which implements the Database interface. Examples are Exist.pm and Xindice.pm.

BUGS

AUTHOR

        Graham Seaman
        CPAN ID: GSEAMAN
        graham@opencollector.org

COPYRIGHT

Copyright (c) 2002 Graham Seaman. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO

perl(1).

METHODS (all called indirectly by other modules)

getName

    Usage : getName()

    Purpose : Returns the database name (eg. 'eXist')

    Argument : None

    Returns : String

getName

    Usage : getConformanceLevel()

    Purpose : Returns the conformance level of this implementation (see http://www.xmldb.org)

    Argument : None

    Returns : String

getCollection

    Usage : $collection = getCollection($uri, $username, $passwd)

    Purpose : Returns a Collection

    Argument : uri for collection, optional name and password

    Returns : Collection

acceptsURI

    Usage : if (db::acceptsURI(exist:://....)){ ...

    Purpose : Returns true if database accepts URI starting with name (eg. 'eXist', 'Xindice')

    Argument : A URI

    Returns : Boolean

    Comment : Broken. FIXME

getProperty

    Usage : $property = getProperty($name)

    Purpose : Returns named property

    Argument : name of property

    Returns : String or null

setProperty

    Usage : $property = setProperty($name, $value)

    Purpose : Sets property to value

    Argument : name and value

    Returns : void

new

    Usage : Should be called indirectly via DatabaseManager

    Purpose : Constructor

Interface

The following methods should be implemented by all concrete driver implementations. They are part of the internal working of this package, not part of the XML:DB specification. All can potentially throw exceptions.

createId($collectionName)

    Usage : $id = $driver->createId($collectionName)

    Purpose : Creates a new unique OID for this collection.

    Argument : collectionName The name of the collection including database instance.

    Returns : The generated id

createCollection

    Usage : $driver->createCollection($parentCollection, $collectionName )

    Purpose : Creates specified Collection

    Arguments :

    • $parentCollection - The name of the collection including database instance to create the collection.

    • $collectionName The name of newly created collection.

    Returns : 1 on success

dropCollection

    Usage : $driver->dropCollection($collectionName )

    Purpose : Deletes specified collection from the database

    Argument : $collectionName - The name of the collection including database instance.

    Returns : 1 on success

listChildCollections

    Usage : $collections = $driver->listChildCollections($collectionName )

    Purpose : Lists all child collections under this collection.

    Argument : $collectionName - The name of the collection including database instance.

    Returns : Arrayref for the list of child collections.

queryCollection

    Usage : $xml = $driver->queryCollection($collectionName, $style, $query, \%namespaces)

    Purpose : Executes a query against a collection

    Arguments :

    • $collectionName - The name of the collection including database instance.

    • $style - XPath or XUpdate

    • $query The query string to execute, should be in the proper syntax for the style specified.

    • \%namespaces A Hashref containing namespace definitions. The key is the namespace prefix and the value is the namespace URI.

    Returns : The result of the query as XML.

getDocument

    Usage : $document = $driver->getDocument($collectionName, $id )

    Purpose : Retrieves a document from the collection

    Arguments

    • $collectionName - The name of the collection including database instance.

    • $id - The id of the document to retrieve

    Returns : The retrieved Document

getDocumentCount

    Usage : $count = getDocumentCount($collectionName )

    Purpose : Returns the number of documents stored in this collection.

    Argument : $collectionName - The name of the collection including database instance.

    Returns : The number of documents in the collection

insertDocument

    Usage : $id = insertDocument($collectionName, $content, $id )

    Purpose : Inserts a new document into the collection

    Arguments :

    • $collectionName - The name of the collection including database instance

    • $content - The Document to insert

    • $id - The id to insert the document under or the empty string if a new id should be generated automatically.

    Returns : The id of the inserted document.

listDocuments

    Usage : @documents = listDocuments($collectionName )

    Purpose : Returns a set containing all documents in the collection.

    Argument : $collectionName - The name of the collection including database instance.

    Returns : Arrayref of document ids in the specified collection

queryDocument

    Usage : $xml = queryDocument($collectionName, $style, $query, %namespaces, $id )

    Purpose : Executes a query against a Document in this collection

    Arguments :

    • $collectionName - The name of the collection including database instance.

    • $style - XPath or XUpdate

    • $query - The query string to execute, should be in the proper syntax for the style specified

    • \%namespaces - A Hashtable containing namespace definitions. The key is the namespace prefix and the value is the namespace URI

    • $id the id of the document to query.

    Returns : The result of the query as XML.

removeDocument

    Usage : removeDocument($collectionName, $id )

    Purpose : Deletes a document from the collection.

    Arguments :

    • $collectionName - The name of the collection including database instance.

    • $id - The id of the Document to delete

    Returns : 1 on success

splitContents

    Usage : \@resources = $db->splitContents($data)

    Purpose : Breaks fragments returned by query into separate elements to create a ResourceSet

    Arguments : Data returned by query (string)

    Returns : Array ref

update

updateResource