本文整理汇总了PHP中SMWExporter::getNamespaceUri方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWExporter::getNamespaceUri方法的具体用法?PHP SMWExporter::getNamespaceUri怎么用?PHP SMWExporter::getNamespaceUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWExporter
的用法示例。
在下文中一共展示了SMWExporter::getNamespaceUri方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBuildTriplesForEmptySemanticDataContainer
public function testBuildTriplesForEmptySemanticDataContainer()
{
$expNsResource = new ExpNsResource('Redirect', Exporter::getNamespaceUri('wiki'), 'Redirect');
$semanticData = new SemanticData(new DIWikiPage('Foo', NS_MAIN, ''));
$redirectLookup = $this->getMockBuilder('\\SMW\\SPARQLStore\\RedirectLookup')->disableOriginalConstructor()->getMock();
$redirectLookup->expects($this->atLeastOnce())->method('findRedirectTargetResource')->will($this->returnValue($expNsResource));
$instance = new TurtleTriplesBuilder($semanticData, $redirectLookup);
$this->assertTrue($instance->doBuild()->hasTriplesForUpdate());
$this->assertInternalType('string', $instance->getTriples());
$this->assertInternalType('array', $instance->getPrefixes());
}
示例2: getPrefixString
/**
* Create the standard PREFIX declarations for SPARQL or Turtle,
* possibly with additional namespaces involved.
*
* @param $extraNamespaces array (associative) of namespaceId => namespaceUri
* @param $forSparql boolean true to use SPARQL prefix syntax, false to use Turtle prefix syntax
*/
public static function getPrefixString( $extraNamespaces = array(), $forSparql = true ) {
$prefixString = '';
$prefixIntro = $forSparql ? 'PREFIX ' : '@prefix ';
$prefixOutro = $forSparql ? "\n" : " .\n";
foreach ( array( 'wiki', 'rdf', 'rdfs', 'owl', 'swivt', 'property', 'xsd' ) as $shortname ) {
$prefixString .= "{$prefixIntro}{$shortname}: <" . SMWExporter::getNamespaceUri( $shortname ) . ">$prefixOutro";
unset( $extraNamespaces[$shortname] ); // avoid double declaration
}
foreach ( $extraNamespaces as $shortname => $uri ) {
$prefixString .= "{$prefixIntro}{$shortname}: <$uri>$prefixOutro";
}
return $prefixString;
}
示例3: getSparqlRedirectTarget
/**
* Find the redirect target of an SMWExpNsResource.
* Returns an SMWExpNsResource object the input redirects to,
* the input itself if there is no redirect (or it cannot be
* used for making a resource with a prefix).
*
* @since 1.6
* @param $expNsResource string URI to check
* @param $exists boolean that is set to true if $expNsResource is in the
* store; always false for blank nodes; always true for subobjects
* @return SMWExpNsResource
*/
protected function getSparqlRedirectTarget(SMWExpNsResource $expNsResource, &$exists)
{
if ($expNsResource->isBlankNode()) {
$exists = false;
return $expNsResource;
} elseif ($expNsResource->getDataItem() instanceof SMWDIWikiPage && $expNsResource->getDataItem()->getSubobjectName() !== '') {
$exists = true;
return $expNsResource;
}
$resourceUri = SMWTurtleSerializer::getTurtleNameForExpElement($expNsResource);
$rediUri = SMWTurtleSerializer::getTurtleNameForExpElement(SMWExporter::getSpecialPropertyResource('_REDI'));
$skeyUri = SMWTurtleSerializer::getTurtleNameForExpElement(SMWExporter::getSpecialPropertyResource('_SKEY'));
$sparqlResult = smwfGetSparqlDatabase()->select('*', "{$resourceUri} {$skeyUri} ?s OPTIONAL { {$resourceUri} {$rediUri} ?r }", array('LIMIT' => 1), array($expNsResource->getNamespaceId() => $expNsResource->getNamespace()));
$firstRow = $sparqlResult->current();
if ($firstRow === false) {
$exists = false;
return $expNsResource;
} elseif (count($firstRow) > 1 && !is_null($firstRow[1])) {
$exists = true;
$rediTargetElement = $firstRow[1];
$rediTargetUri = $rediTargetElement->getUri();
$wikiNamespace = SMWExporter::getNamespaceUri('wiki');
if (strpos($rediTargetUri, $wikiNamespace) === 0) {
return new SMWExpNsResource(substr($rediTargetUri, 0, strlen($wikiNamespace)), $wikiNamespace, 'wiki');
} else {
return $expNsResource;
}
} else {
$exists = true;
return $expNsResource;
}
}
示例4: resourceProvider
public function resourceProvider()
{
$provider[] = array(Exporter::getSpecialNsResource('rdf', 'type'));
$provider[] = array(new ExpNsResource('FooRedirectLookup', Exporter::getNamespaceUri('property'), 'property', new DIWikiPage('FooRedirectLookup', SMW_NS_PROPERTY, '')));
return $provider;
}
示例5: getResourceForTargetElement
private function getResourceForTargetElement(ExpNsResource $expNsResource, $rediTargetElement)
{
if (!$rediTargetElement instanceof ExpResource) {
throw new RuntimeException('Expected a ExpResource instance');
}
$rediTargetUri = $rediTargetElement->getUri();
$wikiNamespace = Exporter::getNamespaceUri('wiki');
if (strpos($rediTargetUri, $wikiNamespace) === 0) {
return new ExpNsResource(substr($rediTargetUri, strlen($wikiNamespace)), $wikiNamespace, 'wiki');
}
return $expNsResource;
}
示例6: testExportSubobject
public function testExportSubobject()
{
$semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
$subobject = new Subobject($semanticData->getSubject()->getTitle());
$subobject->setEmptyContainerForId('Foo');
$semanticData->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer());
$exportData = Exporter::makeExportData($semanticData);
$expectedProperty = new ExpNsResource($this->transformPropertyLabelToAuxiliary($subobject->getProperty()), Exporter::getNamespaceUri('property'), 'property', new DIWikiPage('Has_subobject', SMW_NS_PROPERTY));
$this->assertTrue(Exporter::hasHelperExpElement($subobject->getProperty()));
$this->assertCount(1, $exportData->getValues($expectedProperty));
$this->exportDataValidator->assertThatExportDataContainsProperty($expectedProperty, $exportData);
$expectedResource = new ExpNsResource(Exporter::getEncodedPageName($subobject->getSemanticData()->getSubject()) . '-23' . 'Foo', Exporter::getNamespaceUri('wiki'), 'wiki', $subobject->getSemanticData()->getSubject());
$this->exportDataValidator->assertThatExportDataContainsResource($expectedResource, $expectedProperty, $exportData);
}
示例7: testFindDataItemForExpElement
/**
* @dataProvider uriDataItemProvider
* #378
*/
public function testFindDataItemForExpElement($uri, $expectedDataItem)
{
$uri = Exporter::getNamespaceUri('wiki') . $uri;
$this->assertEquals($expectedDataItem, Exporter::findDataItemForExpElement(new ExpResource($uri)));
}
示例8: testRedirectTragetForDBLookupWithMultipleEntriesForcesNewResource
public function testRedirectTragetForDBLookupWithMultipleEntriesForcesNewResource()
{
$propertyPage = new DIWikiPage('Foo', SMW_NS_PROPERTY);
$resource = new ExpNsResource('Foo', Exporter::getNamespaceUri('property'), 'property', $propertyPage);
$sparqlDatabase = $this->createMockSparqlDatabaseFor(array($resource, $resource));
$instance = new RedirectLookup($sparqlDatabase);
$instance->clear();
$dataItem = new DIWikiPage('Foo', 1, '', '');
$expNsResource = new ExpNsResource('Foo', 'Bar', '', $dataItem);
$exists = null;
$targetResource = $instance->findRedirectTargetResource($expNsResource, $exists);
$this->assertNotSame($expNsResource, $targetResource);
$expectedResource = new ExpNsResource(Exporter::getInstance()->getEncodedPageName($propertyPage), Exporter::getNamespaceUri('wiki'), 'wiki');
$this->assertEquals($expectedResource, $targetResource);
$this->assertTrue($exists);
}