ATTENTION The normative specification of JTMQR has been moved to this site. Please do not use or change the content below.
JTM Query Result (JTMQR) 1.0 (Draft)¶
UPDATE: See JTMQR 2.0 for current format syntax.
The JSON result set for a query is based on the Tuple Sequence Encoding of the "TMIP, Topic Map Interaction Protocol 0.3, Specification" by Robert Barta. The following format simply tries to map the RelaxNG description to JSON with some minor changes:
- the XTM 1.0 fragments will be replaced by JTM 1.0 (or JTM 1.1).
- the
xmlnsnamespace definition will be skipped by now idfor a tuple is not supported (justsandi)the explicittwas removed due to the possibility for "unnamed" arrays in JSON
Specification¶
Query Result Set (root)¶
The query result set contains the following members:
version- the version of JTMQR (should be "1.0")metadata- some information on the sequence dataseq- an array of Tuple Hashesordered- (optional, default: false) true if tuples inseqare ordered
Metadata¶
Gives information about rows and columns used for the result sequence:
columns- the number of result columns (length of a tuple)rows- the number of result setsaliases- json object containing column headers ( keys are the index of result )
Tuple Hash¶
Each tuple hash may contain 0..n of the following members depending on the TMQL query:
s- a literal (string)b- a literal (boolean)n- a literal (number)l- a literal (locator)a- a JSON array (list of values)i- a construct item that is represented as JTM 1.0 or (JTM 1.1)
Array Value¶
Each array may contain a set of JSON object similar to the tuple hash syntax and members. The following members are allowed:
s- a literal (string)b- a literal (boolean)n- a literal (number)l- a literal (locator)i- a construct item that is represented as JTM 1.0 or (JTM 1.1)
Note: Array values may never containd array values
Pseudo Schema¶
{
"version": "",
"metadata": {"columns":0, "rows":0, "aliases":{}},
"seq":[
{"t":[
{ "s":".." | "l":".." |"b":(true|false) | "n":(integer|floating point) | "i":{ -JTM- } | "a":[...]},
..
]},
..
]
"ordered":true
}
Samples¶
// possible result for TMQL query: tm:subject >> instances
{
"version":"1.0",
"metadata": {"columns":1, "rows":20, "aliases":{}},
"seq":[
{"t":[
{"i": // each topic is serialized with JTM
{ "version":"1.1",
"prefixes":{"tmdm":"http://psi.topicmaps.org/iso13250/model/"},
"item_type":"topic",
"subject_identifiers":[ .. ],
"instance_of":[ .. ],
"names":[ .. ]}}
]},
{"t":[
{"i":
{ "version":"1.1",
"prefixes":{"tmdm":"http://psi.topicmaps.org/iso13250/model/"},
"item_type":"topic",
"subject_identifiers":[ .. ],
"instance_of":[ .. ],
"names":[ .. ]}}
]},
{"t":[
{ ... }
]}
],
"ordered":true
}
Sample with projection:
// possible result for TMQL query:
// tm:subject >> instances (
// . ,
// . / tm:name,
// fn:count( . >> characteristics ),
// fn:count( . >> characteristics ) > 2)
{
"version":"1.0",
"metadata": {"columns":4, "rows":20, "aliases":{}},
"seq":[
{"t":[
{"i": // each topic is serialized with JTM
{ "version":"1.1",
"prefixes":{"tmdm":"http://psi.topicmaps.org/iso13250/model/"},
"item_type":"topic",
"subject_identifiers":[ .. ],
"instance_of":[ .. ],
"names":[ .. ]}},
{"s":"Foo"},
{"n":2},
{"b":false}
]},
{"t":[
{"i":
{ "version":"1.1",
"prefixes":{"tmdm":"http://psi.topicmaps.org/iso13250/model/"},
"item_type":"topic",
"subject_identifiers":[ .. ],
"instance_of":[ .. ],
"names":[ .. ]}},
{"s":"Bar"},
{"n":3},
{"b":true}
]},
{"t":[
{"i": ... },
{"s":"Zoo"},
{"n":5},
{"b":true}
]}
],
"ordered":true
}
Sample with array results and alias:
// possible result for TMQL query:
// FOR $t IN tm:subject >> instances
// GROUP BY $0
// RETURN $t AS "topic", $t
// . / tm:name
{
"version":"1.0",
"metadata": {"columns":2, "rows":20, "aliases":{ "0":"topic" , "1":null}},
"seq":[
{"t":[
{"i": // each topic is serialized with JTM
{ "version":"1.1",
"prefixes":{"tmdm":"http://psi.topicmaps.org/iso13250/model/"},
"item_type":"topic",
"subject_identifiers":[ .. ],
"instance_of":[ .. ],
"names":[ .. ]}},
{"a":[
{"s":"Name"},
{"s":"Other"}
]
}
]},
{"t":[
{"i":
{ "version":"1.1",
"prefixes":{"tmdm":"http://psi.topicmaps.org/iso13250/model/"},
"item_type":"topic",
"subject_identifiers":[ .. ],
"instance_of":[ .. ],
"names":[ .. ]}},
{"a":[
{"s":"Name"},
{"s":"Other"}
]
}
]}
],
"ordered":true
}
Maiana public
Topic Maps Lab