I need a format that
There exist similar formats, but all of those I know do not fulfill all of these requirements.
XSLT
XSLT can define XML output and is user-friendly. However, it cannot natively query RDF, only XML.
However, I can use XSLT to process SPARQL output, but that's not user-friendly (too much boilerplate code, and the query is in a different file):
<xsl:template match="s:result">
<div class="cat">
<xsl:value-of select="s:binding[@name='name']/s:literal"/>
</div>
</xsl:template>
SPARQL Templates
This is a user-friendly RDF query language with ability to do some templating, mostly for plain text. For XML output, however, it is not very usable, and not user-friendly because of the need for proper escaping of quotes. Also for generating complex output documents is complicated.
template {
'''<div class="cat">''' ?name '''</div>'''
}
where {
?c a :cat .
?c :name ?name
}
XUL templates
This language is designed exactly for my purpose. However, it lacks a declarative and user-friendly query language like SPARQL, and has quite verbose xml-based query language.
<div class="cat" datasources="./cats.rdf" ref="http://xmlns.com/cats/cat">
<template>
<query>
<content uri="?start" />
<triple subject="?cat" predicate="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" object="?start" />
<triple subject="?cat" predicate="http://xmlns.com/cats/name" object="?name" />
</query>
<action>
<span value="?name" />
</action>
</template>
</div>
It also has a much more concise syntax than this, but one that still lacks the syntactic sugar Turtle and SPARQL has, and is not as powerful as SPARQL.
This language is probably the closest to what I need. However, it still feels like a programming language.
<div class="cat">{
for $cat $name from <cats.rdf>
where {$cat a :cat . $cat :name $name}
return $name
}</div>
The use of for
and return
keywords suggest an algorithmic thinking, but I need something conceptually declarative. Also the mixture of {}
blocks and xml tags can confuse a non-programmer, especially in complex queries where XML tags are returned in the return
clause.
I'd like to have something simple and powerful, and which is syntactically an XML document. Like
<div class="cat" ql:select="?name" ql:where="?cat a :cat . ?cat :name ?name" />
or more XSL-like
<div class="cat">
<ql:value-of select="?cat" where="?cat a :cat . ?cat :name ?name" />
</div>
(Actually, if you cannot suggest something existing, I might implement a language like this last one.)
I've found UISPIN, which is a language very similar to what I've dreamed:
<ui:forEach ui:resultSet="{#SELECT ?name WHERE {?c a :cat . ?c :name ?name} }">
<div class="cat">
{=?name}
</div>
</ui:forEach>
I've also found Gloze, a tool to map back and forth between RDF and custom XML formats, using the XML Schema as the descriptor of the conversion process. This is probably not the easiest to map from RDF to XML, however, in the other direction it's quite straightforward.