RdfXmlParser
in package
implements
ParserInterface, QuadIteratorInterface
uses
TmpStreamParserTrait
Streaming RDF-XML parser. Fast and with low memory footprint.
Known deviations from the RDF-XML specification:
- Doesn't resolve "/.." in relative IRIs.
- Doesn't support rdf:Seq shorthand syntax
- Doesn't support rdf:Collection shorthand syntax
Tags
Table of Contents
Interfaces
Constants
- CHUNK_SIZE = 1000000
- PARSETYPE_COLLECTION = 'Collection'
- PARSETYPE_LITERAL = 'Literal'
- PARSETYPE_RESOURCE = 'Resource'
- RDF_ABOUT = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#about'
- RDF_ABOUTEACH = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#aboutEach'
- RDF_ABOUTEACHPREFIX = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#aboutEachPrefix'
- RDF_COLLELPREFIX = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#_'
- RDF_DATATYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#datatype'
- RDF_DESCRIPTION = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Description'
- RDF_ID = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#ID'
- RDF_LI = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#li'
- RDF_NODEID = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nodeID'
- RDF_PARSETYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#parseType'
- RDF_RESOURCE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#resource'
- RDF_ROOT = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#RDF'
- XML_BASE = 'http://www.w3.org/XML/1998/namespacebase'
- XML_LANG = 'http://www.w3.org/XML/1998/namespacelang'
Properties
- $baseUri : string
- $baseUriDefault : string
- $baseUriEmpty : string
- $dataFactory : DataFactoryInterface
- $elementIds : array<string, NamedNodeInterface>
- $input : StreamInterface
- $key : int|null
- $literalAttributes : array<string|int, string>
- $nmsp : array<string, array<string|int, string>>
- $parser : XmlParser
- $skipAttributes : array<string|int, string>
- $stack : array<string|int, RdfXmlParserState>
- $state : RdfXmlParserState
- $tmpStream : resource|null
- $triples : array<string|int, QuadInterface>
Methods
- __construct() : mixed
- __destruct() : mixed
- current() : QuadInterface
- key() : int|null
- next() : void
- parse() : QuadIteratorInterface
- parseStream() : QuadIteratorInterface
- rewind() : void
- setBaseUri() : void
- valid() : bool
- addTriple() : void
- closeTmpStream() : void
- handleElementId() : NamedNodeInterface
- onCData() : void
- onElementEnd() : void
- onElementStart() : void
- onNamespaceEnd() : void
- onNamespaceStart() : void
- onNode() : void
- onPredicate() : void
- onRoot() : void
- onXmlLiteralElement() : void
- parseBaseUri() : void
- reportError() : void
- resolveIri() : string
- https://www.w3.org/TR/rdf-syntax-grammar/#section-Syntax-ID-xml-base
- shorten() : string
Constants
CHUNK_SIZE
public
mixed
CHUNK_SIZE
= 1000000
PARSETYPE_COLLECTION
public
mixed
PARSETYPE_COLLECTION
= 'Collection'
PARSETYPE_LITERAL
public
mixed
PARSETYPE_LITERAL
= 'Literal'
PARSETYPE_RESOURCE
public
mixed
PARSETYPE_RESOURCE
= 'Resource'
RDF_ABOUT
public
mixed
RDF_ABOUT
= 'http://www.w3.org/1999/02/22-rdf-syntax-ns#about'
RDF_ABOUTEACH
public
mixed
RDF_ABOUTEACH
= 'http://www.w3.org/1999/02/22-rdf-syntax-ns#aboutEach'
RDF_ABOUTEACHPREFIX
public
mixed
RDF_ABOUTEACHPREFIX
= 'http://www.w3.org/1999/02/22-rdf-syntax-ns#aboutEachPrefix'
RDF_COLLELPREFIX
public
mixed
RDF_COLLELPREFIX
= 'http://www.w3.org/1999/02/22-rdf-syntax-ns#_'
RDF_DATATYPE
public
mixed
RDF_DATATYPE
= 'http://www.w3.org/1999/02/22-rdf-syntax-ns#datatype'
RDF_DESCRIPTION
public
mixed
RDF_DESCRIPTION
= 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Description'
RDF_ID
public
mixed
RDF_ID
= 'http://www.w3.org/1999/02/22-rdf-syntax-ns#ID'
RDF_LI
public
mixed
RDF_LI
= 'http://www.w3.org/1999/02/22-rdf-syntax-ns#li'
RDF_NODEID
public
mixed
RDF_NODEID
= 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nodeID'
RDF_PARSETYPE
public
mixed
RDF_PARSETYPE
= 'http://www.w3.org/1999/02/22-rdf-syntax-ns#parseType'
RDF_RESOURCE
public
mixed
RDF_RESOURCE
= 'http://www.w3.org/1999/02/22-rdf-syntax-ns#resource'
RDF_ROOT
public
mixed
RDF_ROOT
= 'http://www.w3.org/1999/02/22-rdf-syntax-ns#RDF'
XML_BASE
public
mixed
XML_BASE
= 'http://www.w3.org/XML/1998/namespacebase'
XML_LANG
public
mixed
XML_LANG
= 'http://www.w3.org/XML/1998/namespacelang'
Properties
$baseUri
private
string
$baseUri
$baseUriDefault
private
string
$baseUriDefault
$baseUriEmpty
private
string
$baseUriEmpty
$dataFactory
private
DataFactoryInterface
$dataFactory
$elementIds
private
array<string, NamedNodeInterface>
$elementIds
$input
private
StreamInterface
$input
$key
private
int|null
$key
= null
$literalAttributes
private
static array<string|int, string>
$literalAttributes
= [self::RDF_ID, self::RDF_DATATYPE, self::XML_LANG]
$nmsp
private
array<string, array<string|int, string>>
$nmsp
$parser
private
XmlParser
$parser
$skipAttributes
private
static array<string|int, string>
$skipAttributes
= [self::RDF_ABOUT, self::RDF_ID, self::RDF_NODEID, self::RDF_RESOURCE, self::RDF_DATATYPE, self::RDF_PARSETYPE, self::XML_LANG]
$stack
private
array<string|int, RdfXmlParserState>
$stack
$state
private
RdfXmlParserState
$state
$tmpStream
private
resource|null
$tmpStream
$triples
private
array<string|int, QuadInterface>
$triples
Methods
__construct()
public
__construct(DataFactoryInterface $dataFactory[, string $baseUri = '' ]) : mixed
Parameters
- $dataFactory : DataFactoryInterface
-
factory to be used to generate RDF terms.
- $baseUri : string = ''
__destruct()
public
__destruct() : mixed
current()
public
current() : QuadInterface
Return values
QuadInterfacekey()
public
key() : int|null
Return values
int|nullnext()
public
next() : void
parse()
public
parse(string $input) : QuadIteratorInterface
Parameters
- $input : string
Return values
QuadIteratorInterfaceparseStream()
public
parseStream(resource|StreamInterface $input) : QuadIteratorInterface
Parameters
- $input : resource|StreamInterface
Return values
QuadIteratorInterfacerewind()
public
rewind() : void
setBaseUri()
public
setBaseUri(string $baseUri) : void
Parameters
- $baseUri : string
valid()
public
valid() : bool
Return values
booladdTriple()
private
addTriple(BlankNodeInterface|NamedNodeInterface|null $subject, NamedNodeInterface|string $predicate, NamedNodeInterface|BlankNodeInterface|string $object[, string|null $lang = null ][, string|null $datatype = null ][, BlankNodeInterface|NamedNodeInterface|null $reifyAs = null ]) : void
Parameters
- $subject : BlankNodeInterface|NamedNodeInterface|null
- $predicate : NamedNodeInterface|string
- $object : NamedNodeInterface|BlankNodeInterface|string
- $lang : string|null = null
- $datatype : string|null = null
- $reifyAs : BlankNodeInterface|NamedNodeInterface|null = null
closeTmpStream()
private
closeTmpStream() : void
handleElementId()
private
handleElementId(string $id) : NamedNodeInterface
Parameters
- $id : string
Return values
NamedNodeInterfaceonCData()
private
onCData(string $data) : void
Parameters
- $data : string
onElementEnd()
private
onElementEnd(string $name) : void
Parameters
- $name : string
onElementStart()
private
onElementStart(string $name, array<string, string> &$attribs) : void
Parameters
- $name : string
- $attribs : array<string, string>
Tags
onNamespaceEnd()
private
onNamespaceEnd(XmlParser $parser, string $prefix) : void
Parameters
- $parser : XmlParser
- $prefix : string
onNamespaceStart()
private
onNamespaceStart(XmlParser $parser, string $prefix, string $uri) : void
Parameters
- $parser : XmlParser
- $prefix : string
- $uri : string
onNode()
private
onNode(string $tag, array<string, string> &$attributes) : void
Parameters
- $tag : string
- $attributes : array<string, string>
onPredicate()
private
onPredicate(string $tag, array<string, string> &$attributes) : void
Parameters
- $tag : string
- $attributes : array<string, string>
onRoot()
private
onRoot(array<string, string> &$attributes) : void
Parameters
- $attributes : array<string, string>
onXmlLiteralElement()
private
onXmlLiteralElement(string $name, array<string, string> &$attributes) : void
Parameters
- $name : string
- $attributes : array<string, string>
parseBaseUri()
private
parseBaseUri(string $baseUri) : void
Parameters
- $baseUri : string
reportError()
private
reportError() : void
resolveIri()
https://www.w3.org/TR/rdf-syntax-grammar/#section-Syntax-ID-xml-base
private
resolveIri(string $iri) : string
Parameters
- $iri : string
Return values
stringshorten()
private
shorten(string $uri) : string
Parameters
- $uri : string