Re: [MarkLogic Dev General] short question about result of sem:sparql-values

2018-02-20 Thread Geert Josten
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(http://www.w3.org/2001/XMLSchema; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xmlns:json="http://marklogic.com/xdmp/json;>)

Raw Output

[{"notEmpty":"<http://www.example.org/entity/Q9235>","label":"\"Friedrich 
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


[MarkLogic Dev General] short question about result of sem:sparql-values

2018-02-20 Thread Erik Zander
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 
but that is as I understand it a sequence of sem:binding
Output of xdmp:describe

sem:binding(http://www.w3.org/2001/XMLSchema; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xmlns:json="http://marklogic.com/xdmp/json;>)

Raw Output

[{"notEmpty":"","label":"\"Friedrich 
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