Description
N-Triples and N-Quads serialization.
This is the crate's interchange form: it is what round-trip tests compare, what a differential harness hands to another implementation, and the shape canonicalization emits. It is deliberately the dullest writer here -- one statement per line, no abbreviation, no prefixes.
Put_Quad
procedure Put_Quad
(Value : Quads.Quad;
Buffer : in out String;
Last : in out Natural;
Style : String_Datatype_Style := Explicit_Datatype)
Serialize one statement as a line, including the trailing " ." but not a line terminator. The graph is written only when it is not the default graph, which is what distinguishes N-Quads from N-Triples.
Parameters
- Value
Quad to serialize
Statement to write
- Buffer
Destination, written from Last + 1 onwards
- Last
Index of the last character written, extended in place
- Style
How to render an xsd:string datatype @return The statement in N-Quads syntax Append the N-Quads form of Value to Buffer, moving Last past what was written.
The function form below builds the whole statement as one string before returning it, which a caller writing to a file then copies again. This writes into the caller's own buffer, so a conversion that streams pays for neither.
How to write an xsd:string datatype
Raised exceptions
- Constraint_Error
Buffer has no room for the statement
String_Datatype_Style
type String_Datatype_Style is (Explicit_Datatype, Implicit_Datatype);
How to serialize a literal whose datatype is xsd:string.
Enumeration literals
- Explicit_Datatype
Always write ^^<...#string>
- Implicit_Datatype
Write the bare quoted form
Write_Graph_Name
function Write_Graph_Name (Value : Quads.Graph_Name) return String
Serialize a graph name, for callers building their own output.
Parameters
- Value
Graph name to serialize
Return value
The graph name in N-Quads syntax, empty for the default graph
Write_Quad
function Write_Quad
(Value : Quads.Quad;
Style : String_Datatype_Style := Explicit_Datatype) return String
Parameters
- Value
- Style
Return value
Write_Term
function Write_Term
(Value : Terms.Term;
Style : String_Datatype_Style := Explicit_Datatype) return String
Serialize one term.
RDF 1.1 makes "abc" and "abc"^^xsd:string the same term, so both styles denote it; they differ only in bytes. Explicit is the default because it is unambiguous to read, and implicit exists because canonical forms and other implementations commonly omit it, and a byte comparison against them has to agree.
Parameters
- Value
Term to serialize
- Style
How to render an xsd:string datatype
Return value
The term in N-Triples syntax