要完全构建可视化,您需要创建一个自定义“图形扩展”查询,如下所示:
# Note that ?node is the node you clicked and must be used in the query
PREFIX rank: <http://www.ontotext.com/owlim/RDFRank#>
PREFIX ent: <http://www.ontotext.com/owlim/entity#>
CONSTRUCT
{
# The triples that will be added to the visual graph
?newNodeLX ?edge ?newNodeRX .
}
WHERE
{
{
{
# Left to right relations (starting IRI is the subject)
?node ?edge ?newNodeR .
# ?node is always an IRI, ?newNodeR must be checked for IRI or Blank
FILTER(isIRI(?newNodeR) || isBlank(?newNodeR))
BIND(IF(isBlank(?newNodeR), URI(CONCAT("BNode:", STR(ent:id(?newNodeR)))), ?newNodeR) AS ?newNodeRX)
BIND(?node AS ?newNodeLX)
}
UNION
{
# Right to left relations (starting IRI is the object)
?newNodeL ?edge ?node .
# ?node is always an IRI, ?newNodeL is always an IRI or Blank
BIND(IF(isBlank(?newNodeL), URI(CONCAT("BNode:", STR(ent:id(?newNodeL)))), ?newNodeL) AS ?newNodeLX)
BIND(?node AS ?newNodeRX)
}
}
UNION
{
{
# Left to right relations (starting Blank is the subject)
?nodeC ?edge ?newNodeR .
# ?nodeC must be checked for Blank, ?newNodeR must be checked for IRI or Blank
FILTER(isBlank(?nodeC))
FILTER(isIRI(?newNodeR) || isBlank(?newNodeR))
BIND(IF(isBlank(?newNodeR), URI(CONCAT("BNode:", STR(ent:id(?newNodeR)))), ?newNodeR) AS ?newNodeRX)
BIND(URI(CONCAT("BNode:", STR(ent:id(?nodeC)))) AS ?newNodeLX)
FILTER(?newNodeLX = ?node)
}
UNION
{
# Right to left relations (starting Blank is the object)
?newNodeL ?edge ?nodeC .
# ?nodeC must be checked for Blank, ?newNodeL is always an IRI or Blank
FILTER(isBlank(?nodeC))
BIND(IF(isBlank(?newNodeL), URI(CONCAT("BNode:", STR(ent:id(?newNodeL)))), ?newNodeL) AS ?newNodeLX)
BIND(URI(CONCAT("BNode:", STR(ent:id(?nodeC)))) AS ?newNodeRX)
FILTER(?newNodeRX = ?node)
}
}
}
#ORDER BY ?edge
并使用“节点基础”查询来扩充它,如下所示:
# Note that ?node is the relevant node's IRI and must be used in the query
PREFIX sesame: <http://www.openrdf.org/schema/sesame#>
PREFIX ent: <http://www.ontotext.com/owlim/entity#>
SELECT ?type {
{
# Get node direct type
?node sesame:directType ?type.
}
UNION
{
# Get node direct type
?nodeB sesame:directType ?type.
FILTER(isBlank(?nodeB) && URI(CONCAT("BNode:", STR(ent:id(?nodeB)))) = ?node)
}
} ORDER BY ?type
还有一个像这样的“Node extra”查询:
# Note that ?node is the node you clicked and must be used in the query
PREFIX ent: <http://www.ontotext.com/owlim/entity#>
SELECT ?property ?value {
{
# Gets all datatype properties (?property) with literals as values (?value)
?node ?property ?value .
# Select only literals
FILTER(isLiteral(?value))
}
UNION
{
?nodeB ?property ?value .
FILTER(isLiteral(?value))
FILTER(isBlank(?nodeB) && URI(CONCAT("BNode:", STR(ent:id(?nodeB)))) = ?node)
}
}