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
Interfaces, Classes, Traits and Enums
Table of Contents
- $prefixes : array<string, string>
- $prettyPrint : bool
- __construct() : mixed
- serialize() : string
- serializeStream() : void
- e() : string
- shorten() : array<string|int, string>
Properties
$prefixes
private
array<string, string>
$prefixes
Tags
$prettyPrint
private
bool
$prettyPrint
Tags
Methods
__construct()
public
__construct([bool $prettyPrint = true ]) : mixed
Parameters
- $prettyPrint : bool = true
-
should output XML be pretty-formatted?
Tags
Return values
mixed —serialize()
public
serialize(QuadIteratorInterface|QuadIteratorAggregateInterface $graph[, RdfNamespaceInterface|null $nmsp = null ]) : string
Parameters
- $graph : QuadIteratorInterface|QuadIteratorAggregateInterface
- $nmsp : RdfNamespaceInterface|null = null
Tags
Return values
string —serializeStream()
public
serializeStream(mixed $output, QuadIteratorInterface|QuadIteratorAggregateInterface $graph[, RdfNamespaceInterface|null $nmsp = null ]) : void
Parameters
- $output : mixed
- $graph : QuadIteratorInterface|QuadIteratorAggregateInterface
- $nmsp : RdfNamespaceInterface|null = null
Tags
Return values
void —e()
private
e(string $value) : string
Parameters
- $value : string
Tags
Return values
string —shorten()
private
shorten(string $uri) : array<string|int, string>
Parameters
- $uri : string