Usage

Although the package is called owl-cli, the command you invoke is called owl.

You can call the built-in overview of commands and arguments via --help:

Usage:

Usage: owl [-v] [--help] [--version] [COMMAND]

Description:

Command line tool for ontology engineering

Options:
      --help      Show short help
  -v, --verbose   Specify multiple -v options to increase verbosity,
                  e.g. use `-v`, `-vv` or `-vvv` for more details
      --version   Show current version
Commands:
  ...

Other than the general help, you give one argument, the command, which will take its own arguments, for example:

owl diagram --format png

Commands that take ontology files as an input support all formats that are supported by OWL API, notably RDF/Turtle, RDF/XML, OWL/XML and OWL Functional Syntax.

diagram Command

The diagram command takes an OWL ontology as input and generates an automatically layouted diagram for it in the SVG or PNG format. This is implemented by mapping the ontology’s axioms into a graph description in the Graphviz language, which is passed to its dot layouting engine. Attributes such as fonts can be customized using arguments.

As no standardized graphical notation for OWL exists, the diagram notation used here is described in detail on a separate page: Diagram Notation.

General Usage

General usage: owl diagram [options] input [output], where input can be either an ontology file or - (which means: read from standard in) and output can be either an ontology file or - (which means: write to standard out). If output is not given, the output filename is the input filename with its file extension changed, e.g. myontology.ttl → myontology.svg. If input is - and output is not given, the output is set to standard out.

Options

Table 1. diagram Command Options
Option Description Default Notes

--direction

Diagram layout direction

left_to_right

Possible values: [top_to_bottom, left_to_right]

--dotbinary

Path to dot binary

dot

By default, dot is searched for in your $PATH

--fontname

Default font

Verdana

--fontsize

Default font size

12

--format

Output file format

svg

Possible values: [png, svg]

--nodefontname

Font for nodes

Verdana

--nodefontsize

Font size for nodes

Verdana

--nodemargin

The margin to render inside of nodes

0.05,0.0

See the Graphviz documentation for more information

--nodeshape

Node shape

box

See the Graphviz documentation for more information

--nodestyle

Node style

rounded

See the Graphviz documentation for more information

--fgcolor

Color for boxes, fonts and edges

white

See the Graphviz documentation for more information

--bgcolor

Background color for the generated diagram

white

See the Graphviz documentation for more information

Example Usage

Simple invocation with default arguments:

# Will create myontology.svg
owl diagram myontology.ttl

Invocation where the output is specified as standard out and piped to convert to create a different format:

owl diagram myontology.ttl - | convert - myontology.jpg

Invocation where an ontology is downloaded, some terms are filtered and then piped to owl diagram:

curl http://www.ontologydesignpatterns.org/cp/owl/partof.owl | \
grep -v 'comment|cpannotation|versionInfo' | owl diagram - partof.svg

write Command

General Usage

The write command takes any RDF file in RDF/Turtle, RDF/XML, RDF N-Triples or N3 format as input and writes it out in any of those formats. When writing RDF/Turtle, the formatting of the resulting output can be configured extensively, as this makes use of the turtle-formatter library.

General usage: owl write [options] input [output], where input can be either an RDF file, a URL (starting with http or https) or - (which means: read from standard in) and output can be either an RDF file or - (which means: write to standard out). If output is not given, the output filename is the input filename with its file extension changed, e.g. myontology.nt → myontology.ttl. If input is - or a URL and output is not given, the output is set to standard out.

Options

Table 2. write Command Options
Option Description Default Notes

-o, --output

Output file format

turtle

Possible values: [turtle, rdfxml, ntriple, n3]

-i, --input

Input file format

turtle

Possible values: [turtle, rdfxml, ntriple, n3]

-p, --prefix

Prefix with corresponding URI to add as @prefix when serializing Turtle.

This can be given multiple times, for multiple prefixes. You can specify a well-known prefix (currently: rdf, rdfs, xsd, owl, dcterms), e.g. -prdf or --prefix=rdf or any other prefix with its url: -pfoo=http://example.com/ or --prefix=foo=http://example.com/. To set the empty prefix, use -p==http://example.com/ or --prefix==http://example.com.

--prefixAlign

Alignment of @prefix statements

off

Possible values: [left, off, right]

