convert method
Decodes an RDF dataset document and returns an RDF dataset
This method transforms a textual RDF dataset document into a structured RdfDataset object
containing quads parsed from the input and organized into default and named graphs.
It implements the convert method from the Converter interface.
Parameters:
inputThe RDF dataset document to decode, as a string.documentUrlThe absolute URL of the document, used for resolving relative IRIs. If not provided, relative IRIs will be kept as-is or handled according to format-specific rules.
Returns:
- An
RdfDatasetcontaining the quads parsed from the input, organized into graphs.
The specific decoding behavior depends on the implementation of this interface, which will handle format-specific details like prefix resolution, blank node handling, and graph context management, etc.
May throw format-specific parsing exceptions if the input is malformed.
Implementation
@override
RdfDataset convert(String input, {String? documentUrl}) {
final parsedInput = parseJsonValueOrThrow(input, format: _format);
final effectiveInput = _options.expandContext == null
? input
: jsonEncode(_applyExpandContext(parsedInput, _options.expandContext!));
final parser = JsonLdParser(
effectiveInput,
baseUri: _options.baseUri ?? documentUrl,
iriTermFactory: _iriTermFactory,
format: _format,
rdfDirection: _options.rdfDirection,
processingMode: _options.processingMode,
contextDocumentProvider: _options.contextDocumentProvider,
skipInvalidRdfTerms: _options.skipInvalidRdfTerms,
);
return RdfDataset.fromQuads(parser.parse());
}