从文档到SPARQL变量(MarkLogic)的BIND值 [英] BIND values from Documents to a SPARQL Variable (MarkLogic)

查看:77
本文介绍了从文档到SPARQL变量(MarkLogic)的BIND值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试查看是否有可能从文档中提取某个值并将其绑定到SPARQL中的变量

I am currently trying to see if it's possible to extract a certain value from a document and bind it to a variable in SPARQL

例如,如果我在MarkLogic中有这样的文档.

For example if i have such a document in MarkLogic.

/人/约翰

<person_data>
   <name>John</name>
   <age>25</age>
</person_data>

使用此数据,我尝试了多种方法来绑定它,例如在sem:sparql中使用XPath,如下所示

using this data I attempted various ways to bind it such as using XPath in sem:sparql as shown below

xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics" at "/MarkLogic/semantics.xqy";

sem:sparql('
PREFIX fn : <http://www.w3.org/2005/xpath-functions>
SELECT *
WHERE {
?s ?p ?o .
BIND (fn:doc("/person/John")//name/text() AS ?name)
}
',
(),
(),
()
)

但是,这导致了错误.因此,我非常感谢您提供有关完成此操作的任何建议.

However, this resulted in an error. Hence, I greatly appreciate any advise given on accomplishing this.

推荐答案

SPARQL引擎无法访问文档,但是仍然有更好的解决方案.为此,您可以使用模板驱动提取.它可以公开文档的SQL视图,还可以公开识别文档中的三元组" .这实际上意味着可以将特定值投影到三元索引中,并且可以像RDF数据一样访问您数据库中的任何其他RDF数据.

The SPARQL engine has no access to documents, but there is a better solution anyhow. You can use Template Driven Extraction for this. It can expose an SQL view on documents, but also 'Identify Triples in Documents'. It effectively means that particular values can be projected into the triple index, and will become accessible as RDF data like any other RDF data in your database.

HTH!

这篇关于从文档到SPARQL变量(MarkLogic)的BIND值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