SMWExporter Class Reference
[Semantic MediaWiki]

SMWExporter is a class for converting internal page-based data (SMWSemanticData) into a format for easy serialisation in OWL or RDF. More...

List of all members.

Static Public Member Functions

static initBaseURIs ()
 Make sure that necessary base URIs are initialised properly.
static makeExportData (SMWSemanticData $semdata)
 Create exportable data from a given semantic data record.
static makeExportDataForSubject (SMWDIWikiPage $diWikiPage, $typesvalueforproperty=null, $addStubData=false)
 Make an SMWExpData object for the given page, and include the basic properties about this subject that are not directly represented by SMW property values.
static addPropertyValues (SMWDIProperty $property, array $dataItems, SMWExpData &$expData)
 Extend a given SMWExpData element by adding export data for the specified property data itme.
static getResourceElementForProperty (SMWDIProperty $diProperty, $helperProperty=false)
 Create an SMWExpElement for some internal resource, given by an SMWDIProperty object.
static getResourceElementForWikiPage (SMWDIWikiPage $diWikiPage, $modifier= '')
 Create an SMWExpElement for some internal resource, given by an SMWDIWikiPage object.
static findDataItemForExpElement (SMWExpElement $expElement)
 Try to find an SMWDataItem that the given SMWExpElement might represent.
static getOWLPropertyType ($type= '')
 Determine what kind of OWL property some SMW property should be exported as.
static getSpecialPropertyResource ($propertyKey, $forNamespace=NS_MAIN)
 Get an SMWExpNsResource for a special property of SMW, or null if no resource is assigned to the given property key.
static getSpecialNsResource ($namespaceId, $localName)
 Create an SMWExpNsResource for some special element that belongs to a known vocabulary.
static encodeURI ($uri)
 This function escapes symbols that might be problematic in XML in a uniform and injective way.
static decodeURI ($uri)
 This function unescapes URIs generated with SMWExporter::encodeURI.
static expandURI ($uri)
 This function expands standard XML entities used in some generated URIs.
static getNamespaceUri ($shortName)
 Get the URI of a standard namespace prefix used in SMW, or the empty string if the prefix is not known.
static getOntologyExpData ($ontologyuri)
 Create an SMWExpData container that encodes the ontology header for an SMW exported OWL file.
static getDataItemExpElement (SMWDataItem $dataItem)
 Create an SWMExpElement that encodes the data of the given dataitem object.
static getDataItemHelperExpElement (SMWDataItem $dataItem)
 Create an SWMExpElement that encodes auxiliary data for representing values of the specified dataitem object in a simplified fashion.
static hasHelperExpElement ($dataItemType)
 Check whether the values of a given type of dataitem have helper values in the sense of SMWExporter::getDataItemHelperExpElement().

Static Protected Attributes

static $m_exporturl = false
static $m_ent_wiki = false
static $m_ent_property = false
static $m_ent_wikiurl = false


Detailed Description

SMWExporter is a class for converting internal page-based data (SMWSemanticData) into a format for easy serialisation in OWL or RDF.

Author:
Markus Krötzsch

Definition at line 14 of file SMW_Exporter.php.


Member Function Documentation

static SMWExporter::initBaseURIs (  )  [static]

Make sure that necessary base URIs are initialised properly.

Definition at line 23 of file SMW_Exporter.php.

References $wgServer.

static SMWExporter::makeExportData ( SMWSemanticData semdata  )  [static]

Create exportable data from a given semantic data record.

Parameters:
$semdata SMWSemanticData
Returns:
SMWExpData

Definition at line 50 of file SMW_Exporter.php.

References SMWSemanticData::getPropertyValues(), and SMWSemanticData::getSubject().

Referenced by SMWSparqlStore::prepareUpdateExpData(), and SMWExportController::serializePage().

static SMWExporter::makeExportDataForSubject ( SMWDIWikiPage diWikiPage,
typesvalueforproperty = null,
addStubData = false 
) [static]

Make an SMWExpData object for the given page, and include the basic properties about this subject that are not directly represented by SMW property values.

The optional parameter $typevalueforproperty can be used to pass a particular SMWTypesValue object that is used for determining the OWL type for property pages.

Todo:
Take into account whether the wiki page belongs to a builtin property, and ensure URI alignment/type declaration in this case.
Parameters:
$diWikiPage SMWDIWikiPage
$typesvalueforproperty mixed either an SMWTypesValue or null
$addStubData boolean to indicate if additional data should be added to make a stub entry for this page
Returns:
SMWExpData

Definition at line 79 of file SMW_Exporter.php.

References SMWDIWikiPage::getDBkey(), SMWDIWikiPage::getSubobjectName(), and smwfGetStore().

Referenced by SMWSparqlStore::expandUpdateExpResource(), and SMWRDFResultPrinter::getResultText().

