RDF::T...nonical(3pm)

πŸ“¦
version 1.019 Β· 7 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ 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 🌈


πŸ’– AUTHOR πŸ’–

Toby Inkster, <tobyink@cpan.org>


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