RdfXmlSerializer
in package
implements
SerializerInterface
uses
TmpStreamSerializerTrait
Simple RDF-XML serializer. It is optimized for speed and low memory footprint.
This means it doesn't perform any preprocessing of the serialized data. As a consequence:
- All namespaces which aren't passed to the serializeStream()/serialize() methods using the $nmsp parameter are just declared in-place in each XML tag in which they are needed.
- The tag representing the subject is reused only if subsequent triples being serialized share the same subject. For the sake of simplicity, speed and low memory usage this class doesn't try to reorder triples in a way each subject in the graph has only single XML tag representing it.
Other limitations:
- Only triples can be serialized as the RDF-XML serialization format is defined only for the base RDF.
- This class naivly shortens predicate URIs splitting on the last hash, slash, star or semicolon. This doesn't guarantee generation of a proper XML PrefixedName. The simplest corner case is just an URI ending with a number like http://foo/123 which is shortened to ns:123 which is invalid in XML.
Tags
Table of Contents
Interfaces
Properties
- $prefixes : array<string, string>
- $prettyPrint : bool
Methods
- __construct() : mixed
- serialize() : string
- serializeStream() : void
- e() : string
- shorten() : array<string|int, string>
Properties
$prefixes
private
array<string, string>
$prefixes
$prettyPrint
private
bool
$prettyPrint
Methods
__construct()
public
__construct([bool $prettyPrint = true ]) : mixed
Parameters
- $prettyPrint : bool = true
-
should output XML be pretty-formatted?
serialize()
public
serialize(Traversable<string|int, QuadInterface>|array<string|int, QuadInterface> $graph[, RdfNamespaceInterface|null $nmsp = null ]) : string
Parameters
- $graph : Traversable<string|int, QuadInterface>|array<string|int, QuadInterface>
- $nmsp : RdfNamespaceInterface|null = null
Tags
Return values
stringserializeStream()
public
serializeStream(resource|StreamInterface $output, Traversable<string|int, QuadInterface>|array<string|int, QuadInterface> $graph[, RdfNamespaceInterface|null $nmsp = null ]) : void
Parameters
- $output : resource|StreamInterface
- $graph : Traversable<string|int, QuadInterface>|array<string|int, QuadInterface>
- $nmsp : RdfNamespaceInterface|null = null
Tags
e()
private
e(string $value) : string
Parameters
- $value : string
Return values
stringshorten()
private
shorten(string $uri) : array<string|int, string>
Parameters
- $uri : string