static SMWExporter::addPropertyValues ( SMWDIProperty property,
array $  dataItems,
SMWExpData &$  expData 
) [static]

Extend a given SMWExpData element by adding export data for the specified property data itme.

This method is called when constructing export data structures from SMWSemanticData objects.

Parameters:
$property SMWDIProperty
$dataItems array of SMWDataItem objects for the given property
$data SMWExpData to add the data to

TODO: currently no full check for avoiding OWL DL illegal redirects is done (OWL property type ignored)

Definition at line 153 of file SMW_Exporter.php.

References SMWExpData::addPropertyObjectValue(), SMWDIProperty::getKey(), SMWExpData::getSubject(), and SMWDataItem::TYPE_WIKIPAGE.

Referenced by SMWRDFResultPrinter::getResultText().

static SMWExporter::getResourceElementForProperty ( SMWDIProperty diProperty,
helperProperty = false 
) [static]

Create an SMWExpElement for some internal resource, given by an SMWDIProperty object.

This code is only applied to user-defined properties, since the code for special properties in SMWExporter::getSpecialPropertyResource() may require information about the namespace in which some special property is used.

Parameters:
$diProperty SMWDIProperty
$helperProperty boolean determines if an auxiliary property resource to store a helper value (see SMWExporter::getDataItemHelperExpElement()) should be generated
Returns:
SMWExpResource

Definition at line 235 of file SMW_Exporter.php.

References SMWDIProperty::getDiWikiPage().

Referenced by SMWSparqlStoreQueryEngine::buildPropertyCondition().

static SMWExporter::getResourceElementForWikiPage ( SMWDIWikiPage diWikiPage,
modifier = '' 
) [static]

Create an SMWExpElement for some internal resource, given by an SMWDIWikiPage object.

This is the one place in the code where URIs of wiki pages and user-defined properties are determined. A modifier can be given to make variants of a URI, typically done for auxiliary properties. In this case, the URI is modiied by appending "-23$modifier" where "-23" is the URI encoding of "#" (a symbol not occuring in MW titles).

Parameters:
$diWikiPage SMWDIWikiPage or SMWDIProperty
$modifier string, using only Latin letters and numbers
Returns:
SMWExpResource

Definition at line 259 of file SMW_Exporter.php.

References SMWDIWikiPage::getDBkey(), SMWDIWikiPage::getSubobjectName(), SMWDataValueFactory::newDataItemValue(), and smwfGetStore().

Referenced by SMWSparqlStoreQueryEngine::buildClassCondition().

static SMWExporter::findDataItemForExpElement ( SMWExpElement expElement  )  [static]

Try to find an SMWDataItem that the given SMWExpElement might represent.

Returns null if this attempt failed.

Parameters:
SMWExpElement $expElement
Returns:
SMWDataItem or null

Definition at line 320 of file SMW_Exporter.php.

Referenced by SMWSparqlStoreQueryEngine::getQueryResultFromSparqlResult().

static SMWExporter::getOWLPropertyType ( type = ''  )  [static]

Determine what kind of OWL property some SMW property should be exported as.

The input is an SMWTypesValue object, a typeid string, or empty (use default)

Todo:
An improved mechanism for selecting property types here is needed.

Definition at line 374 of file SMW_Exporter.php.

References SMWDataValueFactory::findTypeID().

Referenced by SMWConceptValue::descriptionToExpData().

static SMWExporter::getSpecialPropertyResource ( propertyKey,
forNamespace = NS_MAIN 
) [static]

Get an SMWExpNsResource for a special property of SMW, or null if no resource is assigned to the given property key.

The optional namespace is used to select the proper resource for properties that must take the type of the annotated object into account for some reason.

Parameters:
$propertyKey string the Id of the special property
$forNamespace integer the namespace of the page which has a value for this property
Returns:
SMWExpNsResource or null

Definition at line 401 of file SMW_Exporter.php.

Referenced by SMWSparqlStoreQueryEngine::addOrderByData(), SMWSparqlStoreQueryEngine::buildClassCondition(), and SMWSparqlStore::getSparqlRedirectTarget().

static SMWExporter::getSpecialNsResource ( namespaceId,
localName 
) [static]

Create an SMWExpNsResource for some special element that belongs to a known vocabulary.

An exception is generated when given parameters that do not fit any known vocabulary.

Parameters:
$namespaceId string (e.g. "rdf")
$localName string (e.g. "type")
Returns:
SMWExpNsResource

Definition at line 452 of file SMW_Exporter.php.

Referenced by SMWSparqlStoreQueryEngine::buildNamespaceCondition(), SMWSparqlStore::deleteSparqlData(), SMWConceptValue::descriptionToExpData(), SMWExpData::extractMainType(), SMWExpData::getCollection(), SMWConceptValue::getExportData(), SMWSparqlStoreQueryEngine::getSparqlConditionString(), SMWExpData::getSpecialValues(), SMWExpData::makeCollection(), SMWExportController::printPageList(), and SMWExportController::printWikiInfo().

