Semantic MediaWiki and related extensions
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SMW\Exporter\Serializer\Serializer Class Reference
Inheritance diagram for SMW\Exporter\Serializer\Serializer:
Inheritance graph
[legend]

Public Member Functions

 __construct ()
 
 clear ()
 
 startSerialization ()
 
 finishSerialization ()
 
 serializeDeclarations ()
 
 serializeDeclaration ( $uri, $typename)
 
 serializeExpData (ExpData $data)
 
 flushContent ()
 

Protected Member Functions

 serializeHeader ()
 
 serializeFooter ()
 
 serializeNamespaces ()
 
 serializeNamespace ( $shortname, $uri)
 
 requireNamespace ( $nsshort, $nsuri)
 
 requireDeclaration (ExpResource $resource, $decltype)
 
 recordDeclarationTypes (ExpData $expData)
 
 declarationDone (ExpResource $element, int $typeflag)
 
 isOWLClassTypeProperty (ExpNsResource $property)
 

Protected Attributes

 $pre_ns_buffer
 
 $post_ns_buffer
 
 $decl_todo
 
 $decl_done
 
 $extra_namespaces
 
 $global_namespaces
 

Detailed Description

Abstract class for serializing exported data (encoded as ExpData object) in a concrete syntactic format such as Turtle or RDF/XML. The serializer adds object serialisations to an internal string that can be retrieved for pushing it to an output. This abstract class does not define this string as implementations may want to use their own scheme (e.g. using two buffers as in the case of SMWRDFXMLSerializer). The function flushContent() returns the string serialized so far so as to enable incremental serialization.

RDF and OWL have two types of dependencies that are managed by this class: namespaces (and similar abbreviation schemes) and element declarations. The former need to be defined before being used, while the latter can occur at some later point in the serialization. Declarations are relevant to the OWL data model, being one of Class, DatatypeProperty, and ObjectProperty (only the latter two are mutually exclusive). This class determines the required declaration from the context in which an element is used.

GNU GPL v2+

Since
1.5.5
Author
Markus Krötzsch

Constructor & Destructor Documentation

◆ __construct()

SMW\Exporter\Serializer\Serializer::__construct ( )
Since
1.5.5

Member Function Documentation

◆ clear()

SMW\Exporter\Serializer\Serializer::clear ( )

Clear internal states to start a new serialization.

◆ declarationDone()

SMW\Exporter\Serializer\Serializer::declarationDone ( ExpResource  $element,
int  $typeflag 
)
protected

Update the declaration "todo" and "done" lists to reflect the fact that the given element has been declared to has the given type.

Parameters
ExpResource$elementspecifying the element to update
$typeflaginteger specifying the type (e.g. SMW_SERIALIZER_DECL_CLASS)

◆ finishSerialization()

SMW\Exporter\Serializer\Serializer::finishSerialization ( )

Complete the serialization so that calling flushContent() will return the final part of the output, leading to a complete serialization with all necessary declarations. No further serialization functions must be called after this.

◆ flushContent()

SMW\Exporter\Serializer\Serializer::flushContent ( )

Get the string that has been serialized so far. This function also resets the internal buffers for serilized strings and namespaces (what is flushed is gone).

Returns
string

◆ isOWLClassTypeProperty()

SMW\Exporter\Serializer\Serializer::isOWLClassTypeProperty ( ExpNsResource  $property)
protected

Check if the given property is one of the special properties of the OWL language that require their values to be classes or RDF lists of classes. In these cases, it is necessary to declare this in the exported data.

Note
The list of properties checked here is not complete for the OWL language but covers what is used in SMW.
OWL 2 allows URIs to refer to both classes and individual elements in different contexts. We only need declarations for classes that are used as such, hence it is enough to check the property. Moreover, we do not use OWL Datatypes in SMW, so rdf:type, rdfs:domain, etc. always refer to classes.
Parameters
ExpNsResource$property
Returns
boolean

◆ recordDeclarationTypes()

SMW\Exporter\Serializer\Serializer::recordDeclarationTypes ( ExpData  $expData)
protected

Update the declaration "todo" and "done" lists for the case that the given data has been serialized with the type information it provides.

Parameters
ExpData$expData

◆ requireDeclaration()

SMW\Exporter\Serializer\Serializer::requireDeclaration ( ExpResource  $resource,
  $decltype 
)
protected

State that a certain declaration is needed. The method checks if the declaration is already available, and records a todo otherwise.

◆ requireNamespace()

SMW\Exporter\Serializer\Serializer::requireNamespace (   $nsshort,
  $nsuri 
)
protected

Require an additional namespace to be declared in the serialization. The function checks whether the required namespace is available globally and add it to the list of required namespaces otherwise.

◆ serializeDeclaration()

SMW\Exporter\Serializer\Serializer::serializeDeclaration (   $uri,
  $typename 
)
abstract

Serialize a single declaration for the given $uri (expanded) and type (given as a QName).

Parameters
$uristring URI of the thing to declare
$typenamestring one of owl:Class, owl:ObjectProperty, and owl:datatypeProperty

◆ serializeDeclarations()

SMW\Exporter\Serializer\Serializer::serializeDeclarations ( )

Serialize any declarations that have been found to be missing while serializing other elements.

◆ serializeExpData()

SMW\Exporter\Serializer\Serializer::serializeExpData ( ExpData  $data)
abstract

Serialise the given ExpData object. The method must not assume that the exported data refers to wiki pages or other SMW data, and it must ensure that all required auxiliary declarations for obtaining proper OWL are included in any case (this can be done using requireDeclaration()).

Parameters
$dataExpData containing the data to be serialised.

◆ serializeFooter()

SMW\Exporter\Serializer\Serializer::serializeFooter ( )
abstractprotected

Serialise the footer (i.e. write it to the internal buffer).

◆ serializeHeader()

SMW\Exporter\Serializer\Serializer::serializeHeader ( )
abstractprotected

Serialize the header (i.e. write it to the internal buffer). May include standard syntax to start output but also declare some common namespaces globally.

◆ serializeNamespace()

SMW\Exporter\Serializer\Serializer::serializeNamespace (   $shortname,
  $uri 
)
abstractprotected

Serialize a single namespace. Namespaces that were serialized in such a way that they remain available for all following output should be added to $global_namespaces.

Parameters
$shortnamestring abbreviation/prefix to declare
$uristring URI prefix that the namespace encodes

◆ serializeNamespaces()

SMW\Exporter\Serializer\Serializer::serializeNamespaces ( )
protected

Include collected namespace information into the serialization.

◆ startSerialization()

SMW\Exporter\Serializer\Serializer::startSerialization ( )

Start a new serialization, resetting all internal data and serializing necessary header elements.


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

About | General disclaimer | Privacy policy