SMWSerializer Class Reference
[Semantic MediaWiki]

Abstract class for serializing exported data (encoded as SMWExpData object) in a concrete syntactic format such as Turtle or RDF/XML. More...

Inherited by SMWRDFXMLSerializer, and SMWTurtleSerializer.

List of all members.

Public Member Functions

 __construct ()
 Constructor.
 clear ()
 Clear internal states to start a new serialization.
 startSerialization ()
 Start a new serialization, resetting all internal data and serializing necessary header elements.
 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.
 serializeDeclarations ()
 Serialize any declarations that have been found to be missing while serializing other elements.
 serializeDeclaration ($uri, $typename)
 Serialize a single declaration for the given $uri (expanded) and type (given as a QName).
 serializeExpData (SMWExpData $data)
 Serialise the given SMWExpData object.
 flushContent ()
 Get the string that has been serialized so far.

Protected Member Functions

 serializeHeader ()
 Serialize the header (i.e.
 serializeFooter ()
 Serialise the footer (i.e.
 serializeNamespaces ()
 Include collected namespace information into the serialization.
 serializeNamespace ($shortname, $uri)
 Serialize a single namespace.
 requireNamespace ($nsshort, $nsuri)
 Require an additional namespace to be declared in the serialization.
 requireDeclaration (SMWExpResource $resource, $decltype)
 State that a certain declaration is needed.
 recordDeclarationTypes (SMWExpData $expData)
 Update the declaration "todo" and "done" lists for the case that the given data has been serialized with the type information it provides.
 declarationDone (SMWExpResource $element, $typeflag)
 Update the declaration "todo" and "done" lists to reflect the fact that the given element has been declared to has the given type.
 isOWLClassTypeProperty (SMWExpNsResource $property)
 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.

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 SMWExpData 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.

Definition at line 36 of file SMW_Serializer.php.


Constructor & Destructor Documentation

SMWSerializer::__construct (  ) 

Constructor.

Definition at line 89 of file SMW_Serializer.php.

References clear().


Member Function Documentation

SMWSerializer::clear (  ) 

Clear internal states to start a new serialization.

Reimplemented in SMWRDFXMLSerializer, and SMWTurtleSerializer.

Definition at line 96 of file SMW_Serializer.php.

Referenced by __construct(), and startSerialization().

SMWSerializer::startSerialization (  ) 

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

Definition at line 109 of file SMW_Serializer.php.

References clear(), and serializeHeader().

SMWSerializer::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.

Definition at line 120 of file SMW_Serializer.php.

References serializeDeclarations(), and serializeFooter().

SMWSerializer::serializeHeader (  )  [abstract, protected]

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.

Reimplemented in SMWRDFXMLSerializer, and SMWTurtleSerializer.

Referenced by startSerialization().

SMWSerializer::serializeFooter (  )  [abstract, protected]

Serialise the footer (i.e.

write it to the internal buffer).

Reimplemented in SMWRDFXMLSerializer, and SMWTurtleSerializer.

Referenced by finishSerialization().

SMWSerializer::serializeDeclarations (  ) 

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

Definition at line 141 of file SMW_Serializer.php.

References serializeDeclaration().

Referenced by finishSerialization().

SMWSerializer::serializeDeclaration ( uri,
typename 
) [abstract]

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

Parameters:
$uri string URI of the thing to declare
$typename string one of owl:Class, owl:ObjectProperty, and owl:datatypeProperty

Reimplemented in SMWRDFXMLSerializer, and SMWTurtleSerializer.

Referenced by serializeDeclarations().

SMWSerializer::serializeExpData ( SMWExpData data  )  [abstract]

Serialise the given SMWExpData 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:
$data SMWExpData containing the data to be serialised.

Reimplemented in SMWRDFXMLSerializer, and SMWTurtleSerializer.

SMWSerializer::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).

Reimplemented in SMWRDFXMLSerializer.

Definition at line 180 of file SMW_Serializer.php.

References serializeNamespaces().

SMWSerializer::serializeNamespaces (  )  [protected]

Include collected namespace information into the serialization.

Definition at line 192 of file SMW_Serializer.php.

References serializeNamespace().

Referenced by flushContent(), SMWTurtleSerializer::serializeExpData(), and SMWRDFXMLSerializer::serializeExpData().

SMWSerializer::serializeNamespace ( shortname,
uri 
) [abstract, protected]

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:
$shortname string abbreviation/prefix to declare
$uri string URI prefix that the namespace encodes

Reimplemented in SMWRDFXMLSerializer, and SMWTurtleSerializer.

Referenced by serializeNamespaces().

SMWSerializer::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.

Definition at line 214 of file SMW_Serializer.php.

Referenced by SMWTurtleSerializer::serializeExpResource(), and SMWRDFXMLSerializer::serializeNestedExpData().

SMWSerializer::requireDeclaration ( SMWExpResource resource,
decltype 
) [protected]

State that a certain declaration is needed.

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

Definition at line 224 of file SMW_Serializer.php.

References SMWExpResource::getUri().

Referenced by SMWRDFXMLSerializer::serializeExpResource(), SMWTurtleSerializer::serializeNestedExpData(), and SMWRDFXMLSerializer::serializeNestedExpData().

SMWSerializer::recordDeclarationTypes ( SMWExpData 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 specifying the type data upon which declarations are based

Definition at line 252 of file SMW_Serializer.php.

References declarationDone().

Referenced by SMWTurtleSerializer::serializeNestedExpData(), and SMWRDFXMLSerializer::serializeNestedExpData().

SMWSerializer::declarationDone ( SMWExpResource element,
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:
$element SMWExpResource specifying the element to update
$typeflag integer specifying the type (e.g. SMW_SERIALIZER_DECL_CLASS)

Definition at line 275 of file SMW_Serializer.php.

References SMWExpResource::getUri().

Referenced by recordDeclarationTypes().

SMWSerializer::isOWLClassTypeProperty ( SMWExpNsResource 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:
SMWExpNsResource $property

Definition at line 302 of file SMW_Serializer.php.

References SMWExpNsResource::getLocalName().

Referenced by SMWTurtleSerializer::serializeNestedExpData(), and SMWRDFXMLSerializer::serializeNestedExpData().


Member Data Documentation

SMWSerializer::$pre_ns_buffer [protected]

Definition at line 45 of file SMW_Serializer.php.

SMWSerializer::$post_ns_buffer [protected]

Definition at line 50 of file SMW_Serializer.php.

SMWSerializer::$decl_todo [protected]

Definition at line 58 of file SMW_Serializer.php.

SMWSerializer::$decl_done [protected]

Definition at line 66 of file SMW_Serializer.php.

SMWSerializer::$extra_namespaces [protected]

Definition at line 77 of file SMW_Serializer.php.

SMWSerializer::$global_namespaces [protected]

Definition at line 84 of file SMW_Serializer.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