Semantic MediaWiki and related extensions
|
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 | |
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+
SMW\Exporter\Serializer\Serializer::__construct | ( | ) |
SMW\Exporter\Serializer\Serializer::clear | ( | ) |
Clear internal states to start a new serialization.
|
protected |
Update the declaration "todo" and "done" lists to reflect the fact that the given element has been declared to has the given type.
ExpResource | $element | specifying the element to update |
$typeflag | integer specifying the type (e.g. SMW_SERIALIZER_DECL_CLASS) |
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.
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).
|
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.
ExpNsResource | $property |
|
protected |
Update the declaration "todo" and "done" lists for the case that the given data has been serialized with the type information it provides.
ExpData | $expData |
|
protected |
State that a certain declaration is needed. The method checks if the declaration is already available, and records a todo otherwise.
|
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.
|
abstract |
Serialize a single declaration for the given $uri (expanded) and type (given as a QName).
$uri | string URI of the thing to declare |
$typename | string one of owl:Class, owl:ObjectProperty, and owl:datatypeProperty |
SMW\Exporter\Serializer\Serializer::serializeDeclarations | ( | ) |
Serialize any declarations that have been found to be missing while serializing other elements.
|
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()).
$data | ExpData containing the data to be serialised. |
|
abstractprotected |
Serialise the footer (i.e. write it to the internal buffer).
|
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.
|
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.
$shortname | string abbreviation/prefix to declare |
$uri | string URI prefix that the namespace encodes |
|
protected |
Include collected namespace information into the serialization.
SMW\Exporter\Serializer\Serializer::startSerialization | ( | ) |
Start a new serialization, resetting all internal data and serializing necessary header elements.