treetriples is an XML-based RDF syntax. It aims to take the best qualities from existing syntaxes:
treetriples uses the following XML namespace for the elements defined by this specification:
http://djpowell.net/schemas/treetriples/1/
Note that the prefix used in this document is ‘tt’, but any prefix may be used, or documents may place treetriples elements into the default namespace.
In this document, where XML fragments are shown, XML namespace prefixes should be interpreted as if the following namespace mappings were in scope:
Prefix | URI |
---|---|
tt | http://djpowell.net/schemas/treetriples/1/ |
rdf | http://www.w3.org/1999/02/22-rdf-syntax-ns# |
rdfs | http://www.w3.org/2000/01/rdf-schema# |
dc | http://purl.org/dc/elements/1.1/ |
ex | http://example.com/vocab# |
rss | http://purl.org/rss/1.0/ |
foaf | http://xmlns.com/foaf/0.1/ |
html | http://www.w3.org/1999/xhtml |
In this document, where an XML entity reference from the list of prefixes above is used, it should also be interpreted as if it had the corresponding URI value from the table above.
This document uses the term URI [RFC3986] to refer to what the RDF Concepts Recommendation [RDF] refers to as an "RDF URI Reference" [RDFURI]. This is basically an absolute IRI with an optional fragment part.
Below is an example of a treetriples document:
<!DOCTYPE rdf [ <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <!ENTITY ex "http://www.example.com/vocab#"> ]> <rdf xmlns="http://djpowell.net/schemas/treetriples/1/"> <s id="http://www.example.com/thing/1/"> <p id="&ex;bag"> <o id="_:b1" /> </p> <p id="&ex;bnode"> <o id="_:b2" /> </p> <p id="&ex;lang"> <o xml:lang="en">English Literal</o> </p> <p id="&ex;list"> <o id="_:b0" /> </p> <p id="&ex;plain"> <o>Plain Literal</o> </p> <p id="&ex;uri"> <o id="http://www.example.com/thing/4/" /> </p> <p id="&ex;xml"> <o parse="xml"> Below is: <html:div xmlns:html="http://www.w3.org/1999/xhtml">Some <html:b>mixed</html:b> content.</html:div> </o> </p> </s> <s id="_:b2"> <p id="&rdf;type"> <o id="&ex;Type"></o> </p> <p id="&ex;number"> <o datatype="http://www.w3.org/2001/XMLSchema#int">7</o> </p> </s> <d parse="list"> <o id="http://www.example.com/thing/2/" listId="_:b0" /> <o id="http://www.example.com/thing/3/" /> </d> <d parse="bag" id="_:b1"> <o>1</o> <o>2</o> <o>3</o> </d> </rdf>
The equivalent in RDF/XML is:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ex="http://www.example.com/vocab#" xmlns:html="http://www.w3.org/1999/xhtml"> <rdf:Description rdf:about="http://www.example.com/thing/1/"> <ex:plain>Plain Literal</ex:plain> <ex:lang xml:lang="en">English Literal</ex:lang> <ex:bag> <rdf:Bag> <rdf:li>1</rdf:li> <rdf:li>2</rdf:li> <rdf:li>3</rdf:li> </rdf:Bag> </ex:bag> <ex:list rdf:parseType="Collection"> <rdf:Description rdf:about="http://www.example.com/thing/2/" /> <rdf:Description rdf:about="http://www.example.com/thing/3/" /> </ex:list> <ex:xml rdf:parseType="Literal"> Below is: <html:div>Some <html:b>mixed</html:b> content.</html:div> </ex:xml> <ex:uri rdf:resource="http://www.example.com/thing/4/" /> <ex:bnode rdf:nodeID="b2" /> </rdf:Description> <ex:Type rdf:nodeID="b1"> <ex:number rdf:datatype="http://www.w3.org/2001/XMLSchema#int">7</ex:number> </ex:Type> </rdf:RDF>
TODO
'id' attributes are used to represent URIs and Bnode identifiers in treetriples documents. The same syntax is also used by 'listId' and 'stmtId' attributes to represent the ids of list nodes and reified statements. That syntax is described below:
If an Id construct starts with the string '_:' (underscore colon), then it is a bnode identifier, otherwise it is a URI.
Bnode identifiers give bnodes document-scoped ids so that the bnode can be referenced from elsewhere in the document.
The syntax of a bnode id is restricted by the following regular expression:
_:[a-zA-Z_][a-zA-Z0-9.\-_]*
That is, an underscore (_); a colon (:); a letter (a-z or A-Z) or underscore (_); followed by zero or more of: a letter (a-z or A-Z), digit (0-9), full-stop (.), hyphen (-), or underscore (_).
URIs used in id constructs:
The <tt:o> element is used in this document to represent the object of a triple. The object of a triple is one of:
A <tt:o> element, with no attributes represents a plain literal. The text content of the element, if any, represents the literal value.
eg:
<tt:o>A plain literal</tt:o>
A blank literal can be represented as:
<tt:o/>
A <tt:o> element with an xml:lang attribute represents a plain literal with a language tag. The value of xml:lang represents the language of the literal as a [RFC3066] language tag (as used by RDF/XML). The text content of the element, if any, represents the literal value.
eg:
<tt:o xml:lang="de">Guten Tag!</tt:o>
Note that because xml:lang is only allowed to appear in this single place, there is no inheritance of xml:lang context.
A <tt:o> element with a datatype attribute represents a typed literal. The value of the datatype attribute is the datatype URI. The text content of the element, if any, represents the literal value.
eg:
<tt:o datatype="http://www.w3.org/2001/XMLSchema#dateTime">2000-01-01T12:00:00Z</tt:o>
The datatype URI MUST be a legal RDF datatype, as defined by the RDF Concepts Recommendation [RDF].
A <tt:o> element with a parse="xml" attribute represents an XML literal. The child content of the element, if any, represents the value of the literal.
eg:
<tt:o parse="xml">
Below is:
<html:div>Some <html:b>mixed</html:b> content.</html:div>
</tt:o>
Consumers wishing to obtain the stringified value of an XML Literal must convert the contents of the <tt:o> element to Exclusive Canonical XML with comments and an empty Inclusive NamespaceList, then convert the UTF-8 bytes back to a character string. This is the same process as required by RDF/XML.
The contents of a well-formed XML Literal is not restricted by this document. Any requirements made by this document, such as to the contents of id attributes, or the occurrence of tt: namespaced elements do not apply to the children of the <tt:o> element.
TODO
A <tt:d> element, with a parse attribute containing one of the values below, represents a container:
parse attribute | rdf:type |
---|---|
alt | rdf:Alt |
bag | rdf:Bag |
seq | rdf:Seq |
container | none |
The element MUST have an id attribute representing the URI or bnode identifier of the container.
The parse attribute values: alt, bag, and seq, denote a triple, with the resource represented by the id attribute as its subject; the predicate rdf:type; and the corresponding rdf:type value as the object. Elements with a parse="container" attribute, do not implicitly create an rdf:type triple.
Inside the element, one or more <tt:o> elements represent each consecutive member of the container. The first child element represents a triple with the resource represented by the id attribute as its subject; the predicate rdf:_1; and the resource represented by the <tt:o> element as its object. Subsequent child elements represent triples with the predicates rdf:_2, rdf:_3, etc.
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO