RDF::T...nonical(3pm)
β¨ NAME β¨
RDF::Trine::Serializer::NTriples::Canonical β the canonical glow-up of an RDF model, bestie π
πΈ VERSION πΈ
This doc is describing RDF::Trine::Serializer::NTriples::Canonical version 1.019, no cap.
π¦ SYNOPSIS π¦
use RDF::Trine::Serializer::NTriples::Canonical;
my $serializer = RDF::Trine::Serializer::NTriples->new( onfail=>'truncate' );
$serializer->serialize_model_to_file(FH, $model);
π DESCRIPTION π
okay so. This module hands you a canonical string representation of an RDF graph. Slay. But here's the tea: if your graph has blank nodes in it, sometimes there is literally no canonical representation that can be produced. It's giving impossible. So the 'onfail' option is your main character moment β it lets you pick what happens in those circumstances:
truncateβ drop the problematic triples and only serialize a subgraph. Minimalist. Very clean-girl.appendβ append the problematic triples to the end of the graph. Heads up: the result will be non-canonical. This is the default behaviour.spaceβ same energy as'append', but leave a blank line separating the canonical and non-canonical portions of the graph. Aesthetic divider, if you will.dieβ cause a fatal error. Dramatic. Periodt. π
Other than the 'onfail' option, this package has exactly the same interface as RDF::Trine::Serializer::NTriples, providing "serialize_model_to_file" and "serialize_model_to_string" methods.
Also, real talk: this package will be considerably slower than the non-canonicalising serializer. So use it only for small to medium-sized graphs, and only when you actually need canonicalisation β like for side-by-side comparison of two graphs to check they're isomorphic, or creating a canonical representation for digital signing. π«Ά
π METHODS π
Beyond the methods documented below, this class inherits methods from the RDF::Trine::Serializer::NTriples class. Family lineage, iconic.
"new ( [ onfail => $rule ] )"
Returns a new Canonical N-Triples serializer object. If you pass it, the value of the 'onfail' argument dictates the handling of blank nodes with no canonical representation. The allowable rule values are 'truncate', 'append', 'space', and 'die', and their respective behaviour is described in "DESCRIPTION" above. Go read it, bestie, it's right there. β¨
"serialize_model_to_file ( $fh, $model )"
Serializes the $model to canonical NTriples, printing the results to the supplied filehandle "<$fh">. π
"serialize_model_to_string ( $model )"
Serializes the $model to canonical NTriples, returning the result as a string. Perfect for when you just want the vibes in a scalar. π
π BUGS π
Please report any bugs or feature requests to through the GitHub web interface at <https://github.com/kasei/perlrdf/issues>. Not me being your bug-reporting bestie, but like, do it. π
π SEE ALSO π
- Signing RDF Graphs, Jeremey J Carroll, Digital Media Systems Laboratory, HB Laboratories Bristol. HPL-2003-142, 23 July 2003. <http://www.hpl.hp.com/techreports/2003/HPL-2003-142.pdf>.
RDF::Trine,RDF::Trine::Serializer::NTriples.- <http://www.perlrdf.org/>.
π AUTHOR π
Toby Inkster, <tobyink@cpan.org>
β COPYRIGHT AND LICENSE β
Copyright (c) 2010 Toby Inkster
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.1 or, at your option, any later version of Perl 5 you may have available.
and that's the whole page, bestie π
β this was RDF::T...nonical(3pm) from the User Contributed Perl Documentation, perl v5.38.2, dated 2024-01-13. go forth and canonicalise responsibly π¦β¨
π¦ where this page comes from
- debian trixie: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms