# rdflib.plugins.parsers package

## Submodules

## rdflib.plugins.parsers.RDFVOC module

class rdflib.plugins.parsers.RDFVOC.RDFVOC

  Bases: `RDF`

  Description: `URIRef` = rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#Description')
  ID: `URIRef` = rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#ID')
  RDF: `URIRef` = rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#RDF')
  about: `URIRef` = rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#about')
  datatype: `URIRef` = rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#datatype')
  li: `URIRef` = rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#li')
  nodeID: `URIRef` = rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#nodeID')
  parseType: `URIRef` = rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#parseType')
  resource: `URIRef` = rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#resource')

## rdflib.plugins.parsers.hext module

This is a rdflib plugin for parsing Hextuple files, which are Newline-Delimited JSON (ndjson) files, into Conjunctive. The store that backs the graph must be able to handle contexts, i.e. multiple graphs.

class rdflib.plugins.parsers.hext.HextuplesParser

  Bases: `Parser`

  An RDFLib parser for Hextuples

  __annotations__ = {}
  __dict__ = mappingproxy({'__module__': 'rdflib.plugins.parsers.hext', '__firstlineno__': 32, '__doc__': '\nAn RDFLib parser for Hextuples\n', '__init__': <function HextuplesParser.__init__>, '_parse_hextuple': <function HextuplesParser._parse_hextuple>, 'parse': <function HextuplesParser.parse>, '__static_attributes__': ('default_context', 'skolemize'), '__dict__': <attribute '__dict__' of 'HextuplesParser' objects>, '__weakref__': <attribute '__weakref__' of 'HextuplesParser' objects>, '__annotations__': {'default_context': 'Optional[Graph]'}})
  __firstlineno__ = 32
  __init__()
  __module__ = 'rdflib.plugins.parsers.hext'
  __static_attributes__ = ('default_context', 'skolemize')
  __weakref__

    list of weak references to the object

  parse(source, graph, skolemize=False, **kwargs)
    Parameters:

      - source (`InputSource`)

      - graph (`Graph`)

      - skolemize (`bool`)

      - kwargs (`Any`)

    Return type:

      `None`

## rdflib.plugins.parsers.jsonld module

This parser will interpret a JSON-LD document as an RDF Graph. See:

> http://json-ld.org/

Example usage:

    >>> from rdflib import Graph, URIRef, Literal
    >>> test_json = '''
    ... {
    ...     "@context": {
    ...         "dc": "http://purl.org/dc/terms/",
    ...         "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    ...         "rdfs": "http://www.w3.org/2000/01/rdf-schema#"
    ...     },
    ...     "@id": "http://example.org/about",
    ...     "dc:title": {
    ...         "@language": "en",
    ...         "@value": "Someone's Homepage"
    ...     }
    ... }
    ... '''
    >>> g = Graph().parse(data=test_json, format='json-ld')
    >>> list(g) == [(URIRef('http://example.org/about'),
    ...     URIRef('http://purl.org/dc/terms/title'),
    ...     Literal("Someone's Homepage", lang='en'))]
    True

class rdflib.plugins.parsers.jsonld.JsonLDParser

  Bases: `Parser`

  __annotations__ = {}
  __dict__ = mappingproxy({'__module__': 'rdflib.plugins.parsers.jsonld', '__firstlineno__': 80, '__init__': <function JsonLDParser.__init__>, 'parse': <function JsonLDParser.parse>, '__static_attributes__': (), '__dict__': <attribute '__dict__' of 'JsonLDParser' objects>, '__weakref__': <attribute '__weakref__' of 'JsonLDParser' objects>, '__doc__': None, '__annotations__': {}})
  __firstlineno__ = 80
  __init__()
  __module__ = 'rdflib.plugins.parsers.jsonld'
  __static_attributes__ = ()
  __weakref__

    list of weak references to the object

  parse(source, sink, version=1.1, skolemize=False, encoding='utf-8', base=None, context=None, generalized_rdf=False, extract_all_scripts=False, **kwargs)

    Parse JSON-LD from a source document.

    The source document can be JSON or HTML with embedded JSON script elements (type attribute = “application/ld+json”). To process as HTML `source.content_type` must be set to “text/html” or “application/xhtml+xml”.

    Parameters:

      - source (`InputSource`) – InputSource with JSON-formatted data (JSON or HTML)

      - sink (`Graph`) – Graph to receive the parsed triples

      - version (`float`) – parse as JSON-LD version, defaults to 1.1

      - encoding (`Optional`[`str`]) – character encoding of the JSON (should be “utf-8” or “utf-16”), defaults to “utf-8”

      - base (`Optional`[`str`]) – JSON-LD Base IRI, defaults to None

      - context (`Union`[`List`[`Union`[`Dict`[`str`, `Any`], `str`, `None`]], `Dict`[`str`, `Any`], `str`, `None`]) – JSON-LD Context, defaults to None

      - generalized_rdf (`Optional`[`bool`]) – parse as Generalized RDF, defaults to False

      - extract_all_scripts (`Optional`[`bool`]) – if source is an HTML document then extract all script elements, defaults to False (extract only the first script element). This is ignored if `source.system_id` contains a fragment identifier, in which case only the script element with matching id attribute is extracted.

      - skolemize (`bool`)

      - kwargs (`Any`)

    Return type:

      `None`

rdflib.plugins.parsers.jsonld.to_rdf(data, dataset, base=None, context_data=None, version=None, generalized_rdf=False, allow_lists_of_lists=None, skolemize=False)
  Parameters:

    - data (`Any`)

    - dataset (`Graph`)

    - base (`Optional`[`str`])

    - context_data (`Union`[`List`[`Union`[`Dict`[`str`, `Any`], `str`, `None`]], `Dict`[`str`, `Any`], `str`, `None`])

    - version (`Optional`[`float`])

    - generalized_rdf (`bool`)

    - allow_lists_of_lists (`Optional`[`bool`])

    - skolemize (`bool`)

## rdflib.plugins.parsers.notation3 module

notation3.py - Standalone Notation3 Parser Derived from CWM, the Closed World Machine

Authors of the original suite:

- Dan Connolly <@@>

- Tim Berners-Lee <@@>

- Yosi Scharf <@@>

- Joseph M. Reagle Jr. <reagle@w3.org>

- Rich Salz <rsalz@zolera.com>

http://www.w3.org/2000/10/swap/notation3.py

Copyright 2000-2007, World Wide Web Consortium. Copyright 2001, MIT. Copyright 2001, Zolera Systems Inc.

License: W3C Software License http://www.w3.org/Consortium/Legal/copyright-software

Modified by Sean B. Palmer Copyright 2007, Sean B. Palmer.

Modified to work with rdflib by Gunnar Aastrand Grimnes Copyright 2010, Gunnar A. Grimnes

exception rdflib.plugins.parsers.notation3.BadSyntax(uri, lines, argstr, i, why)

  Bases: `SyntaxError`

  Parameters:

    - uri (`str`)

    - lines (`int`)

    - argstr (`str`)

    - i (`int`)

    - why (`str`)

  __firstlineno__ = 1737
  __init__(uri, lines, argstr, i, why)
    Parameters:

      - uri (`str`)

      - lines (`int`)

      - argstr (`str`)

      - i (`int`)

      - why (`str`)

  __module__ = 'rdflib.plugins.parsers.notation3'
  __static_attributes__ = ('_i', '_str', '_uri', '_why', 'lines')
  __str__()

    Return str(self).

    Return type:

      `str`

  __weakref__

    list of weak references to the object

  property message: str

