BIND values from Documents to a SPARQL Variable (MarkLogic)

跟風遠走 提交于 2020-01-06 07:01:10

问题


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

For example if i have such a document in MarkLogic.

/person/John

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

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.


回答1:


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!



来源:https://stackoverflow.com/questions/55162838/bind-values-from-documents-to-a-sparql-variable-marklogic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!