本文整理汇总了PHP中Zend_Dom_Query::setDocumentXML方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Dom_Query::setDocumentXML方法的具体用法?PHP Zend_Dom_Query::setDocumentXML怎么用?PHP Zend_Dom_Query::setDocumentXML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Dom_Query
的用法示例。
在下文中一共展示了Zend_Dom_Query::setDocumentXML方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test11RetrieveConceptFiletrStatus
public function test11RetrieveConceptFiletrStatus()
{
// Use API to search for concept and filter on status
// todo: test additionele zoek parameters
print "\n" . "Test: get concept via filters";
$client = Authenticator::authenticate();
//prepare and send request
$uri = BASE_URI_ . '/public/api/find-concepts?q=prefLabel:' . CONCEPT_prefLabel . '&status:' . CONCEPT_status_forfilter . '&tenant:' . TENANT . '&inScheme:' . CONCEPT_schema_forfilter;
print "\n filtered request's uri: " . $uri . "\n";
$client->setUri($uri);
$client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
$client->SetHeaders(array('Accept' => 'text/html,application/xhtml+xml,application/xml', 'Content-Type' => 'application/xml', 'Accept-Language' => 'nl,en-US,en', 'Accept-Encoding' => 'gzip, deflate', 'Connection' => 'keep-alive'));
$response = $client->request(Zend_Http_Client::GET);
// analyse respond
print "\n get status: " . $response->getMessage() . "\n";
$this->AssertEquals(200, $response->getStatus());
$namespaces = array("rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "skos" => "http://www.w3.org/2004/02/skos/core#", "openskos" => "http://openskos.org/xmlns/openskos.xsd");
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($response->getBody());
$dom->registerXpathNamespaces($namespaces);
$elem = $dom->queryXpath('/rdf:RDF');
$this->assertEquals(XML_ELEMENT_NODE, $elem->current()->nodeType, 'The root node of the response is not an element');
$this->assertEquals(1, $elem->current()->getAttribute("openskos:numFound"));
$resDescr = $dom->queryXpath('/rdf:RDF/rdf:Description');
$i = 0;
$l = $resDescr->count();
$resDescr->rewind();
while ($i < $l) {
$labels = $resDescr->current()->getElementsByTagName("altLabel");
//print "\n val:" . $labels ->item(0) ->textContent;
$randomn = rand(0, 4096);
$labels->item(0)->nodeValue = "test-1-" . $randomn;
$doc = $resDescr->current()->ownerDocument;
$xml = $doc->saveXML();
var_dump($xml);
// try $newdom isntead of $dom, which can be corrupted
//$dom = new DOMDocument('1.0', 'utf-8');
//$rdf = $dom -> createElement("rdf:RDF");
//$dom ->importNode($newDescr, TRUE);// appendChild($rdf);
//$rdf ->appendChild($newDescr);
//$xml = $dom->saveXML();
//var_dump($xml);
$client->setUri(BASE_URI_ . "/public/api/concept?");
$client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
$response = $client->setEncType('text/xml')->setRawData($xml)->setParameterGet('tenant', TENANT)->setParameterGet('collection', COLLECTION_1_code)->setParameterGet('key', API_KEY)->request(Zend_Http_Client::PUT);
print "\n Update response message: " . $response->getMessage();
$this->AssertEquals(200, $response->getStatus(), 'Update request returned worng status code');
$resDescr->next();
$i++;
}
}
示例2: assertions
private function assertions($response)
{
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($response->GetBody());
// comparing test xml with teh data from the xml from the file
// Asserting
// Assert - 1
$results1 = $dom->query('skos:notation');
$this->AssertEquals(1, count($results1));
$this->AssertEquals(self::$notation, $results1->current()->nodeValue);
// Assert - 2
$results2 = $dom->query('skos:inScheme');
$this->AssertEquals(1, count($results2));
$this->assertStringStartsWith("http://data.beeldengeluid.nl/gtaa/Onderwerpen", $results2->current()->getAttribute('rdf:resource'));
}
示例3: assertionsForXMLRDFCollection
private function assertionsForXMLRDFCollection($response)
{
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($response->getBody());
$results1 = $dom->query('rdf:Description');
$collection_1_description_about = BASE_URI_ . '/api/collections/' . COLLECTION_1_tenant . ":" . COLLECTION_1_code;
$this->AssertEquals($collection_1_description_about, $results1->current()->getAttribute('rdf:about'));
$results2 = $dom->query('rdf:type');
$this->AssertEquals(COLLECTION_1_type_resource, $results2->current()->getAttribute('rdf:resource'));
$results3 = $dom->query('dcterms:title');
$this->AssertEquals(COLLECTION_1_title, $results3->current()->nodeValue);
$results4 = $dom->query('dcterms:creator');
$this->AssertEquals(COLLECTION_1_creator, $results4->current()->nodeValue);
$this->AssertEquals(COLLECTION_1_creator_about, $results4->current()->getAttribute('rdf:about'));
}
示例4: assertionsXMLRDFInstitutions
private function assertionsXMLRDFInstitutions($response)
{
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($response->getBody());
$results1 = $dom->query('v:Vcard');
$this->assertEquals(NUMBER_INSTITUTIONS, count($results1));
for ($i = 0; $i < NUMBER_INSTITUTIONS; $i++) {
$this->assertionsXMLRDFInstitution($dom, $i);
}
}
示例5: testImport
public function testImport()
{
print "\n" . "Testing import ... ";
$response = RequestResponse::ImportConceptRequest(self::$client, self::$postData, self::$boundaryNumeric);
Logging::var_error_log("\n Response body ", $response->getBody(), __DIR__ . "/ImportResponse.html");
$this->AssertEquals(200, $response->getStatus(), 'Failed to import concept');
$output = array('0' => "The ouput of sending jobs: ");
$retvar = 0;
$sendjob = exec(PHP_JOBS_PROCESS, $output, $retvar);
// check via spraql query
//$sparqlResult = $this ->sparqlRetrieveTriplesForNotation(self::$notation);
//var_dump($sparqlResult);
self::$client->setUri(BASE_URI_ . '/public/api/find-concepts?q=prefLabel:' . self::$prefLabel);
$responseGet = self::$client->request(Zend_Http_Client::GET);
$this->AssertEquals(200, $responseGet->getStatus(), $responseGet->getMessage());
$dom = new Zend_Dom_Query();
$namespaces = RequestResponse::setNamespaces();
$dom->registerXpathNamespaces($namespaces);
$xml = $responseGet->getBody();
$dom->setDocumentXML($xml);
var_dump($xml);
$results1 = $dom->query('rdf:RDF');
$this->AssertEquals(1, $results1->current()->getAttribute('openskos:numFound'));
$results2 = $dom->queryXpath('/rdf:RDF/rdf:Description');
$this->AssertEquals(1, count($results2));
}
示例6: getAbout
private function getAbout($response)
{
$dom = new Zend_Dom_Query();
$namespaces = RequestResponse::setNamespaces();
$dom->setDocumentXML($response->getBody());
$dom->registerXpathNamespaces($namespaces);
$description = $dom->queryXpath('/rdf:RDF/rdf:Description');
$this->assertEquals(1, $description->count(), "rdf:Description element is not declared");
$resURI = $description->current()->getAttribute("rdf:about");
$this->assertNotEquals("", $resURI, "No valid uri for SKOS concept");
return $resURI;
}
示例7: retrieveConceptDomViaNotation
private function retrieveConceptDomViaNotation($client, $notation, $accept)
{
$uri = BASE_URI_ . '/public/api/find-concepts?q=notation:' . $notation;
$body = $this->retrieveConceptAsResponseBody($client, $uri, $accept);
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($body);
return $dom;
}
示例8: assertionsForXMLRDFConcept
private function assertionsForXMLRDFConcept($response, $prefLabel, $altLabel, $hiddenLabel, $lang, $definition, $notation, $topConceptOf, $inScheme)
{
$dom = new Zend_Dom_Query();
$namespaces = RequestResponse::setNamespaces();
$dom->registerXpathNamespaces($namespaces);
$xml = $response->getBody();
$dom->setDocumentXML($xml);
$results1 = $dom->queryXpath('/rdf:RDF/rdf:Description');
$this->AssertEquals(1, count($results1));
$this->AssertStringStartsWith(BASE_URI_ . "/" . OPENSKOS_SET_code, $results1->current()->getAttribute('rdf:about'));
$results2 = $dom->query('rdf:type');
$this->AssertEquals(CONCEPT_type, $results2->current()->getAttribute('rdf:resource'));
$results3 = $dom->query('skos:notation');
$this->AssertEquals($notation, $results3->current()->nodeValue);
$results4 = $dom->query('skos:inScheme');
$this->AssertEquals($inScheme, count($results4));
$results5 = $dom->query('skos:topConceptOf');
$this->AssertEquals($topConceptOf, count($results5));
$results6 = $dom->query('skos:prefLabel');
$this->AssertEquals($lang, $results6->current()->getAttribute('xml:lang'));
$this->AssertEquals($prefLabel, $results6->current()->nodeValue);
$results6a = $dom->query('skos:altLabel');
$this->AssertEquals($lang, $results6a->current()->getAttribute('xml:lang'));
$this->AssertEquals($altLabel, $results6a->current()->nodeValue);
$results6b = $dom->query('skos:hiddenLabel');
$this->AssertEquals($lang, $results6b->current()->getAttribute('xml:lang'));
$this->AssertEquals($hiddenLabel, $results6b->current()->nodeValue);
$results7 = $dom->query('skos:definition');
$this->AssertEquals($definition, $results7->current()->nodeValue);
$results9 = $dom->query('dcterms:creator');
$this->AssertStringStartsWith(BASE_URI_, $results9->current()->getAttribute('rdf:resource'));
$results8 = $dom->query('openskos:set');
$this->AssertEquals(OPENSKOS_SET_code, $results8->current()->nodeValue);
}
示例9: assertionsForXMLRDFConcept
private function assertionsForXMLRDFConcept($response)
{
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($response->getBody());
$results1 = $dom->query('rdf:Description');
$this->AssertEquals(CONCEPT_Description_about, $results1->current()->getAttribute('rdf:about'));
$results2 = $dom->query('rdf:type');
$this->AssertEquals(CONCEPT_type_resource, $results2->current()->getAttribute('rdf:resource'));
$results3 = $dom->query('skos:notation');
$this->AssertEquals(CONCEPT_notation, $results3->current()->nodeValue);
$results4 = $dom->query('skos:inScheme');
$this->AssertEquals(CONCEPT_NUMBER_inScheme, count($results4));
$results5 = $dom->query('skos:topConceptOf');
$this->AssertEquals(CONCEPT_NUMBER_topConceptOf, count($results5));
$results6 = $dom->query('skos:prefLabel');
$this->AssertEquals(CONCEPT_prefLabel_lang, $results6->current()->getAttribute('xml:lang'));
$this->AssertEquals(CONCEPT_prefLabel, $results6->current()->nodeValue);
}
示例10: test07CreateConceptWithoutUri
public function test07CreateConceptWithoutUri()
{
// Create a concept without Uri and with unique PrefLabel.
print "\n\n test07 ... \n";
$client = Authenticator::authenticate();
$randomn = rand(0, 4092);
$prefLabel = 'testPrefLable_' . $randomn;
$dateSubmitted = date(DateTime::ISO8601);
$xml = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:dcterms="http://purl.org/dc/terms/" > ' . '<rdf:Description>' . '<rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>' . '<dcterms:creator>Test</dcterms:creator>' . '<skos:prefLabel xml:lang="nl">' . $prefLabel . '</skos:prefLabel>' . '<dcterms:dateSubmitted>' . $dateSubmitted . '</dcterms:dateSubmitted>' . '<skos:inScheme rdf:resource="http://data.beeldengeluid.nl/gtaa/GeografischeNamen"/>' . '</rdf:Description>' . '</rdf:RDF>';
$client->setUri(BASE_URI_ . "/public/api/concept?");
$client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
$response = $client->setEncType('text/xml')->setRawData($xml)->setParameterGet('tenant', TENANT)->setParameterGet('collection', COLLECTION_1_code)->setParameterGet('key', API_KEY)->setParameterGet('autoGenerateIdentifiers', 'true')->request('POST');
if ($response->isSuccessful()) {
print "\n Concept created \n";
var_dump($response->getBody());
} else {
print "\n Failed to create concept: " . $response->getHeader('X-Error-Msg');
}
$this->AssertEquals(201, $response->getStatus());
print "\n HTTPResponseHeader-Location: " . $response->getHeader('Location');
$namespaces = array("rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "skos" => "http://www.w3.org/2004/02/skos/core#", "openskos" => "http://openskos.org/xmlns/openskos.xsd");
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($response->getBody());
$dom->registerXpathNamespaces($namespaces);
$elem = $dom->queryXpath('/rdf:RDF');
$this->assertEquals($elem->current()->nodeType, XML_ELEMENT_NODE, 'The root node of the response is not an element');
$resURI = $dom->queryXpath('/rdf:RDF/rdf:Description')->current()->getAttribute("rdf:about");
$this->assertNotEquals("", $resURI, "No valid uri for SKOS concept");
$status = $dom->queryXpath('/rdf:RDF/rdf:Description/openskos:status');
$this->assertEquals(1, $status->count(), "No valid uri for SKOS concept");
print "\n New concept is created with URI {$resURI} and status" . $status->current()->nodeValue;
}
示例11: assertionsXMLRDFCollections
private function assertionsXMLRDFCollections($response)
{
$dom = new Zend_Dom_Query();
$dom->setDocumentXML($response->getBody());
$results1 = $dom->query('rdf:Description');
$this->assertEquals(NUMBER_COLLECTIONS, count($results1));
for ($i = 0; $i < NUMBER_COLLECTIONS; $i++) {
$this->assertionsXMLRDFCollection($dom, $i);
}
}