class rdflib.plugins.parsers.notation3.Formula(parent)

  Bases: `object`

  Parameters:

    parent (`Graph`)

  __dict__ = mappingproxy({'__module__': 'rdflib.plugins.parsers.notation3', '__firstlineno__': 1776, 'number': 0, '__init__': <function Formula.__init__>, '__str__': <function Formula.__str__>, 'id': <function Formula.id>, 'newBlankNode': <function Formula.newBlankNode>, 'newUniversal': <function Formula.newUniversal>, 'declareExistential': <function Formula.declareExistential>, 'close': <function Formula.close>, '__static_attributes__': ('counter', 'existentials', 'number', 'quotedgraph', 'universals', 'uuid'), '__dict__': <attribute '__dict__' of 'Formula' objects>, '__weakref__': <attribute '__weakref__' of 'Formula' objects>, '__doc__': None, '__annotations__': {'existentials': 'Dict[str, BNode]', 'universals': 'Dict[str, BNode]'}})
  __firstlineno__ = 1776
  __init__(parent)
    Parameters:

      parent (`Graph`)

  __module__ = 'rdflib.plugins.parsers.notation3'
  __static_attributes__ = ('counter', 'existentials', 'number', 'quotedgraph', 'universals', 'uuid')
  __str__()

    Return str(self).

    Return type:

      `str`

  __weakref__

    list of weak references to the object

  close()
    Return type:

      `QuotedGraph`

  declareExistential(x)
    Parameters:

      x (`str`)

    Return type:

      `None`

  id()
    Return type:

      `BNode`

  newBlankNode(uri=None, why=None)
    Parameters:

      - uri (`Optional`[`str`])

      - why (`Optional`[`Any`])

    Return type:

      `BNode`

  newUniversal(uri, why=None)
    Parameters:

      - uri (`str`)

      - why (`Optional`[`Any`])

    Return type:

      `Variable`

  number = 0

class rdflib.plugins.parsers.notation3.N3Parser

  Bases: `TurtleParser`

  An RDFLib parser for Notation3

  See http://www.w3.org/DesignIssues/Notation3.html

  __annotations__ = {}
  __firstlineno__ = 2026
  __init__()
  __module__ = 'rdflib.plugins.parsers.notation3'
  __static_attributes__ = ()
  parse(source, graph, encoding='utf-8')
    Parameters:

      - source (`InputSource`)

      - graph (`Graph`)

      - encoding (`Optional`[`str`])

    Return type:

      `None`

class rdflib.plugins.parsers.notation3.RDFSink(graph)

  Bases: `object`

  Parameters:

    graph (`Graph`)

  __dict__ = mappingproxy({'__module__': 'rdflib.plugins.parsers.notation3', '__firstlineno__': 1818, '__init__': <function RDFSink.__init__>, 'newFormula': <function RDFSink.newFormula>, 'newGraph': <function RDFSink.newGraph>, 'newSymbol': <function RDFSink.newSymbol>, 'newBlankNode': <function RDFSink.newBlankNode>, 'newLiteral': <function RDFSink.newLiteral>, 'newList': <function RDFSink.newList>, 'newSet': <function RDFSink.newSet>, 'setDefaultNamespace': <function RDFSink.setDefaultNamespace>, 'makeStatement': <function RDFSink.makeStatement>, 'normalise': <function RDFSink.normalise>, 'intern': <function RDFSink.intern>, 'bind': <function RDFSink.bind>, 'startDoc': <function RDFSink.startDoc>, 'endDoc': <function RDFSink.endDoc>, '__static_attributes__': ('counter', 'graph', 'rootFormula', 'uuid'), '__dict__': <attribute '__dict__' of 'RDFSink' objects>, '__weakref__': <attribute '__weakref__' of 'RDFSink' objects>, '__doc__': None, '__annotations__': {'rootFormula': 'Optional[Formula]'}})
  __firstlineno__ = 1818
  __init__(graph)
    Parameters:

      graph (`Graph`)

  __module__ = 'rdflib.plugins.parsers.notation3'
  __static_attributes__ = ('counter', 'graph', 'rootFormula', 'uuid')
  __weakref__

    list of weak references to the object

  bind(pfx, uri)
    Return type:

      `None`

  endDoc(formula)
    Parameters:

      formula (`Optional`[`Formula`])

    Return type:

      `None`

  intern(something)
    Parameters:

      something (`TypeVar`(`_AnyT`))

    Return type:

      `TypeVar`(`_AnyT`)

  makeStatement(quadruple, why=None)
    Parameters:

      - quadruple (`Tuple`[`Union`[`Formula`, `Graph`, `None`], `Node`, `Node`, `Node`])

      - why (`Optional`[`Any`])

    Return type:

      `None`

  newBlankNode(arg=None, uri=None, why=None)
    Parameters:

      - arg (`Union`[`Formula`, `Graph`, `Any`, `None`])

      - uri (`Optional`[`str`])

      - why (`Optional`[`Callable`[[], `None`]])

    Return type:

      `BNode`

  newFormula()
    Return type:

      `Formula`

  newGraph(identifier)
    Parameters:

      identifier (`Identifier`)

    Return type:

      `Graph`

  newList(n, f)
    Parameters:

      - n (`List`[`Any`])

      - f (`Optional`[`Formula`])

    Return type:

      `IdentifiedNode`

  newLiteral(s, dt, lang)
    Parameters:

      - s (`str`)

      - dt (`Optional`[`URIRef`])

      - lang (`Optional`[`str`])

    Return type:

      `Literal`

  newSet(*args)
    Parameters:

      args (`TypeVar`(`_AnyT`))

    Return type:

      `Set`[`TypeVar`(`_AnyT`)]

  newSymbol(*args)
    Parameters:

      args (`str`)

    Return type:

      `URIRef`

  normalise(f, n)
    Parameters:

      - f (`Optional`[`Formula`])

      - n (`Union`[`Tuple`[`int`, `str`], `bool`, `int`, `Decimal`, `float`, `TypeVar`(`_AnyT`)])

    Return type:

      `Union`[`URIRef`, `Literal`, `BNode`, `TypeVar`(`_AnyT`)]

  setDefaultNamespace(*args)
    Parameters:

      args (`bytes`)

    Return type:

      `str`

  startDoc(formula)
    Parameters:

      formula (`Optional`[`Formula`])

    Return type:

      `None`

