/**
  * testRemoveNamespace method
  *
  * @access public
  * @return void
  */
 function testRemoveNamespace()
 {
     $this->Rss->addNs('custom', 'http://example.com/dtd.xml');
     $this->Rss->addNs('custom2', 'http://example.com/dtd2.xml');
     $manager =& XmlManager::getInstance();
     $expected = array('custom' => 'http://example.com/dtd.xml', 'custom2' => 'http://example.com/dtd2.xml');
     $this->assertEqual($manager->namespaces, $expected);
     $this->Rss->removeNs('custom');
     $expected = array('custom2' => 'http://example.com/dtd2.xml');
     $this->assertEqual($manager->namespaces, $expected);
 }
示例#2
0
文件: xml.php 项目: 5chain/CrowdFund
 /**
  * Sets/gets global XML options
  *
  * @param array $options
  * @return array
  * @access public
  * @static
  */
 function options($options = array())
 {
     $_this =& XmlManager::getInstance();
     $_this->options = array_merge($_this->options, $options);
     return $_this->options;
 }
示例#3
0
文件: 01.php 项目: kanbang/Colt
EXPECTED RESULT:
book1 = <book><title>Knowledge Discovery in Databases.</title></book>
ACTUAL RESULT:
<?php 
$book_name = 'book1';
$book_content = '<book><title>Knowledge Discovery in Databases.</title></book>';
$mgr = new XmlManager();
if ($mgr->existsContainer("test.dbxml")) {
    $mgr->removeContainer("test.dbxml");
}
$con = $mgr->createContainer("test.dbxml");
$con->putDocument($book_name, $book_content);
$doc = $con->getDocument($book_name);
$s = $doc->getContentAsString();
print $doc->getName() . " = {$s}\n";
unset($doc);
unset($con);
$mgr->removeContainer("test.dbxml");
示例#4
0
文件: index.php 项目: jdegges/pipweb
 function RetrieveConfigurationPropertiesFromXml($Path)
 {
     $FauxContext = "0";
     if ($this->ConfigFile == "") {
         $this->ErrorManager->AddError($FauxContext, $this->Name, "RetrieveConfigurationPropertiesFromXml", "You must supply a path to the configuration file");
     }
     // Retrieve config file contents
     $File = new File();
     $File->Name = $this->ConfigFile;
     $File->Path = $Path;
     $FileManager = new FileManager();
     $FileManager->ErrorManager =& $this->ErrorManager;
     $File = $FileManager->Get($File);
     // If there were errors retrieving the config file and we're in the CWD, report an error
     if ($this->ErrorManager->ErrorCount > 0 && $Path == $this->CurrentWorkingDirectory) {
         $this->ErrorManager->Clear();
         $this->ErrorManager->AddError($FauxContext, $this->Name, "RetrieveConfigurationPropertiesFromXml", "The root configuration file could not be found/read (_config.xml).");
         // If failed to retrieve the file from a non-root directory,
         // just accept the root file
     } elseif ($this->ErrorManager->ErrorCount > 0) {
         $this->ErrorManager->Clear();
         // If no errors occurred, continue to retrieve new configuration settings
     } else {
         // Create an XML Parser to retrieve configuration settings
         $XMan = new XmlManager();
         $XMan->ErrorManager =& $this->ErrorManager;
         $MyConfig = $XMan->ParseNode($File->Body);
         if ($MyConfig && $this->ErrorManager->ErrorCount == 0) {
             $this->StyleUrl = $XMan->GetNodeValueByName($MyConfig, "StyleUrl");
             $this->PageTitle = $XMan->GetNodeValueByName($MyConfig, "PageTitle");
             $this->PageIntroduction = $XMan->GetNodeValueByName($MyConfig, "PageIntroduction");
             $this->PageIntroduction = str_replace("[", "<", $this->PageIntroduction);
             $this->PageIntroduction = str_replace("]", ">", $this->PageIntroduction);
             $this->PageIntroduction = str_replace("\n", "<br />", $this->PageIntroduction);
             $this->DisplayHiddenFiles = $XMan->GetNodeValueByName($MyConfig, "DisplayHiddenFiles");
             $this->BrowseSubFolders = $XMan->GetNodeValueByName($MyConfig, "BrowseSubFolders");
             $this->SortBy = $XMan->GetNodeValueByName($MyConfig, "SortBy");
             $this->SortDirection = $XMan->GetNodeValueByName($MyConfig, "SortDirection");
             $this->DateFormat = $XMan->GetNodeValueByName($MyConfig, "DateFormat");
             $this->UsePageIntroductionInSubFolders = ForceBool($XMan->GetNodeValueByName($MyConfig, "UsePageIntroductionInSubFolders"), false);
             $this->PluginHeight = ForceInt($XMan->GetNodeValueByName($MyConfig, "PluginHeight"), $this->PluginHeight);
             $this->PluginWidth = ForceInt($XMan->GetNodeValueByName($MyConfig, "PluginWidth"), $this->PluginWidth);
             $this->FilesPerPage = ForceIncomingInt("fpp", ForceInt($XMan->GetNodeValueByName($MyConfig, "FilesPerPage"), $this->FilesPerPage));
             $this->MaxFilesPerPage = ForceInt($XMan->GetNodeValueByName($MyConfig, "MaxFilesPerPage"), $this->MaxFilesPerPage);
             $this->FitImagesToPage = ForceBool($XMan->GetNodeValueByName($MyConfig, "FitImagesToPage"), $this->FitImagesToPage);
             $this->UseThumbnails = ForceBool($XMan->GetNodeValueByName($MyConfig, "UseThumbnails"), $this->UseThumbnails);
             $this->HideFiles = explode(",", $XMan->GetNodeValueByName($MyConfig, "HideFiles"));
             for ($i = 0; $i < count($this->HideFiles); $i++) {
                 $this->FullyQualifiedHideFiles[] = $this->CurrentBrowsingDirectory . "/" . $this->HideFiles[$i];
             }
         }
     }
     return $this->ErrorManager->Iif();
 }
