Textual graph format is used to write ontologies in Simantics platform. [Graph Compiler](GraphCompiler.md) translates textual format to binary [Transferable graphs](TransferableGraph.md) that can be then imported to Simantics database. ## Syntax ### Indentation The graph format is indentation based. The amount of indentation can be freely chosen, but it has to be consistent with the previous lines. The lines can be indendented only with spaces. Tabulators are not allowed. Both C and C++ style comments are allowed. If a C style comment begins a line, there must not be anything else in the line after the comment, otherwise the amount of indentation would be then unclear. Text in parenthesis (), [] and {} can be freely indented. ### Statements A graph file describes a collection of statements. One statement is written as: Subject Predicate Object and represented graphically as ![Subject Predicate Object](Images/SubPreObj.png) Statements with the same subject can be written in the same line Subject Predicate1 Object1 Predicate2 Object2 Predicate3 Object3 or with multiple indented lines ~~~ Subject Predicate1 Object1 Predicate2 Object2 Predicate3 Object3 ~~~ These forms can also be combined ~~~ Subject Predicate1 Object1 Predicate2 Object2 Predicate3 Object3 Predicate4 Object4 ~~~ Statements with the same subject and predicate can be abbreviated as ~~~ Subject Predicate Object1 Object2 Object3 ~~~ In this case, there must be no objects in the same line with the predicate. Statements concerning the object of another statement can be written after the object if the object is not in the same line with the original subject. The following texts describe the same graph: ![Subject Predicate Object Chain](Images/SubPreObj_chain_01.png) ~~~ Subject Predicate1 Object1 Object1 Predicate2 Object2 Subject Predicate1 Object1 Predicate2 Object2 Subject Predicate1 Object1 Predicate2 Object2 Subject Predicate1 Object1 Predicate2 Object2 Subject Predicate1 Object1 Predicate2 Object2 Subject Predicate1 Object1 Predicate2 Object2 ~~~ ### Resources Subject, predicate, and object of a statement are all resources. Predicates and other resources are handled little differently. A resource can be in one of the following forms: * Identifier * URI * Reference to a child of another resource * Literal value (not allowed as a predicate) * Data type (not allowed as a predicate) * A special relation: =, -characters and must begin with "http:". For example ``. The syntax of literal values and data types is specified in [[Databoard Specification#Value Text Notation]]. Variants and tagged values (of some union type) must be enclosed in parenthesis. A data type must be prefixed with $ and union types and array types must be enclosed in parenthesis. References are used to refer URIs: If identifier A referes to , then A.Foo referes to . If URI contains non-alphanumerical characters, the name can be enclosed in double quotes. For example A."Cul-de-sac" refers to . Special relations are abbreviations of some Layer0 relations: {| |- |width="40px" align="center"| = | http://www.simantics.org/Layer0-1.0/Equals |- |width="40px" align="center"| http://www.simantics.org/Layer0-1.0/Inherits |- |width="40px" align="center"| http://www.simantics.org/Layer0-1.0/SubrelationOf |- |width="40px" align="center"| : | http://www.simantics.org/Layer0-1.0/InstanceOf |- |width="40px" align="center"| >-- | http://www.simantics.org/Layer0-1.0/IsDomainOf |- |width="40px" align="center"| <-- | http://www.simantics.org/Layer0-1.0/HasDomain |- |width="40px" align="center"| --> | http://www.simantics.org/Layer0-1.0/HasRange |- |width="40px" align="center"| ==> | http://www.simantics.org/Layer0-1.0/RequiresValueType |} ### Templates A template is a parametrized graph that can be defined and instantiated. A template is defines as follows: ~~~ : L0.Template @template