IF Commons GitHub

integrations/pure/export-rdfxml

The RDF/XML writer (commons 0019-mizan-integrations FR-016): an ontology's triples as RDF/XML 1.1, as text, in one canonical form, so that a tool that reads only RDF/XML (the OWL API, Protege, older triple stores) reads the same graph as the Turtle, and a generated file can be checked for staleness.

The form is flat: one rdf:Description for each subject, in the order of their N-Triples terms, its rdf:type first and its other predicates by IRI, each predicate's objects in the order of their N-Triples terms (the order the kernel's Turtle writer uses), so the same triples give the same bytes whatever the order they were stated in. A predicate's IRI is split into a namespace and an XML name: at a declared prefix where one fits, and otherwise after the last character that an XML name may not hold, the namespace then getting a prefix ns1, ns2 in the order of the namespaces' IRIs. A plain string (an xsd:string) has no rdf:datatype; a string in a language has xml:lang; a blank node is an rdf:nodeID. What XML 1.0 cannot say is a finding, never silently changed: a predicate with no XML name (its IRI ends in a digit or in a character an XML name may not hold) and a control character in a literal.

import { exportRdfXml } from "./export-rdfxml.ts";
exportRdfXml({ prefixes: [], triples: [] }); // { kind: "ok", value: '<?xml version="1.0" encoding="UTF-8"?>\n<rdf:RDF xmlns:rdf="...">\n</rdf:RDF>\n' }

Source: commons/mizan/src/integrations/pure/export-rdfxml.ts

1 of 4 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

integrations.RdfXmlDocumenttypeno test imports it
type RdfXmlDocument = {
  readonly comments?: readonly string[];
  readonly prefixes: readonly Namespace[];
  readonly triples: readonly Triple[];
};

What the document is made of: the prefixes it may declare, its triples and the comment lines of its head.

integrations.exportRdfXmlfunctionno test imports it
function exportRdfXml(doc: RdfXmlDocument): Result<string, readonly string[]>

Triples as RDF/XML in its canonical form, or what XML cannot say of them, one sentence each.

RdfXmlDocumenttypeno test imports it
type RdfXmlDocument = {
  readonly comments?: readonly string[];
  readonly prefixes: readonly Namespace[];
  readonly triples: readonly Triple[];
};

What the document is made of: the prefixes it may declare, its triples and the comment lines of its head.

exportRdfXmlfunction
function exportRdfXml(doc: RdfXmlDocument): Result<string, readonly string[]>

Triples as RDF/XML in its canonical form, or what XML cannot say of them, one sentence each.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.