Automatic transformation of XML namespaces/RDF grammar trees
An implementation provides a directed acyclic graph of RDF classes. An object is said to belong to a class when it either has
a relation to this class or to any of its subclasses.
The below describes grammar and meaning of an RDF file, as it should be used in our software.
After reading an RDF file, some information (namespaces, transformations, etc.) is extracted from it, as the RDF file is considered as an instance of the below defined grammar.
Remark: The below grammar always applies to one RDF file, it never applies to several RDF files merged.
Rationale: If the data were merged on loading every new RDF file, this would possibly create contradictory (not conforming to the grammar described below) information when loading the next RDF file.
Cardinality of a predicate P for a subject S is the number of objects for these predicate and subject. We will denote cardinalities as:
- 0..1 (a number equal to 0 or 1)
- 1..1 (exactly 1)
- 0..* (any natural number)
- 1..* (any positive natural number)
It should be specified the set of all RDF grammar trees (grammar forest).
I will denote this as a tree: The root node is a class IRI. The rest nodes are interleaving predicates together with cardinalities and nodes.
I will write additional requirements for a node in parentheses. Specifically if a node must be of an XML Scheme datatype, I will write the type in brackets.
I will call such trees format trees.
Note that subjects may have additional predicates not described in the format trees. For example (below) objects of class
:Namespace may have predicates
A node conforms to grammar if it passes through the recursive descent parser for this grammar. However, non-passing subnodes may not cause a fatal error of their parent node, such nodes are just ignored.
Rationale: We need recursive descent because this is the only way to make future compatibility with XML Schema types.
It is recommended to produce a warning or fatal error (that is ignore the RDF file) if a cardinality of a predicate is not equal the cardinality of the corresponding grammar node.
A node X for which it's specified in the RDF file that it is of class ROOT, where ROOT is the root of a grammar tree in the forest, is conforms to the grammar, if the triples starting at the subject X conform to the cardinality constrains and so it is recursively for the subtrees. Furthermore, it is valid if it also conforms to additional validity constrains.
An RDF file conforms to grammar tree if for every node X of this file, such that X belongs to ROOT where ROOT is the root of the grammar tree, conforms to the grammar.
An RDF file conforms to grammar forest if and only if it conforms to every grammar tree in the grammar forest.
RDF file is valid (for the purposes of this specification) if it conforms to grammar forest and all additional validity constraints defined in this specification.
See below for examples.
Extracted RDF data will be named in this specification as indicated by italicized text in parentheses.