class rdflib.plugins.parsers.notation3.SinkParser(store, openFormula=None, thisDoc='', baseURI=None, genPrefix='', why=None, turtle=False)

  Bases: `object`

  Parameters:

    - store (`RDFSink`)

    - openFormula (`Optional`[`Formula`])

    - thisDoc (`str`)

    - baseURI (`Optional`[`str`])

    - genPrefix (`str`)

    - why (`Optional`[`Callable`[[], `None`]])

    - turtle (`bool`)

  BadSyntax(argstr, i, msg)
    Parameters:

      - argstr (`str`)

      - i (`int`)

      - msg (`str`)

    Return type:

      `NoReturn`

  UEscape(argstr, i, startline)
    Parameters:

      - argstr (`str`)

      - i (`int`)

      - startline (`int`)

    Return type:

      `Tuple`[`int`, `str`]

  __dict__ = mappingproxy({'__module__': 'rdflib.plugins.parsers.notation3', '__firstlineno__': 383, '__init__': <function SinkParser.__init__>, 'here': <function SinkParser.here>, 'formula': <function SinkParser.formula>, 'loadStream': <function SinkParser.loadStream>, 'loadBuf': <function SinkParser.loadBuf>, 'feed': <function SinkParser.feed>, 'directiveOrStatement': <function SinkParser.directiveOrStatement>, 'tok': <function SinkParser.tok>, 'sparqlTok': <function SinkParser.sparqlTok>, 'directive': <function SinkParser.directive>, 'sparqlDirective': <function SinkParser.sparqlDirective>, 'bind': <function SinkParser.bind>, 'setKeywords': <function SinkParser.setKeywords>, 'startDoc': <function SinkParser.startDoc>, 'endDoc': <function SinkParser.endDoc>, 'makeStatement': <function SinkParser.makeStatement>, 'statement': <function SinkParser.statement>, 'subject': <function SinkParser.subject>, 'verb': <function SinkParser.verb>, 'prop': <function SinkParser.prop>, 'item': <function SinkParser.item>, 'blankNode': <function SinkParser.blankNode>, 'path': <function SinkParser.path>, 'anonymousNode': <function SinkParser.anonymousNode>, 'node': <function SinkParser.node>, 'property_list': <function SinkParser.property_list>, 'commaSeparatedList': <function SinkParser.commaSeparatedList>, 'objectList': <function SinkParser.objectList>, 'checkDot': <function SinkParser.checkDot>, 'uri_ref2': <function SinkParser.uri_ref2>, 'skipSpace': <function SinkParser.skipSpace>, 'variable': <function SinkParser.variable>, 'bareWord': <function SinkParser.bareWord>, 'qname': <function SinkParser.qname>, 'object': <function SinkParser.object>, 'nodeOrLiteral': <function SinkParser.nodeOrLiteral>, 'uriOf': <function SinkParser.uriOf>, 'strconst': <function SinkParser.strconst>, '_unicodeEscape': <function SinkParser._unicodeEscape>, 'uEscape': <function SinkParser.uEscape>, 'UEscape': <function SinkParser.UEscape>, 'BadSyntax': <function SinkParser.BadSyntax>, '__static_attributes__': ('_anonymousNodes', '_baseURI', '_bindings', '_context', '_formula', '_genPrefix', '_parentContext', '_parentVariables', '_reason', '_reason2', '_store', '_thisDoc', '_variables', 'keywords', 'keywordsSet', 'lines', 'startOfLine', 'string_delimiters', 'turtle'), '__dict__': <attribute '__dict__' of 'SinkParser' objects>, '__weakref__': <attribute '__weakref__' of 'SinkParser' objects>, '__doc__': None, '__annotations__': {'_anonymousNodes': 'Dict[str, BNode]', '_variables': 'Dict[str, Variable]', '_parentVariables': 'Dict[str, Variable]', '_reason2': 'Optional[Callable[..., None]]', '_baseURI': 'Optional[str]', '_formula': 'Optional[Formula]', '_context': 'Optional[Formula]', '_parentContext': 'Optional[Formula]'}})
  __firstlineno__ = 383
  __init__(store, openFormula=None, thisDoc='', baseURI=None, genPrefix='', why=None, turtle=False)

    note: namespace names should not end in # ; the # will get added during qname processing

    Parameters:

      - store (`RDFSink`)

      - openFormula (`Optional`[`Formula`])

      - thisDoc (`str`)

      - baseURI (`Optional`[`str`])

      - genPrefix (`str`)

      - why (`Optional`[`Callable`[[], `None`]])

      - turtle (`bool`)

  __module__ = 'rdflib.plugins.parsers.notation3'
  __static_attributes__ = ('_anonymousNodes', '_baseURI', '_bindings', '_context', '_formula', '_genPrefix', '_parentContext', '_parentVariables', '_reason', '_reason2', '_store', '_thisDoc', '_variables', 'keywords', 'keywordsSet', 'lines', 'startOfLine', 'string_delimiters', 'turtle')
  __weakref__

    list of weak references to the object

  anonymousNode(ln)

    Remember or generate a term for one of these _: anonymous nodes

    Parameters:

      ln (`str`)

    Return type:

      `BNode`

  bareWord(argstr, i, res)

    abc -> :abc

    Parameters:

      - argstr (`str`)

      - i (`int`)

      - res (`MutableSequence`[`Any`])

    Return type:

      `int`

  bind(qn, uri)
    Parameters:

      - qn (`str`)

      - uri (`bytes`)

    Return type:

      `None`

  blankNode(uri=None)
    Parameters:

      uri (`Optional`[`str`])

    Return type:

      `BNode`

  checkDot(argstr, i)
    Parameters:

      - argstr (`str`)

      - i (`int`)

    Return type:

      `int`

  commaSeparatedList(argstr, j, res, what)

    return value: -1 bad syntax; >1 new position in argstr res has things found appended

    Parameters:

      - argstr (`str`)

      - j (`int`)

      - res (`MutableSequence`[`Any`])

      - what (`Callable`[[`str`, `int`, `MutableSequence`[`Any`]], `int`])

    Return type:

      `int`

  directive(argstr, i)
    Parameters:

      - argstr (`str`)

      - i (`int`)

    Return type:

      `int`

  directiveOrStatement(argstr, h)
    Parameters:

      - argstr (`str`)

      - h (`int`)

    Return type:

      `int`

  endDoc()

    Signal end of document and stop parsing. returns formula

    Return type:

      `Optional`[`Formula`]

  feed(octets)

    Feed an octet stream to the parser

    if BadSyntax is raised, the string passed in the exception object is the remainder after any statements have been parsed. So if there is more data to feed to the parser, it should be straightforward to recover.

    Parameters:

      octets (`Union`[`str`, `bytes`])

    Return type:

      `None`

  formula()
    Return type:

      `Optional`[`Formula`]

  here(i)

    String generated from position in file

    This is for repeatability when referring people to bnodes in a document. This has diagnostic uses less formally, as it should point one to which bnode the arbitrary identifier actually is. It gives the line and character number of the ‘[’ charcacter or path character which introduced the blank node. The first blank node is boringly _L1C1. It used to be used only for tracking, but for tests in general it makes the canonical ordering of bnodes repeatable.

    Parameters:

      i (`int`)

    Return type:

      `str`

  item(argstr, i, res)
    Parameters:

      - argstr (`str`)

      - res (`MutableSequence`[`Any`])

    Return type:

      `int`

  loadBuf(buf)

    Parses a buffer and returns its top level formula

    Parameters:

      buf (`Union`[`str`, `bytes`])

    Return type:

      `Optional`[`Formula`]

  loadStream(stream)
    Parameters:

      stream (`Union`[`IO`[`str`], `IO`[`bytes`]])

    Return type:

      `Optional`[`Formula`]

  makeStatement(quadruple)
    Return type:

      `None`

  node(argstr, i, res, subjectAlready=None)

    Parse the <node> production. Space is now skipped once at the beginning instead of in multiple calls to self.skipSpace().

    Parameters:

      - argstr (`str`)

      - i (`int`)

      - res (`MutableSequence`[`Any`])

      - subjectAlready (`Optional`[`Node`])

    Return type:

      `int`

  nodeOrLiteral(argstr, i, res)
    Parameters:

      - argstr (`str`)

      - i (`int`)

      - res (`MutableSequence`[`Any`])

    Return type:

      `int`

  object(argstr, i, res)
    Parameters:

      - argstr (`str`)

      - i (`int`)

      - res (`MutableSequence`[`Any`])

    Return type:

      `int`

  objectList(argstr, i, res)
    Parameters:

      - argstr (`str`)

      - i (`int`)

      - res (`MutableSequence`[`Any`])

    Return type:

      `int`

  path(argstr, i, res)

    Parse the path production.

    Parameters:

      - argstr (`str`)

      - i (`int`)

      - res (`MutableSequence`[`Any`])

    Return type:

      `int`

  prop(argstr, i, res)
    Parameters:

      - argstr (`str`)

      - i (`int`)

      - res (`MutableSequence`[`Any`])

    Return type:

      `int`

  property_list(argstr, i, subj)

    Parse property list Leaves the terminating punctuation in the buffer

    Parameters:

      - argstr (`str`)

      - i (`int`)

      - subj (`Node`)

    Return type:

      `int`

  qname(argstr, i, res)

    xyz:def -> (‘xyz’, ‘def’) If not in keywords and keywordsSet: def -> (‘’, ‘def’) :def -> (‘’, ‘def’)

    Parameters:

      - argstr (`str`)

      - i (`int`)

      - res (`MutableSequence`[`Union`[`Identifier`, `Tuple`[`str`, `str`]]])

    Return type:

      `int`

  setKeywords(k)

    Takes a list of strings

    Parameters:

      k (`Optional`[`List`[`str`]])

    Return type:

      `None`

  skipSpace(argstr, i)

    Skip white space, newlines and comments. return -1 if EOF, else position of first non-ws character

    Parameters:

      - argstr (`str`)

      - i (`int`)

    Return type:

      `int`

  sparqlDirective(argstr, i)

    turtle and trig support BASE/PREFIX without @ and without terminating .

    Parameters:

      - argstr (`str`)

      - i (`int`)

    Return type:

      `int`

  sparqlTok(tok, argstr, i)

    Check for SPARQL keyword. Space must have been stripped on entry and we must not be at end of file. Case insensitive and not preceded by @

    Parameters:

      - tok (`str`)

      - argstr (`str`)

      - i (`int`)

    Return type:

      `int`

  startDoc()
    Return type:

      `None`

  statement(argstr, i)
    Parameters:

      - argstr (`str`)

      - i (`int`)

    Return type:

      `int`

  strconst(argstr, i, delim)

    parse an N3 string constant delimited by delim. return index, val

    Parameters:

      - argstr (`str`)

      - i (`int`)

      - delim (`str`)

    Return type:

      `Tuple`[`int`, `str`]

  subject(argstr, i, res)
    Parameters:

      - argstr (`str`)

      - i (`int`)

      - res (`MutableSequence`[`Any`])

    Return type:

      `int`

  tok(tok, argstr, i, colon=False)

    Check for keyword. Space must have been stripped on entry and we must not be at end of file.

    if colon, then keyword followed by colon is ok (@prefix:<blah> is ok, rdf:type shortcut a must be followed by ws)

    Parameters:

      - tok (`str`)

      - argstr (`str`)

      - i (`int`)

      - colon (`bool`)

    Return type:

      `int`

  uEscape(argstr, i, startline)
    Parameters:

      - argstr (`str`)

      - i (`int`)

      - startline (`int`)

    Return type:

      `Tuple`[`int`, `str`]

  uriOf(sym)
    Parameters:

      sym (`Union`[`Identifier`, `Tuple`[`str`, `str`]])

    Return type:

      `str`

  uri_ref2(argstr, i, res)

    Generate uri from n3 representation.

    Note that the RDF convention of directly concatenating NS and local name is now used though I prefer inserting a ‘#’ to make the namesapces look more like what XML folks expect.

    Parameters:

      - argstr (`str`)

      - i (`int`)

      - res (`MutableSequence`[`Any`])

    Return type:

      `int`

  variable(argstr, i, res)

    ?abc -> variable(:abc)

    Parameters:

      - argstr (`str`)

      - i (`int`)

    Return type:

      `int`

  verb(argstr, i, res)

    has _prop_ is _prop_ of a = _prop_ >- prop -> <- prop -< _operator_

    Parameters:

      - argstr (`str`)

      - i (`int`)

      - res (`MutableSequence`[`Any`])

    Return type:

      `int`

class rdflib.plugins.parsers.notation3.TurtleParser

  Bases: `Parser`

  An RDFLib parser for Turtle

  See http://www.w3.org/TR/turtle/

  __annotations__ = {}
  __dict__ = mappingproxy({'__module__': 'rdflib.plugins.parsers.notation3', '__firstlineno__': 1990, '__doc__': '\nAn RDFLib parser for Turtle\n\nSee http://www.w3.org/TR/turtle/\n', '__init__': <function TurtleParser.__init__>, 'parse': <function TurtleParser.parse>, '__static_attributes__': (), '__dict__': <attribute '__dict__' of 'TurtleParser' objects>, '__weakref__': <attribute '__weakref__' of 'TurtleParser' objects>, '__annotations__': {}})
  __firstlineno__ = 1990
  __init__()
  __module__ = 'rdflib.plugins.parsers.notation3'
  __static_attributes__ = ()
  __weakref__

    list of weak references to the object

  parse(source, graph, encoding='utf-8', turtle=True)
    Parameters:

      - source (`InputSource`)

      - graph (`Graph`)

      - encoding (`Optional`[`str`])

      - turtle (`bool`)

    Return type:

      `None`

rdflib.plugins.parsers.notation3.base()

  The base URI for this process - the Web equiv of cwd

  Relative or absolute unix-standard filenames parsed relative to this yield the URI of the file. If we had a reliable way of getting a computer name, we should put it in the hostname just to prevent ambiguity

  Return type:

    `str`

rdflib.plugins.parsers.notation3.hexify(ustr)

  Use URL encoding to return an ASCII string corresponding to the given UTF8 string

      >>> hexify("http://example/a b")
      b'http://example/a%20b'

  Parameters:

    ustr (`str`)

  Return type:

    `bytes`

rdflib.plugins.parsers.notation3.join(here, there)

  join an absolute URI and URI reference (non-ascii characters are supported/doctested; haven’t checked the details of the IRI spec though)

  `here` is assumed to be absolute. `there` is URI reference.

      >>> join('http://example/x/y/z', '../abc')
      'http://example/x/abc'

  Raise ValueError if there uses relative path syntax but here has no hierarchical path.

      >>> join('mid:foo@example', '../foo')
      Traceback (most recent call last):
          raise ValueError(here)
      ValueError: Base <mid:foo@example> has no slash
      after colon - with relative '../foo'.

      >>> join('http://example/x/y/z', '')
      'http://example/x/y/z'

      >>> join('mid:foo@example', '#foo')
      'mid:foo@example#foo'

  We grok IRIs

      >>> len('Andr\xe9')
      5

      >>> join('http://example.org/', '#Andr\xe9')
      'http://example.org/#Andr\xe9'

  Parameters:

    - here (`str`)

    - there (`str`)

  Return type:

    `str`

rdflib.plugins.parsers.notation3.runNamespace()

  Returns a URI suitable as a namespace for run-local objects

  Return type:

    `str`

rdflib.plugins.parsers.notation3.splitFragP(uriref, punc=0)

  split a URI reference before the fragment

  Punctuation is kept.

  e.g.

      >>> splitFragP("abc#def")
      ('abc', '#def')

      >>> splitFragP("abcdef")
      ('abcdef', '')

  Parameters:

    - uriref (`str`)

    - punc (`int`)

  Return type:

    `Tuple`[`str`, `str`]

rdflib.plugins.parsers.notation3.uniqueURI()

  A unique URI

  Return type:

    `str`

## rdflib.plugins.parsers.nquads module

This is a rdflib plugin for parsing NQuad files into Conjunctive graphs that can be used and queried. The store that backs the graph must be able to handle contexts.

    >>> from rdflib import ConjunctiveGraph, URIRef, Namespace
    >>> g = ConjunctiveGraph()
    >>> data = open("test/data/nquads.rdflib/example.nquads", "rb")
    >>> g.parse(data, format="nquads")
    <Graph identifier=... (<class 'rdflib.graph.Graph'>)>
    >>> assert len(g.store) == 449
    >>> # There should be 16 separate contexts
    >>> assert len([x for x in g.store.contexts()]) == 16
    >>> # is the name of entity E10009 "Arco Publications"?
    >>> #   (in graph http://bibliographica.org/entity/E10009)
    >>> # Looking for:
    >>> # <http://bibliographica.org/entity/E10009>
    >>> #   <http://xmlns.com/foaf/0.1/name>
    >>> #   "Arco Publications"
    >>> #   <http://bibliographica.org/entity/E10009>
    >>> s = URIRef("http://bibliographica.org/entity/E10009")
    >>> FOAF = Namespace("http://xmlns.com/foaf/0.1/")
    >>> assert(g.value(s, FOAF.name).eq("Arco Publications"))

class rdflib.plugins.parsers.nquads.NQuadsParser(sink=None, bnode_context=None)

  Bases: `W3CNTriplesParser`

  Parameters:

    - sink (`Union`[`DummySink`, `NTGraphSink`, `None`])

    - bnode_context (`Optional`[`MutableMapping`[`str`, `BNode`]])

  __dict__ = mappingproxy({'__module__': 'rdflib.plugins.parsers.nquads', '__firstlineno__': 44, 'parse': <function NQuadsParser.parse>, 'parseline': <function NQuadsParser.parseline>, '__static_attributes__': ('buffer', 'file', 'line', 'sink', 'skolemize'), '__dict__': <attribute '__dict__' of 'NQuadsParser' objects>, '__weakref__': <attribute '__weakref__' of 'NQuadsParser' objects>, '__doc__': None, '__annotations__': {'sink': 'Union[DummySink, NTGraphSink]', 'buffer': 'Optional[str]', 'file': 'Optional[Union[TextIO, codecs.StreamReader]]', 'line': 'Optional[str]'}})
  __firstlineno__ = 44
  __module__ = 'rdflib.plugins.parsers.nquads'
  __static_attributes__ = ('buffer', 'file', 'line', 'sink', 'skolemize')
  __weakref__

    list of weak references to the object

  buffer: Optional[str]
  file: Optional[Union[TextIO, codecs.StreamReader]]
  line: Optional[str]
  parse(inputsource, sink, bnode_context=None, skolemize=False, **kwargs)

    Parse inputsource as an N-Quads file.

    Parameters:

      - inputsource (`InputSource`) – the source of N-Quads-formatted data

      - sink (`Graph`) – where to send parsed triples

      - bnode_context (`Optional`[`MutableMapping`[`str`, `BNode`]]) – a dict mapping blank node identifiers to `BNode` instances. See `W3CNTriplesParser.parse`

      - skolemize (`bool`)

      - kwargs (`Any`)

  parseline(bnode_context=None)
    Parameters:

      bnode_context (`Optional`[`MutableMapping`[`str`, `BNode`]])

    Return type:

      `None`

  sink: Union[DummySink, NTGraphSink]
  skolemize

## rdflib.plugins.parsers.ntriples module

N-Triples Parser License: GPL 2, W3C, BSD, or MIT Author: Sean B. Palmer, inamidst.com

class rdflib.plugins.parsers.ntriples.DummySink

  Bases: `object`

  __dict__ = mappingproxy({'__module__': 'rdflib.plugins.parsers.ntriples', '__firstlineno__': 61, '__init__': <function DummySink.__init__>, 'triple': <function DummySink.triple>, '__static_attributes__': ('length',), '__dict__': <attribute '__dict__' of 'DummySink' objects>, '__weakref__': <attribute '__weakref__' of 'DummySink' objects>, '__doc__': None, '__annotations__': {}})
  __firstlineno__ = 61
  __init__()
  __module__ = 'rdflib.plugins.parsers.ntriples'
  __static_attributes__ = ('length',)
  __weakref__

    list of weak references to the object

  triple(s, p, o)

class rdflib.plugins.parsers.ntriples.NTGraphSink(graph)

  Bases: `object`

  Parameters:

    graph (`Graph`)

  __firstlineno__ = 344
  __init__(graph)
    Parameters:

      graph (`Graph`)

  __module__ = 'rdflib.plugins.parsers.ntriples'
  __slots__ = ('g',)
  __static_attributes__ = ('g',)
  g
  triple(s, p, o)
    Parameters:

      - s (`Node`)

      - p (`Node`)

      - o (`Node`)

    Return type:

      `None`

class rdflib.plugins.parsers.ntriples.NTParser

  Bases: `Parser`

  parser for the ntriples format, often stored with the .nt extension

  See http://www.w3.org/TR/rdf-testcases/#ntriples

  __annotations__ = {}
  __firstlineno__ = 354
  __module__ = 'rdflib.plugins.parsers.ntriples'
  __slots__ = ()
  __static_attributes__ = ()
  classmethod parse(source, sink, **kwargs)

    Parse the NT format

    Parameters:

      - source (`InputSource`) – the source of NT-formatted data

      - sink (`Graph`) – where to send parsed triples

      - kwargs (`Any`) – Additional arguments to pass to `W3CNTriplesParser.parse`

    Return type:

      `None`

class rdflib.plugins.parsers.ntriples.W3CNTriplesParser(sink=None, bnode_context=None)

  Bases: `object`

  An N-Triples Parser. This is a legacy-style Triples parser for NTriples provided by W3C Usage:

      p = W3CNTriplesParser(sink=MySink())
      sink = p.parse(f) # file; use parsestring for a string

  To define a context in which blank node identifiers refer to the same blank node across instances of NTriplesParser, pass the same dict as `bnode_context` to each instance. By default, a new blank node context is created for each instance of `W3CNTriplesParser`.

  Parameters:

    - sink (`Union`[`DummySink`, `NTGraphSink`, `None`])

    - bnode_context (`Optional`[`MutableMapping`[`str`, `BNode`]])

  __annotations__ = {'buffer': 'Optional[str]', 'file': 'Optional[Union[TextIO, codecs.StreamReader]]', 'line': 'Optional[str]', 'sink': 'Union[DummySink, NTGraphSink]'}
  __firstlineno__ = 127
  __init__(sink=None, bnode_context=None)
    Parameters:

      - sink (`Union`[`DummySink`, `NTGraphSink`, `None`])

      - bnode_context (`Optional`[`MutableMapping`[`str`, `BNode`]])

  __module__ = 'rdflib.plugins.parsers.ntriples'
  __slots__ = ('_bnode_ids', 'sink', 'buffer', 'file', 'line', 'skolemize')
  __static_attributes__ = ('_bnode_ids', 'buffer', 'file', 'line', 'sink', 'skolemize')
  buffer: `Optional`[`str`]
  eat(pattern)
    Parameters:

      pattern (`Pattern`[`str`])

    Return type:

      `Match`[`str`]

  file: `Union`[`TextIO`, `StreamReader`, `None`]
  line: `Optional`[`str`]
  literal()
    Return type:

      `Union`[`Literal`[`False`], `Literal`]

  nodeid(bnode_context=None)
    Parameters:

      bnode_context (`Optional`[`MutableMapping`[`str`, `BNode`]])

    Return type:

      `Union`[`Literal`[`False`], `BNode`, `URIRef`]

  object(bnode_context=None)
    Parameters:

      bnode_context (`Optional`[`MutableMapping`[`str`, `BNode`]])

    Return type:

      `Union`[`URIRef`, `BNode`, `Literal`]

  parse(f, bnode_context=None, skolemize=False)

    Parse f as an N-Triples file.

    Parameters:

      - f (`Union`[`TextIO`, `IO`[`bytes`], `StreamReader`]) – the N-Triples source

      - bnode_context (`Optional`[`MutableMapping`[`str`, `BNode`]]) – a dict mapping blank node identifiers (e.g., `a` in `_:a`) to `BNode` instances. An empty dict can be passed in to define a distinct context for a given call to `parse`.

      - skolemize (`bool`)

    Return type:

      `Union`[`DummySink`, `NTGraphSink`]

  parseline(bnode_context=None)
    Parameters:

      bnode_context (`Optional`[`MutableMapping`[`str`, `BNode`]])

    Return type:

      `None`

  parsestring(s, **kwargs)

    Parse s as an N-Triples string.

    Parameters:

      s (`Union`[`bytes`, `bytearray`, `str`])

    Return type:

      `None`

  peek(token)
    Parameters:

      token (`str`)

    Return type:

      `bool`

  predicate()
    Return type:

      `Union`[`BNode`, `URIRef`]

  readline()

    Read an N-Triples line from buffered input.

    Return type:

      `Optional`[`str`]

  sink: `Union`[`DummySink`, `NTGraphSink`]
  skolemize
  subject(bnode_context=None)
    Return type:

      `Union`[`BNode`, `URIRef`]

  uriref()
    Return type:

      `Union`[`Literal`[`False`], `URIRef`]

rdflib.plugins.parsers.ntriples.unquote(s)

  Unquote an N-Triples string.

  Parameters:

    s (`str`)

  Return type:

    `str`

rdflib.plugins.parsers.ntriples.uriquote(uri)
  Parameters:

    uri (`str`)

  Return type:

    `str`

## rdflib.plugins.parsers.patch module

class rdflib.plugins.parsers.patch.Operation(*values)

  Bases: `Enum`

  Enum of RDF Patch operations.

  Operations: - `AddTripleOrQuad` (A): Adds a triple or quad. - `DeleteTripleOrQuad` (D): Deletes a triple or quad. - `AddPrefix` (PA): Adds a prefix. - `DeletePrefix` (PD): Deletes a prefix. - `TransactionStart` (TX): Starts a transaction. - `TransactionCommit` (TC): Commits a transaction. - `TransactionAbort` (TA): Aborts a transaction. - `Header` (H): Specifies a header.

  AddPrefix = 'PA'
  AddTripleOrQuad = 'A'
  DeletePrefix = 'PD'
  DeleteTripleOrQuad = 'D'
  Header = 'H'
  TransactionAbort = 'TA'
  TransactionCommit = 'TC'
  TransactionStart = 'TX'
  __module__ = 'rdflib.plugins.parsers.patch'

class rdflib.plugins.parsers.patch.RDFPatchParser(sink=None, bnode_context=None)

  Bases: `NQuadsParser`

  Parameters:

    - sink (`Union`[`DummySink`, `NTGraphSink`, `None`])

    - bnode_context (`Optional`[`MutableMapping`[`str`, `BNode`]])

  __annotations__ = {'buffer': 'Optional[str]', 'file': 'Optional[Union[TextIO, codecs.StreamReader]]', 'line': 'Optional[str]', 'sink': 'Union[DummySink, NTGraphSink]'}
  __firstlineno__ = 49
  __module__ = 'rdflib.plugins.parsers.patch'
  __static_attributes__ = ('buffer', 'file', 'line', 'sink', 'skolemize')
  add_or_remove_triple_or_quad(operation, bnode_context=None)
    Parameters:

      bnode_context (`Optional`[`MutableMapping`[`str`, `BNode`]])

    Return type:

      `None`

  add_prefix()
  buffer: Optional[str]
  delete_prefix()
  eat_op(op)
    Parameters:

      op (`str`)

    Return type:

      `None`

  file: Optional[Union[TextIO, codecs.StreamReader]]
  labeled_bnode()
  line: Optional[str]
  nodeid(bnode_context=None)
    Parameters:

      bnode_context (`Optional`[`MutableMapping`[`str`, `BNode`]])

    Return type:

      `Union`[`Literal`[`False`], `BNode`, `URIRef`]

  operation()
    Return type:

      `Operation`

  parse(inputsource, sink, bnode_context=None, skolemize=False, **kwargs)

    Parse inputsource as an RDF Patch file.

    Parameters:

      - inputsource (`InputSource`) – the source of RDF Patch formatted data

      - sink (`Dataset`) – where to send parsed data

      - bnode_context (`Optional`[`MutableMapping`[`str`, `BNode`]]) – a dict mapping blank node identifiers to `BNode` instances. See `W3CNTriplesParser.parse`

      - skolemize (`bool`)

      - kwargs (`Any`)

    Return type:

      `Dataset`

  parsepatch(bnode_context=None)
    Parameters:

      bnode_context (`Optional`[`MutableMapping`[`str`, `BNode`]])

    Return type:

      `None`

  sink: Union[DummySink, NTGraphSink]
  skolemize

## rdflib.plugins.parsers.rdfxml module

An RDF/XML parser for RDFLib

class rdflib.plugins.parsers.rdfxml.BagID(value: str, base: str | None = None)

  Bases: `URIRef`

  __abstractmethods__ = frozenset({})
  __annotations__ = {'__invert__': 'Callable[[URIRef], InvPath]', '__neg__': 'Callable[[URIRef], NegatedPath]', '__or__': 'Callable[[URIRef, Union[URIRef, Path]], AlternativePath]', '__truediv__': 'Callable[[URIRef, Union[URIRef, Path]], SequencePath]'}
  __firstlineno__ = 87
  __init__(val)
  __module__ = 'rdflib.plugins.parsers.rdfxml'
  __slots__ = ['li']
  __static_attributes__ = ('li',)
  li
  next_li()

class rdflib.plugins.parsers.rdfxml.ElementHandler

  Bases: `object`

  __firstlineno__ = 101
  __init__()
  __module__ = 'rdflib.plugins.parsers.rdfxml'
  __slots__ = ['start', 'char', 'end', 'li', 'id', 'base', 'subject', 'predicate', 'object', 'list', 'language', 'datatype', 'declared', 'data']
  __static_attributes__ = ('base', 'char', 'data', 'datatype', 'declared', 'end', 'id', 'language', 'li', 'list', 'object', 'start', 'subject')
  base
  char
  data
  datatype
  declared
  end
  id
  language
  li
  list
  next_li()
  object
  predicate
  start
  subject

class rdflib.plugins.parsers.rdfxml.RDFXMLHandler(store)

  Bases: `ContentHandler`

  Parameters:

    store (`Graph`)

  __firstlineno__ = 139
  __init__(store)
    Parameters:

      store (`Graph`)

  __module__ = 'rdflib.plugins.parsers.rdfxml'
  __static_attributes__ = ('_current_context', '_ns_contexts', 'bnode', 'ids', 'locator', 'preserve_bnode_ids', 'stack', 'store')
  absolutize(uri)
    Parameters:

      uri (`str`)

    Return type:

      `URIRef`

  add_reified(sid, spo)
    Parameters:

      - sid (`Identifier`)

      - spo (`Tuple`[`Node`, `Node`, `Node`])

  characters(content)

    Receive notification of character data.

    The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.

    Parameters:

      content (`str`)

    Return type:

      `None`

  convert(name, qname, attrs)
    Parameters:

      - name (`Tuple`[`Optional`[`str`], `str`])

      - attrs (`AttributesImpl`)

    Return type:

      `Tuple`[`URIRef`, `Dict`[`URIRef`, `str`]]

  property current: ElementHandler | None
  document_element_start(name, qname, attrs)
    Parameters:

      - name (`Tuple`[`str`, `str`])

      - attrs (`AttributesImpl`)

    Return type:

      `None`

  endElementNS(name, qname)

    Signals the end of an element in namespace mode.

    The name parameter contains the name of the element type, just as with the startElementNS event.

    Parameters:

      name (`Tuple`[`Optional`[`str`], `str`])

    Return type:

      `None`

  endPrefixMapping(prefix)

    End the scope of a prefix-URI mapping.

    See startPrefixMapping for details. This event will always occur after the corresponding endElement event, but the order of endPrefixMapping events is not otherwise guaranteed.

    Parameters:

      prefix (`Optional`[`str`])

    Return type:

      `None`

  error(message)
    Parameters:

      message (`str`)

    Return type:

      `NoReturn`

  get_current()
    Return type:

      `Optional`[`ElementHandler`]

  get_next()
    Return type:

      `Optional`[`ElementHandler`]

  get_parent()
    Return type:

      `Optional`[`ElementHandler`]

  ignorableWhitespace(content)

    Receive notification of ignorable whitespace in element content.

    Validating Parsers must use this method to report each chunk of ignorable whitespace (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models.

    SAX parsers may return all contiguous whitespace in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.

    Return type:

      `None`

  list_node_element_end(name, qname)
    Parameters:

      name (`Tuple`[`str`, `str`])

    Return type:

      `None`

  literal_element_char(data)
    Parameters:

      data (`str`)

    Return type:

      `None`

  literal_element_end(name, qname)
    Parameters:

      name (`Tuple`[`str`, `str`])

    Return type:

      `None`

  literal_element_start(name, qname, attrs)
    Parameters:

      - name (`Tuple`[`str`, `str`])

      - attrs (`AttributesImpl`)

    Return type:

      `None`

  property next: ElementHandler | None
  node_element_end(name, qname)
    Parameters:

      name (`Tuple`[`str`, `str`])

    Return type:

      `None`

  node_element_start(name, qname, attrs)
    Parameters:

      - name (`Tuple`[`str`, `str`])

      - attrs (`AttributesImpl`)

    Return type:

      `None`

  property parent: ElementHandler | None
  processingInstruction(target, data)

    Receive notification of a processing instruction.

    The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element.

    A SAX parser should never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.

    Return type:

      `None`

  property_element_char(data)
    Parameters:

      data (`str`)

    Return type:

      `None`

  property_element_end(name, qname)
    Parameters:

      name (`Tuple`[`str`, `str`])

    Return type:

      `None`

  property_element_start(name, qname, attrs)
    Parameters:

      - name (`Tuple`[`str`, `str`])

      - attrs (`AttributesImpl`)

    Return type:

      `None`

  reset()
    Return type:

      `None`

  setDocumentLocator(locator)

    Called by the parser to give the application a locator for locating the origin of document events.

    SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface.

    The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application’s business rules). The information returned by the locator is probably not sufficient for use with a search engine.

    Note that the locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.

    Parameters:

      locator (`Locator`)

  startDocument()

    Receive notification of the beginning of a document.

    The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).

    Return type:

      `None`

  startElementNS(name, qname, attrs)

    Signals the start of an element in namespace mode.

    The name parameter contains the name of the element type as a (uri, localname) tuple, the qname parameter the raw XML 1.0 name used in the source document, and the attrs parameter holds an instance of the Attributes class containing the attributes of the element.

    The uri part of the name tuple is None for elements which have no namespace.

    Parameters:

      - name (`Tuple`[`Optional`[`str`], `str`])

      - attrs (`AttributesImpl`)

    Return type:

      `None`

  startPrefixMapping(prefix, namespace)

    Begin the scope of a prefix-URI Namespace mapping.

    The information from this event is not necessary for normal Namespace processing: the SAX XML reader will automatically replace prefixes for element and attribute names when the http://xml.org/sax/features/namespaces feature is true (the default).

    There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be expanded automatically; the start/endPrefixMapping event supplies the information to the application to expand prefixes in those contexts itself, if necessary.

    Note that start/endPrefixMapping events are not guaranteed to be properly nested relative to each-other: all startPrefixMapping events will occur before the corresponding startElement event, and all endPrefixMapping events will occur after the corresponding endElement event, but their order is not guaranteed.

    Parameters:

      - prefix (`Optional`[`str`])

      - namespace (`str`)

    Return type:

      `None`

