modules/rdf/serializer/plan.zzm

rdf-0.0.3 documentation

NAME

rdf/serializer/plan - Shared RDF serializer graph planning.

SYNOPSIS

  from rdf/serializer/plan import rdf_serializer_plan;

  let plan := rdf_serializer_plan(quads);
  for ( let bunch in plan{bunches} ) {
      say bunch{subject}.to_String();
  }

DESCRIPTION

This module prepares RDF graph-shaped data for human-oriented serializers. It groups triples by subject, identifies blank nodes which can safely be nested as property lists, detects RDF collection heads, and sorts subject and predicate groups using the same broad priorities as RDF::TrineX::Serializer::MockTurtleSoup.

The resulting plan is intentionally serializer-neutral so Turtle and RDF/XML serializers can share the same decisions about blank-node nesting, list-cell suppression, and subject/predicate ordering.

EXPORTS

Functions

  • rdf_serializer_plan(Array quads, Dict options := {})

    Returns a dictionary containing bunches and bunch_map. Each bunch is a dictionary with subject, triples, inline, list, inlist, and isturd fields. Named graph quads are ignored because Turtle and RDF/XML are RDF graph syntaxes rather than dataset syntaxes.

  • rdf_serializer_sort_triples(Array triples, Dict options := {})

    Returns triples sorted with rdf:type first, labelling predicates second, and remaining predicates by serializer display key then object identity. The labelling option is an array of predicate IRIs which should be considered label predicates.

COPYRIGHT AND LICENCE

rdf/serializer/plan is copyright Toby Inkster.

It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.