Thank you Geert,

Great that was exactly what I was looking for!

Maybe the example should be added to the documentation of the function sure 
would have saved me some time.

Regards and thanks again,
Erik

Från: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] För Geert Josten
Skickat: den 20 februari 2018 15:17
Till: MarkLogic Developer Discussion <general@developer.marklogic.com>
Ämne: Re: [MarkLogic Dev General] short question about result of 
sem:sparql-values

Hi Erik,

Correct. The function returns a sequence of sem:binding objects. A sem:binding 
is a special type of map:map, so you can use map functions on them. Here is a 
working example that returns concrete values:

xquery version "1.0-ml";

import module namespace sem = "http://marklogic.com/semantics";
  at "/MarkLogic/semantics.xqy";

sem:sparql-values("select * { ?s ?p ?o } limit 50", map:map()) ! map:get(., "o")

Note: the ! Is the iterator operator from XQuery 3. You could also use a more 
old fashion FLWOR is that would be clearer to you..

Cheers,
Geert

From: 
<general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>>
 on behalf of Erik Zander 
<erik.zan...@studentlitteratur.se<mailto:erik.zan...@studentlitteratur.se>>
Reply-To: MarkLogic Developer Discussion 
<general@developer.marklogic.com<mailto:general@developer.marklogic.com>>
Date: Tuesday, February 20, 2018 at 9:02 AM
To: "general@developer.marklogic.com<mailto:general@developer.marklogic.com>" 
<general@developer.marklogic.com<mailto:general@developer.marklogic.com>>
Subject: [MarkLogic Dev General] short question about result of 
sem:sparql-values

Hi,

I have what I feel should be a simple question but I yet to understand how it's 
done.

When calling sem:sparql-values how do I get the result?
In the
documentation it says it's a sequence 
http://docs.marklogic.com/guide/semantics/semantic-searches - 
id_90139<http://docs.marklogic.com/guide/semantics/semantic-searches#id_90139> 
but that is as I understand it a sequence of sem:binding
Output of xdmp:describe

sem:binding(<json:object xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:json="http://marklogic.com/xdmp/json";><json:entry<http://marklogic.com/xdmp/json%22%3e%3cjson:entry>
 key="notEmpty"><json:value xsi:type="sem:iri" xmlns:...</json:object>)

Raw Output

[{"notEmpty":"<http://www.example.org/entity/Q9235>","label":"\"Friedrich<http://www.example.org/entity/Q9235%3e%22,%22label%22:%22/%22Friedrich>
 Hegel\"@sv"}]

In this case I just want to get the value Friedrich Hegel.
Doing sem:sparql-values($sparql,$bindings)/label doesn't work as it says not a 
node

Any pointers on how I should go about would be welcome.

Regards
Erik

_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to