Skip to content

Blank nodes parsing reworked

Latest
Compare
Choose a tag to compare
@zozlak zozlak released this 29 Apr 08:44

Until now parsing of blank nodes did not follow the RDF specification which requires blank nodes from different documents to be treated as different nodes even if they have same blank node identifier (see here). This release allows to choose how the blank nodes should be handled:

  • All parsers' parse() and parseStream() methods implement an optional $baseUri parameter identifying the parsed document. This allows a parser to determine if a blank node with a given id should create a new RDF graph node or not according to the RDF specification.
    • Because of possible blank node identifiers conflicts between documents all parsed blank node identifiers are regenerated using a global unique sequence. If for some reason you need to preserve blank node identifiers of a parsed document, use rdfInterface\ParserInterface::BLANK_NODES_PRESERVE as the $baseUri parameter value.
  • The quickRdfIo\Util::parse() method passes the $baseUri parameter to the parser and if it's not provided, tries to guess it (e.g. takes a file path is a file is parsed, an URI if data is parsed from an URI or a PSR-7 response, etc.).