示例#5
0
文件: 10.php 项目: kanbang/Colt
Create two XML Containers within a Berkeley DB environment,
then within a Berkeley DB transaction add a document to
each container.

EXPECTED RESULT:
Success
ACTUAL RESULT:
<?php 
$book_name = 'book1';
$book_content = '<book><title>Knowledge Discovery in Databases.</title></book>';
foreach (array_merge(glob("__db*"), glob("log.O"), glob("test*.dbxml")) as $file) {
    @unlink($file);
}
$env = new Db4Env();
$env->open();
$mgr = new XmlManager($env);
$config = new XmlContainerConfig();
$config->setTransactional(true);
$mgr->setDefaultContainerConfig($config);
$con1 = $mgr->createContainer("test.dbxml");
$con2 = $mgr->createContainer("test2.dbxml");
$txn = $mgr->createTransaction();
$con1->putDocument($txn, $book_name, $book_content);
$con2->putDocument($txn, $book_name, $book_content);
$txn->commit();
unset($con1);
unset($con2);
unset($mgr);
$env->close();
print "Success\n";
示例#6
0
文件: 12.php 项目: kanbang/Colt
Currently non-functional.
<?php 
$book_name = 'book1';
$book_content = '<book><title>Knowledge Discovery in Databases.</title></book>';
class myResolver extends XmlResolver
{
    function resolveDocument($uri, &$result)
    {
        print "In resolveDocument({$uri})\n";
        $result = new XmlValue("<a><b>b</b></a>");
        return true;
    }
    function resolveCollection($uri, &$result)
    {
        print "In resolveCollection({$uri})\n";
        return false;
    }
}
$r = new myResolver();
$mgr = new XmlManager();
$mgr->registerResolver($r);
$con = $mgr->createContainer("test.dbxml");
$con->putDocument($book_name, $book_content);
$results = $mgr->query("doc('myscheme:xxx')/root");
print_r($results);
示例#7
0
文件: 03.php 项目: kanbang/Colt
Create an XmlContainer, add a document that includes a
namespace definition, create a query context, define a
namespace prefix to URI mapping, query the container
for the document within a context, iterate over the
result set displaying the values returned.

