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):
- Loading triples with mlcp,
- Loading Triples with XQuery,
- Loading Triples Using the REST API.
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.
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.
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