class rdflib.plugins.parsers.rdfxml.RDFXMLParser

  Bases: `Parser`

  __annotations__ = {}
  __dict__ = mappingproxy({'__module__': 'rdflib.plugins.parsers.rdfxml', '__firstlineno__': 640, '__init__': <function RDFXMLParser.__init__>, 'parse': <function RDFXMLParser.parse>, '__static_attributes__': ('_parser',), '__dict__': <attribute '__dict__' of 'RDFXMLParser' objects>, '__weakref__': <attribute '__weakref__' of 'RDFXMLParser' objects>, '__doc__': None, '__annotations__': {}})
  __firstlineno__ = 640
  __init__()
  __module__ = 'rdflib.plugins.parsers.rdfxml'
  __static_attributes__ = ('_parser',)
  __weakref__

    list of weak references to the object

  parse(source, sink, **args)
    Parameters:

      - source (`InputSource`)

      - sink (`Graph`)

      - args (`Any`)

    Return type:

      `None`

rdflib.plugins.parsers.rdfxml.create_parser(target, store)
  Parameters:

    - target (`InputSource`)

    - store (`Graph`)

  Return type:

    `XMLReader`

## rdflib.plugins.parsers.trig module

class rdflib.plugins.parsers.trig.TrigParser

  Bases: `Parser`

  An RDFLib parser for TriG

  __annotations__ = {}
  __dict__ = mappingproxy({'__module__': 'rdflib.plugins.parsers.trig', '__firstlineno__': 135, '__doc__': '\nAn RDFLib parser for TriG\n\n', '__init__': <function TrigParser.__init__>, 'parse': <function TrigParser.parse>, '__static_attributes__': (), '__dict__': <attribute '__dict__' of 'TrigParser' objects>, '__weakref__': <attribute '__weakref__' of 'TrigParser' objects>, '__annotations__': {}})
  __firstlineno__ = 135
  __init__()
  __module__ = 'rdflib.plugins.parsers.trig'
  __static_attributes__ = ()
  __weakref__

    list of weak references to the object

  parse(source, graph, encoding='utf-8')
    Parameters:

      - source (`InputSource`)

      - graph (`Graph`)

      - encoding (`str`)

    Return type:

      `None`