static SMWExporter::encodeURI ( uri  )  [static]

This function escapes symbols that might be problematic in XML in a uniform and injective way.

It is used to encode URIs.

Definition at line 465 of file SMW_Exporter.php.

static SMWExporter::decodeURI ( uri  )  [static]

This function unescapes URIs generated with SMWExporter::encodeURI.

This allows services that receive a URI to extract e.g. the according wiki page.

Definition at line 478 of file SMW_Exporter.php.

Referenced by SMWURIResolver::execute().

static SMWExporter::expandURI ( uri  )  [static]

This function expands standard XML entities used in some generated URIs.

Given a string with such entities, it returns a string with all entities properly replaced.

Note:
The function SMWExporter::getNamespaceUri() is often more suitable. This XML-specific method might become obsolete.
Parameters:
$uri string of the URI to be expanded
Returns:
string of the expanded URI

Definition at line 497 of file SMW_Exporter.php.

Referenced by SMWTurtleSerializer::getTurtleNameForExpElement(), SMWInfolink::getURL(), SMWExportController::printPageList(), SMWExportController::printPages(), SMWExportController::printWikiInfo(), SMWTurtleSerializer::serializeDeclaration(), SMWTurtleSerializer::serializeHeader(), and SMWRDFXMLSerializer::serializeHeader().

static SMWExporter::getNamespaceUri ( shortName  )  [static]

Get the URI of a standard namespace prefix used in SMW, or the empty string if the prefix is not known.

Parameters:
$shortName string id (prefix) of the namespace
Returns:
string of the expanded URI

Definition at line 513 of file SMW_Exporter.php.

Referenced by SMWSparqlDatabase::getPrefixString(), and SMWSparqlStore::getSparqlRedirectTarget().

static SMWExporter::getOntologyExpData ( ontologyuri  )  [static]

Create an SMWExpData container that encodes the ontology header for an SMW exported OWL file.

Parameters:
string $ontologyuri specifying the URI of the ontology, possibly empty

Definition at line 536 of file SMW_Exporter.php.

Referenced by SMWRDFResultPrinter::getResultText(), SMWExportController::printAll(), SMWExportController::printPageList(), SMWExportController::printPages(), and SMWExportController::printWikiInfo().

static SMWExporter::getDataItemExpElement ( SMWDataItem dataItem  )  [static]

static SMWExporter::getDataItemHelperExpElement ( SMWDataItem dataItem  )  [static]

Create an SWMExpElement that encodes auxiliary data for representing values of the specified dataitem object in a simplified fashion.

This is done for types of dataitems that are not supported very well in current systems, or that do not match a standard datatype in RDF. For example, time points (DITime) are encoded as numbers. The number can replace the actual time for all query and ordering purposes (the order in either case is linear and maps to the real number line). Only data retrieval should better use the real values to avoid that rounding errors lead to unfaithful recovery of data. Note that the helper values do not maintain any association with their original values -- they are a fully redundant alternative representation, not an additional piece of information for the main values. Even if decoding is difficult, they must be in one-to-one correspondence to the original value.

For dataitems that do not have such a simplification, the method returns null.

Note:
If a helper element is used, then it must be the same as getDataItemHelperExpElement( $dataItem->getSortKeyDataItem() ). Query conditions like ">" use sortkeys for values, and helper elements are always preferred in query answering.
Parameters:
$dataItem SMWDataItem
Returns:
SMWExpElement or null

Definition at line 640 of file SMW_Exporter.php.

References SMWDataItem::TYPE_TIME.

Referenced by SMWSparqlStoreQueryEngine::buildValueCondition().

static SMWExporter::hasHelperExpElement ( dataItemType  )  [static]

Check whether the values of a given type of dataitem have helper values in the sense of SMWExporter::getDataItemHelperExpElement().

Parameters:
$dataItemType integer type ID of dataitem (see SMWDataItem)
Returns:
boolean

Definition at line 656 of file SMW_Exporter.php.

References SMWDataItem::TYPE_TIME.

Referenced by SMWSparqlStoreQueryEngine::buildPropertyCondition().


Member Data Documentation

SMWExporter::$m_exporturl = false [static, protected]

Definition at line 15 of file SMW_Exporter.php.

SMWExporter::$m_ent_wiki = false [static, protected]

Definition at line 16 of file SMW_Exporter.php.

SMWExporter::$m_ent_property = false [static, protected]

Definition at line 17 of file SMW_Exporter.php.

SMWExporter::$m_ent_wikiurl = false [static, protected]

Definition at line 18 of file SMW_Exporter.php.


The documentation for this class was generated from the following file:

Generated on Sun Mar 18 07:15:43 2012 for Semantic MediaWiki by  doxygen 1.5.6