RdfCore.withCodecs constructor
- List<
RdfGraphCodec> codecs = const [], - List<
RdfDatasetCodec> datasetCodecs = const [],
Creates a new RDF library instance with only the provided codecs registered
This convenience constructor sets up an RDF library with the specified codecs registered. It allows for easy customization of the library's capabilities. For example, if you need to support Turtle with certain parsing flags because your turtle documents are not fully compliant with the standard.
The codecs
parameter is a list of graph codecs to register in the RDF library.
The datasetCodecs
parameter is a list of dataset codecs to register in the RDF library.
Example:
final namespaceMappings = RdfNamespaceMappings();
final turtle = TurtleCodec(
namespaceMappings: namespaceMappings,
parsingFlags: {TurtleParsingFlag.allowMissingFinalDot});
final rdf = RdfCore.withCodecs(codecs: [turtle]);
final graph = rdf.decode(turtleData, contentType: 'text/turtle');
Implementation
factory RdfCore.withCodecs(
{List<RdfGraphCodec> codecs = const [],
List<RdfDatasetCodec> datasetCodecs = const []}) {
final registry = RdfCodecRegistry(codecs);
final datasetRegistry = RdfDatasetCodecRegistry(datasetCodecs);
return RdfCore(registry: registry, datasetRegistry: datasetRegistry);
}