convert method

  1. @override
RdfGraph convert(
  1. String input, {
  2. String? documentUrl,
})
override

Decodes a Turtle document into an RDF graph

This method parses a string containing Turtle syntax into an RDF graph structure. It delegates to the internal TurtleParser implementation to handle the actual parsing.

Parameters:

  • input The Turtle document to decode as a string.
  • documentUrl Optional base URI for the document, used for resolving relative IRIs in the Turtle content. If not provided, relative IRIs will result in an error unless there's a @base directive in the content.

Returns:

  • An RdfGraph containing the parsed triples.

Throws:

Implementation

@override
RdfGraph convert(String input, {String? documentUrl}) {
  final dataset = _decoder.convert(input, documentUrl: documentUrl);
  if (dataset.namedGraphs.isNotEmpty) {
    throw RdfSyntaxException(
      'Turtle documents cannot contain named graphs',
      format: _format,
    );
  }
  return dataset.defaultGraph;
}