EXPECTED RESULT:
book1_ns = <book xmlns:books="http://foo.bar.com/books.dtd"><books:title>Knowledge Discovery in Databases.</books:title></book>
ACTUAL RESULT:
<?php 
$book_name = 'book1_ns';
$book_content = "<book xmlns:books='http://foo.bar.com/books.dtd'><books:title>Knowledge Discovery in Databases.</books:title></book>";
$container_name = 'test.dbxml';
$mgr = new XmlManager(null);
if (file_exists("test.dbxml")) {
    $mgr->removeContainer("test.dbxml");
}
$con = $mgr->createContainer("test.dbxml");
$con->putDocument($book_name, $book_content);
$qc = $mgr->createQueryContext();
$qc->setNamespace("books2", "http://foo.bar.com/books.dtd");
$results = $mgr->query("collection('test.dbxml')/*[books2:title='Knowledge Discovery in Databases.']", $qc);
$results->reset();
while ($results->hasNext()) {
    $val = $results->next();
    $doc = $val->asDocument();
    print $doc->getName() . " = " . $val->asString() . "\n";
}
示例#8
0
}
// If the folder exists, and there is a _config.xml file in the folder, reconfigure the filebrowser
if ($Config->CurrentWorkingDirectory != $Config->CurrentBrowsingDirectory) {
    $Config->RetrieveConfigurationPropertiesFromXml($Config->CurrentBrowsingDirectory);
}
// -----------------------------------
// 2. RETRIEVE FILE EXTENSION SETTINGS
// -----------------------------------
$File = new File();
$File->Name = $Config->FileTypesFile;
$File->Path = $Config->CurrentWorkingDirectory;
$FileManager = new FileManager();
$FileManager->ErrorManager =& $Config->ErrorManager;
$File = $FileManager->Get($File);
// Create an XML Parser to retrieve configuration settings
$XmlManager = new XmlManager();
$XmlManager->ErrorManager =& $ErrorManager;
$FileTypes = $XmlManager->ParseNode($File->Body);
// Create an array of all defined file types
$FileCollections = array();
$FolderCollection = array();
$ExtensionLibrary = array();
for ($i = 0; $i < count($FileTypes->Child); $i++) {
    if ($FileTypes->Child[$i]->Name == "FileGroup") {
        $FileCollections[$i] = new FileCollection($FileTypes->Child[$i]->Attributes["Name"]);
        for ($j = 0; $j < count($FileTypes->Child[$i]->Child); $j++) {
            $Node = $FileTypes->Child[$i]->Child[$j];
            if ($Node->Name == "Extensions") {
                // Ignore all items with a handler method of none
                if (@$Node->Attributes["HandlerMethod"] != "None") {
                    $CurrentExtensionArray = explode(",", $Node->Value);
 protected function getParsedDefListFromXml()
 {
     $xml_mgr = new XmlManager();
     $defs = $xml_mgr->getList($this->db_type);
     $defs = array_map(array($this, 'parseDef'), $defs);
     return $defs;
 }
示例#10
0
文件: 07.php 项目: kanbang/Colt
Create an XML Container, rename that container, delete the
container, and repeat.
EXPECTED RESULT:
Success
ACTUAL RESULT:
<?php 
$mgr = new XmlManager();
for ($i = 0; $i < 5; $i++) {
    $con = $mgr->createContainer("test1.dbxml");
    unset($con);
    $mgr->renameContainer("test1.dbxml", "test2.dbxml");
    $con = $mgr->openContainer("test2.dbxml");
    unset($con);
    $mgr->removeContainer("test2.dbxml");
}
print "Success\n";
示例#11
0
文件: 14.php 项目: kanbang/Colt
Displays the behavior of XmlInputStream.  When a is stream is created it can
only be destroyed by passing it to putDocument.  Also, once it is passed
to putDocument, if it is accessed again it will cause a segment fault

EXPECTED RESULT:
book1.xml = <book><title>Knowledge Discovery in Databases.</title></book>
ACTUAL RESULT:
<?php 
$file_name = "book1.xml";
$mgr = new XmlManager();
if ($mgr->existsContainer("test.dbxml")) {
    $mgr->removeContainer("test.dbxml");
}
$con = $mgr->createContainer("test.dbxml");
$inputstream = $mgr->createLocalFileInputStream($file_name);
$con->putDocument($file_name, $inputstream);
$doc = $con->getDocument($file_name);
$s = $doc->getContentAsString();
print $doc->getName() . " = {$s}\n";
unset($doc);
unset($con);
$mgr->removeContainer("test.dbxml");
示例#12
0
文件: 02.php 项目: kanbang/Colt
Create an XmlManager/XmlContainer, add a document, query the container
for the document, iterate over the result set displaying the
values returned.

EXPECTED RESULT:
book1 = <book><title>Knowledge Discovery in Databases.</title></book>
ACTUAL RESULT:
<?php 
$book_name = 'book1';
$book_content = '<book><title>Knowledge Discovery in Databases.</title></book>';
$container_name = 'test.dbxml';
$mgr = new XmlManager();
if (file_exists("test.dbxml")) {
    $mgr->removeContainer("test.dbxml");
}
$con = $mgr->createContainer("test.dbxml");
$con->putDocument($book_name, $book_content);
$results = $mgr->query("collection('test.dbxml')/book");
$results->reset();
while ($results->hasNext()) {
    $val = $results->next();
    $doc = $val->asDocument();
    print $doc->getName() . " = " . $val->asString() . "\n";
}
示例#13
0
文件: 05.php 项目: kanbang/Colt
Create an XmlContainer, define an equality string index
for booktitle elements, add a document, create a query
context, define a variable binding, query the container
for the document within a context referencing the variable
defined, iterate over the result set displaying the values
returned.

EXPECTED RESULT:
book1 = <book><title>Knowledge Discovery in Databases.</title></book>
ACTUAL RESULT:
<?php 
$book_name = 'book1';
$book_content = "<book><title>Knowledge Discovery in Databases.</title></book>";
$container_name = 'test.dbxml';
unlink($container_name);
$mgr = new XmlManager(null);
$con = $mgr->createContainer("test.dbxml");
$con->addIndex("", "title", "node-element-equality-string");
$con->putDocument($book_name, $book_content);
$qc = $mgr->createQueryContext();
$qc->setVariableValue("title", "Knowledge Discovery in Databases.");
$results = $mgr->query("collection('test.dbxml')//*[title=\$title]", $qc);
$results->reset();
while ($results->hasNext()) {
    $val = $results->next();
    $doc = $val->asDocument();
    print $doc->getName() . " = " . $val->asString() . "\n";
}
 /**
  * testNamespaces method
  *
  * @access public
  * @return void
  */
 function testNamespaces()
 {
     $source = '<a:container xmlns:a="http://example.com/a" xmlns:b="http://example.com/b" xmlns:c="http://example.com/c" xmlns:d="http://example.com/d" xmlns:e="http://example.com/e"><b:rule test=""><c:result>value</c:result></b:rule><d:rule test=""><e:result>value</e:result></d:rule></a:container>';
     $xml = new Xml($source);
     $expects = '<a:container xmlns:a="http://example.com/a" xmlns:b="http://example.com/b" xmlns:c="http://example.com/c" xmlns:d="http://example.com/d" xmlns:e="http://example.com/e" xmlns:f="http://example.com/f"><b:rule test=""><c:result>value</c:result></b:rule><d:rule test=""><e:result>value</e:result></d:rule></a:container>';
     $_xml = XmlManager::getInstance();
     $xml->addNamespace('f', 'http://example.com/f');
     $result = $xml->toString(array('cdata' => false));
     $this->assertEqual($expects, $result);
 }
示例#15
0
文件: 08.php 项目: kanbang/Colt
Create an use a transactional XML Container:
add a document, get the document, display the content of
the document.

EXPECTED RESULT:
book1 = <book><title>Knowledge Discovery in Databases.</title></book>
ACTUAL RESULT:
<?php 
$book_name = 'book1';
$book_content = '<book><title>Knowledge Discovery in Databases.</title></book>';
foreach (array_merge(glob("__db*"), glob("log.O"), glob("test*.dbxml")) as $file) {
    @unlink($file);
}
$env = new Db4Env();
$env->open();
$mgr = new XmlManager($env);
$con = $mgr->createContainer("test.dbxml");
$con->putDocument($book_name, $book_content);
$doc = $con->getDocument($book_name);
$s = $doc->getContentAsString();
print $doc->getName() . " = {$s}\n";
unset($doc);
unset($con);
$mgr->removeContainer("test.dbxml");
$env->close();
示例#16
0
EXPECTED RESULT:
book1 = <book><title>Knowledge Discovery in Databases.</title></book>
ACTUAL RESULT:
<?php 
#
# This is a very simple example of using try/catch and XmlException
# to get information on an exception thrown from Berkeley DB XML.
# The line that generates the exception is the query, which uses
# bad XQuery syntax.
#
$book_name = 'book1';
$book_content = '<book><title>Knowledge Discovery in Databases.</title></book>';
$mgr = new XmlManager();
try {
    $con = $mgr->createContainer("test.dbxml");
    $con->putDocument($book_name, $book_content);
    $qc = $mgr->createQueryContext();
    $res = $mgr->query("collection('test.dbxml')/x[", $qc);
    $doc = $con->getDocument("foo");
    $s = $doc->getContentAsString();
    print $doc->getName() . " = {$s}\n";
    unset($doc);
    unset($con);
} catch (XmlException $xe) {
    print "XmlException message: " . $xe->what() . "\n";
    print "XmlException code: " . $xe->getExceptionCode() . "\n";
    print "XmlException dbErrno: " . $xe->getDbErrno() . "\n";
    print "Query line: " . $xe->getQueryLine() . "\n";
    print "Query column: " . $xe->getQueryColumn() . "\n";
    unset($con);
}
示例#17
0
文件: 04.php 项目: kanbang/Colt
Create an XmlContainer, define an equality string index
for booktitle elements, add a document, query the container
for the document, iterate over the result set displaying
the values returned.

EXPECTED RESULT:
book1 = <book><title>Knowledge Discovery in Databases.</title></book>
ACTUAL RESULT:
<?php 
$book_name = 'book1';
$book_content = "<book><title>Knowledge Discovery in Databases.</title></book>";
$container_name = 'test.dbxml';
unlink($container_name);
$mgr = new XmlManager(null);
$con = $mgr->createContainer("test.dbxml");
$con->addIndex("", "title", "node-element-equality-string");
$con->putDocument($book_name, $book_content);
$results = $mgr->query("collection('test.dbxml')//*[title='Knowledge Discovery in Databases.']");
$results->reset();
while ($results->hasNext()) {
    $val = $results->next();
    $doc = $val->asDocument();
    print $doc->getName() . " = " . $val->asString() . "\n";
}