class rdflib.plugins.parsers.trig.TrigSinkParser(store, openFormula=None, thisDoc='', baseURI=None, genPrefix='', why=None, turtle=False)

  Bases: `SinkParser`

  Parameters:

    - store (`RDFSink`)

    - openFormula (`Optional`[`Formula`])

    - thisDoc (`str`)

    - baseURI (`Optional`[`str`])

    - genPrefix (`str`)

    - why (`Optional`[`Callable`[[], `None`]])

    - turtle (`bool`)

  __annotations__ = {}
  __firstlineno__ = 15
  __module__ = 'rdflib.plugins.parsers.trig'
  __static_attributes__ = ('_context', '_parentContext', '_reason2')
  directiveOrStatement(argstr, h)
    Parameters:

      - argstr (`str`)

      - h (`int`)

    Return type:

      `int`

  graph(argstr, i)

    Parse trig graph, i.e.

    > <urn:graphname> = { .. triples .. }

    return -1 if it doesn’t look like a graph-decl raise Exception if it looks like a graph, but isn’t.

    Parameters:

      - argstr (`str`)

      - i (`int`)

    Return type:

      `int`

  labelOrSubject(argstr, i, res)
    Parameters:

      - argstr (`str`)

      - i (`int`)

      - res (`MutableSequence`[`Any`])

    Return type:

      `int`

