RdfCore.withCodecs constructor
- List<
RdfGraphCodec> codecs = 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 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 []}) {
final registry = RdfCodecRegistry();
for (final codec in codecs) {
registry.registerGraphCodec(codec);
}
return RdfCore(registry: registry);
}