generateMissingPrefixes property

bool generateMissingPrefixes
final

Controls automatic generation of namespace prefixes for IRIs without matching prefixes.

When set to true (default), the encoder will automatically generate namespace prefixes for IRIs that don't have a matching prefix in either the custom prefixes or the standard namespace mappings.

The prefix generation process:

  1. Attempts to extract a meaningful namespace from the IRI (splitting at '/' or '#')
  2. Skips IRIs with only protocol specifiers (e.g., "http://")
  3. Only generates prefixes for namespaces ending with '/' or '#' (proper RDF namespace delimiters)
  4. Uses RdfNamespaceMappings.getOrGeneratePrefix to create a compact, unique prefix

Setting this to false will result in all IRIs without matching prefixes being written as full IRIs in angle brackets (e.g., <http://example.org/term>).

This option is particularly useful for:

  • Reducing the verbosity of the Turtle output
  • Making the serialized data more human-readable
  • Automatically handling unknown namespaces without manual prefix declaration

Implementation

final bool generateMissingPrefixes;