Documentation

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
author

zozlak

Table of Contents

Interfaces

ParserInterface
QuadIteratorInterface

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

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

$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

$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]

Methods

setBaseUri()

public setBaseUri(string $baseUri) : void
Parameters
$baseUri : string

addTriple()

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

onCData()

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
throws
RdfIoException

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

resolveIri()

https://www.w3.org/TR/rdf-syntax-grammar/#section-Syntax-ID-xml-base

private resolveIri(string $iri) : string
Parameters
$iri : string
Return values
string

shorten()

private shorten(string $uri) : string
Parameters
$uri : string
Return values
string

        
On this page

Search results