--encoding

Output encoding

utf_8

Possible values: [latin1, utf_16_be, utf_16_le, utf_8, utf_8_bom]

--doubleFormat

Defines how double numbers are formatted

0.####E0

See here for more information on the format

--endOfLine

End of line style

lf

Possible values: [cr, crlf, lf]

--indent

Indent style

space

Possible values: [tab, space]. Note that when choosing tab, alignPredicates and alignObjects are automatically treated as false.

--firstPredicateInNewLine

Write first predicate in new line of block

Switched off by default

--writeRdfType

Write rdf:type instead of a

Switched off by default

--useCommaByDefault

Use commas for multiple objects

Switched off by default

--noCommaForPredicate

Use no commas for multiple objects for this predicate

This can be given multiple times.

--useLongLiterals

Use long form for literals, e.g. "5"^^xsd:integer instead of 5

Switched off by default

--alignObjects

Align objects for same predicates

Switched off by default

--alignPredicates

Align predicates for same subjects

Switched off by default

--continuationIndentSize

Indentation size after forced line wraps

4

--doNotInsertFinalNewline

Do not insert newline at end of file

Switched off by default

--indentSize

Indentation size in spaces

2

--keepUnusedPrefixes

Keeps prefixes that are not part of any statement

Switched off by default

--prefixOrder

Sort order for prefixes (if they appear in a model)

[rdf, rdfs, xsd, owl]

Add this switch multiple times, once for each prefix, in the desired order

--subjectOrder

Sort order for subjects by type (if they appear in a model)

[rdfs:Class, owl:Ontology, owl:Class, rdf:Property, owl:ObjectProperty, owl:DatatypeProperty, owl:AnnotationProperty, owl:NamedIndividual, owl:AllDifferent, owl:Axiom]

Add this switch multiple times, once for each subject type, in the desired order

--predicateOrder

Sort order for predicates (if they appear on a subject)

[rdf:type, rdfs:label, rdfs:comment, dcterms:description]

Add this switch multiple times, once for each predicate, in the desired order

--objectOrder

Sort order for objects

[owl:NamedIndividual, owl:ObjectProperty, owl:DatatypeProperty, owl:AnnotationProperty, owl:FunctionalProperty, owl:InverseFunctionalProperty, owl:TransitiveProperty, owl:SymmetricProperty, owl:AsymmetricProperty, owl:ReflexiveProperty, owl:IrreflexiveProperty]

Add this switch multiple times, once for each object type, in the desired order

--anonymousNodeIdPattern

Name pattern for blank node IDs

_:gen0

A 0 inside the pattern will be replace with the index of the respective blank node

Example Usage

Simple invocation with default arguments:

# Read myontology.ttl and print it in formatted Turtle format
owl write myontology.ttl

# Read myontology.owl in RDF/XML format and print it in formatted Turtle format, writing output.ttl
owl write -i rdfxml myontology.owl output.ttl

# Read myontology.n3 in N3 format and print it in formatted Turtle format to stdout
owl write -i n3 myontology.n3

# Read myontology.nt in N-Triples format and print it in RDF/XML format to stdout
owl write -i ntriple -o rdfxml myontology.nt

Read an N-Triples file and write formatted Turtle, while also configuring which prefixes should be used:

owl write -prdf -powl -pxsd -p'ex=http://example.com#' -i ntriple myontology.nt

Read a Turtle file and print it out, while configuring the output’s formatting and prefix order:

owl write --indentSize 4 --writeRdfType --prefixOrder owl --prefixOrder rdf myontology.turtle

Read a remote ontology in RDF/XML format and print it in formatted Turtle format:

owl write -i rdfxml 'http://www.ontologydesignpatterns.org/cp/owl/partof.owl'

infer Command

General Usage

The infer command takes an OWL ontology as input and performs OWL 2 DL reasoning on it. Reasoning is done using the Openllet reasoner.

General usage: owl infer input [output], where input can be either an ontology file, an URL or - (which means: read from standard in) and output can be either an ontology file or - (which means: write to standard out). If input is a file and output is not given, the input file is overwritten with the inferenced result. If input is - and output is not given, the output is set to standard out.

Example Usage

Perform reasoning on the input ontology and write results to stdout:

owl infer ontology.ttl -