rdflib.plugins.parsers.trig.becauseSubGraph(*args, **kwargs)

## rdflib.plugins.parsers.trix module

A TriX parser for RDFLib

class rdflib.plugins.parsers.trix.TriXHandler(store)

  Bases: `ContentHandler`

  An Sax Handler for TriX. See http://sw.nokia.com/trix/

  Parameters:

    store (`Store`)

  __annotations__ = {'datatype': 'Optional[str]', 'lang': 'Optional[str]'}
  __firstlineno__ = 29
  __init__(store)
    Parameters:

      store (`Store`)

  __module__ = 'rdflib.plugins.parsers.trix'
  __static_attributes__ = ('bnode', 'chars', 'datatype', 'graph', 'lang', 'locator', 'preserve_bnode_ids', 'state', 'store', 'triple')
  characters(content)

    Receive notification of character data.

    The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.

    Parameters:

      content (`str`)

    Return type:

      `None`

  datatype: `Optional`[`str`]
  endElementNS(name, qname)

    Signals the end of an element in namespace mode.

    The name parameter contains the name of the element type, just as with the startElementNS event.

    Parameters:

      name (`Tuple`[`Optional`[`str`], `str`])

    Return type:

      `None`

  endPrefixMapping(prefix)

    End the scope of a prefix-URI mapping.

    See startPrefixMapping for details. This event will always occur after the corresponding endElement event, but the order of endPrefixMapping events is not otherwise guaranteed.

    Parameters:

      prefix (`Optional`[`str`])

    Return type:

      `None`

  error(message)
    Parameters:

      message (`str`)

    Return type:

      `NoReturn`

  get_bnode(label)
    Parameters:

      label (`str`)

    Return type:

      `BNode`

  ignorableWhitespace(content)

    Receive notification of ignorable whitespace in element content.

    Validating Parsers must use this method to report each chunk of ignorable whitespace (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models.

    SAX parsers may return all contiguous whitespace in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.

    Return type:

      `None`

  lang: `Optional`[`str`]
  processingInstruction(target, data)

    Receive notification of a processing instruction.

    The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element.

    A SAX parser should never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.

    Return type:

      `None`

  reset()
    Return type:

      `None`

  setDocumentLocator(locator)

    Called by the parser to give the application a locator for locating the origin of document events.

    SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface.

    The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application’s business rules). The information returned by the locator is probably not sufficient for use with a search engine.

    Note that the locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.

    Parameters:

      locator (`Locator`)

  startDocument()

    Receive notification of the beginning of a document.

    The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).

    Return type:

      `None`

  startElementNS(name, qname, attrs)

    Signals the start of an element in namespace mode.

    The name parameter contains the name of the element type as a (uri, localname) tuple, the qname parameter the raw XML 1.0 name used in the source document, and the attrs parameter holds an instance of the Attributes class containing the attributes of the element.

    The uri part of the name tuple is None for elements which have no namespace.

    Parameters:

      - name (`Tuple`[`Optional`[`str`], `str`])

      - attrs (`AttributesImpl`)

    Return type:

      `None`

  startPrefixMapping(prefix, namespace)

    Begin the scope of a prefix-URI Namespace mapping.

    The information from this event is not necessary for normal Namespace processing: the SAX XML reader will automatically replace prefixes for element and attribute names when the http://xml.org/sax/features/namespaces feature is true (the default).

    There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be expanded automatically; the start/endPrefixMapping event supplies the information to the application to expand prefixes in those contexts itself, if necessary.

    Note that start/endPrefixMapping events are not guaranteed to be properly nested relative to each-other: all startPrefixMapping events will occur before the corresponding startElement event, and all endPrefixMapping events will occur after the corresponding endElement event, but their order is not guaranteed.

    Parameters:

      - prefix (`Optional`[`str`])

      - namespace (`str`)

    Return type:

      `None`

class rdflib.plugins.parsers.trix.TriXParser

  Bases: `Parser`

  A parser for TriX. See http://sw.nokia.com/trix/

  __annotations__ = {}
  __dict__ = mappingproxy({'__module__': 'rdflib.plugins.parsers.trix', '__firstlineno__': 276, '__doc__': 'A parser for TriX. See http://sw.nokia.com/trix/', '__init__': <function TriXParser.__init__>, 'parse': <function TriXParser.parse>, '__static_attributes__': ('_parser',), '__dict__': <attribute '__dict__' of 'TriXParser' objects>, '__weakref__': <attribute '__weakref__' of 'TriXParser' objects>, '__annotations__': {}})
  __firstlineno__ = 276
  __init__()
  __module__ = 'rdflib.plugins.parsers.trix'
  __static_attributes__ = ('_parser',)
  __weakref__

    list of weak references to the object

  parse(source, sink, **args)
    Parameters:

      - source (`InputSource`)

      - sink (`Graph`)

      - args (`Any`)

    Return type:

      `None`

rdflib.plugins.parsers.trix.create_parser(store)
  Parameters:

    store (`Store`)

  Return type:

    `XMLReader`

## Module contents