MarkLogic sem: function group in MarkLogic Java API

跟風遠走 提交于 2019-12-11 03:47:26

问题


I am looking for information around the MarkLogic Java API, precisely I tried to find Java equivalent to the sem: xquery function group. I was not able to find anything in the docs so I thought you guys might have a better idea. What I need to do exactly is transform rdf/turtle to the ML triples, I understand that XQuery would be ideal for that but I can't use it because of the requirements, and once again I know it's not too clever but I can't change that. Any help would be greatly appreciated. All I found in the documentation was around three ways of loading triples (https://docs.marklogic.com/guide/semantics/loading#id_81259):

  1. Loading triples with mlcp,
  2. Loading Triples with XQuery,
  3. Loading Triples Using the REST API.

回答1:


One more suggestion. Some of the REST API's endpoints support the Graph Store Protocol and the SPARQL Protocol. You can send turtle to the graph store protocol with any HTTP client... here's the curl for it:

curl -Hcontent-type:text/turtle \ -d@'nameofturtlefile.ttl' \ -X PUT URLFORHOST/v1/graphs?graph=nameofgraph.

That endpoint takes care of the translation to sem:triple elements; you should never have to see that XML representation of triples.

Translate the curl call to Apache HTTP Client and you have a way to ingest turtle. I've also used the Jena API (look up riot) to save turtle to MarkLogic.




回答2:


You can load rdf/turtle documents into MarkLogic with mlcp, which is a Java program.

If you want to do it yourself, its the RDFReader class in mlcp that does most of the heavy lifting. Basically, it uses Jena to parse the input file and reads statements from the model constructing sem:* XML out of them.

Hope that helps.




回答3:


Quite a few features aren't exposed through the high-level Java API. Because of that the Java API supports extensions, and http://docs.marklogic.com/guide/java/resourceservices describes how they work. If you create one, consider open-sourcing it.

You might also be interested in the example extension for SPARQL queries: http://docs.marklogic.com/javadoc/client/com/marklogic/client/example/extension/SPARQLManager.html



来源:https://stackoverflow.com/questions/22459406/marklogic-sem-function-group-in-marklogic-java-api

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