.Dd April 14, 2021 .Dt SERDI 1 .Os Serd 0.30.11 .Sh NAME .Nm serdi .Nd read, filter, transform, and write RDF data .Sh SYNOPSIS .Nm serdi .Op Fl Cfhmqv .Op Fl F Ar pattern | Fl G Ar pattern .Op Fl I Ar base .Op Fl b Ar bytes .Op Fl c Ar prefix .Op Fl i Ar syntax .Op Fl k Ar bytes .Op Fl o Ar syntax .Op Fl p Ar prefix .Op Fl r Ar root .Op Fl s Ar string .Op Fl w Ar filename .Ar input ... .Sh DESCRIPTION .Nm is a fast command-line utility for processing RDF data. It reads one or more documents and writes the data again, possibly transformed and/or in a different syntax. By default, the input syntax is guessed from the file extension, and output is written in NTriples or NQuads. .Pp .Nm can be used to check for syntax errors, convert from one syntax to another, pretty-print documents, or transform URIs and blank node IDs. .Pp The options are as follows: .Pp .Bl -tag -compact -width 3n .It Fl C Convert literals to canonical form. Literals with supported XSD datatypes will be parsed and rewritten canonically. All numeric datatypes are supported, as well as .Vt boolean , .Vt duration , .Vt datetime , .Vt time , .Vt hexBinary , and .Vt base64Binary . .Pp .It Fl F Ar pattern Filter out statements that match .Ar pattern . The pattern must be a single statement written in NTriples or NQuads, with variables like .Dq ?name for wildcards. The names of variables in the pattern are insignificant. .Pp .It Fl G Ar pattern Only include statements that match .Ar pattern . This option is like .Fl p but inverted, so that only matching statements are included, like grep. .Pp .It Fl I Ar base Input base URI. Relative URI references in the input will be resolved against this. When the input is a file, the URI of the file is automatically used as the base URI. This option can be used to override that, or to provide a base URI for input from stdin or a string. .Pp .It Fl b Ar bytes I/O block size. This is the number of bytes in a file that will be read or written at once. The default is 4096, which should perform well in most cases. Note that this only applies to files, standard input and output are always processed one byte at a time. .Pp .It Fl c Ar prefix Chop .Ar prefix from matching blank node IDs. This is the inverse of .Fl p . .Pp .It Fl f Fast and loose mode. This disables shortening URIs into prefixed names or relative URI references. If the model is enabled, then this writes the model quickly in sorted order. Note that doing so with TriG or Turtle may make the output ugly, since blank nodes will not be inlined. .Pp .It Fl h Print the command line options. .Pp .It Fl i Ar syntax Set an input syntax option. May be given multiple times. The case-insensitive .Ar syntax can be either a syntax name or an input syntax option. The supported syntaxes are .Dq NQuads , .Dq NTriples , .Dq TriG , and .Dq Turtle . .Pp The supported input options are: .Pp .Bl -tag -width "QvariablesQ" -compact -offset indent .It Dq lax Tolerate invalid input where possible. Warnings will be printed on syntax errors, but parsing will attempt to continue. Note that data may be lost when using this option! .Pp .It Dq variables Support parsing variable nodes. Variables can be written in SPARQL style, for example .Dq ?var or .Dq $var . .Pp .It Dq verbatim Normally, the reader expands all relative URIs, and may adjust blank node labels to avoid clashing with generated ones. This flag disables all of this processing, so that URI references and blank nodes are passed to the sink exactly as they are in the input. Note that this does not apply to CURIEs, since serd deliberately does not have a way to represent CURIE nodes. A bad namespace prefix is considered a syntax error. .El .Pp .It Fl k Ar bytes Parser stack size. For performance and security reasons, parsing is performed with a fixed-size stack. By default, the stack is 4096 bytes, which should be sufficient for most data. If some data has very deep nesting or very large literal values, it may exceed the default amount of space, and this option can be used to increase it and allow the document to be parsed successfully. .Pp .It Fl m Build a model in memory. This loads all of the input into memory before writing the output. This will reorder statements and eliminate duplicates, at the cost of performance and memory consumption. When writing TriG or Turtle, this may enable better pretty-printing with more inline descriptions. .Pp .It Fl o Ar syntax Set an output syntax option. May be given multiple times. The case-insensitive .Ar syntax can be either a syntax name or an output syntax option. The supported syntaxes are .Dq empty , .Dq NQuads , .Dq NTriples , .Dq TriG , and .Dq Turtle . .Pp The supported output options are: .Pp .Bl -tag -width "QverbatimQ" -compact -offset indent .It Dq ascii Escape all non-ASCII characters. .Pp .It Dq expanded Write expanded URIs instead of prefixed names. .Pp .It Dq verbatim Write URI references exactly as they are in the input. This avoids resolving URIs and making them relative to the output base URI. .Pp .It Dq terse Write terser output without newlines. .Pp .It Dq lax Tolerate invalid UTF-8 by writing the replacement character when necessary. Note that data may be lost when using this option! .El .Pp .It Fl p Ar prefix Add .Ar prefix to blank node IDs. This can be used to avoid clashes between blank node IDs in input documents. .Pp .It Fl q Suppress all output except data. .Pp .It Fl r Ar root Keep relative URIs within a .Ar root URI. This will avoid creating any relative URI references with leading path segments like .Dq ../ that enter a parent of .Ar root . .Pp .It Fl s Ar string Parse .Ar string as input. .Pp .It Fl v Display version information and exit. .Pp .It Fl w Ar filename Write output to the given .Ar filename instead of stdout. .El .Sh EXIT STATUS .Nm exits with a status of 0, or non-zero if an error occured. .Sh EXAMPLES To pretty-print a document: .Pp .Dl $ serdi -o turtle file.ttl > out.ttl .Pp To print any errors: .Pp .Dl $ serdi file.ttl > /dev/null .Pp To remove any rdf:type properties: .Pp .Dl $ serdi -F \(dq?s ?o .\(dq file.ttl .Pp To include only rdf:type properties: .Pp .Dl $ serdi -G \(dq?s ?o .\(dq file.ttl .Sh SEE ALSO .Bl -item -compact .It .Lk http://drobilla.net/software/serd/ .It .Lk http://gitlab.com/drobilla/serd/ .El .Sh STANDARDS .Bl -item .It .Rs .%A W3C .%T RDF 1.1 NQuads .%D February 2014 .Re .Lk https://www.w3.org/TR/n-quads/ .It .Rs .%A W3C .%D February 2014 .%T RDF 1.1 NTriples .Re .Lk https://www.w3.org/TR/n-triples/ .It .Rs .%A W3C .%T RDF 1.1 TriG .%D February 2014 .Re .Lk https://www.w3.org/TR/trig/ .It .Rs .%A W3C .%D February 2014 .%T RDF 1.1 Turtle .Re .Lk https://www.w3.org/TR/turtle/ .El .Sh AUTHORS .Nm is a part of serd, by .An David Robillard .Mt d@drobilla.net .