Hi Tony,

Of course, this would be the easy workaround.  But since it is
possible to evaluate the query all at once, it would be good to be
able to do so.

Another workaround I thought about, is to use BIND in the query, to
create another placeholder out of ?s.  For instance, change the
previous SPARQL query into:

    SELECT * WHERE {
       ?s ?p ?o .
       BIND(CONCAT(?s, "") as ?v)
    }

This return a "v" in each result row, but it is then always null.  The
following:

require('/MarkLogic/semantics').sparql(
    'SELECT * WHERE { ?s ?p ?o . BIND(CONCAT(?s, "") as ?v) }',
    { 's': [ sem.iri('#1'), sem.iri('#2') ] })

returns an iterator to objects of the form:

    { p: "#pred", o: "value", v: null }

So it is not even usable either.

Regards,

-- 
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/


On 16 May 2016 at 10:51, Anthony Coates wrote:
> Classification: Public
>
> Hi Florent.  Would it be a problem to just call the query (multiple times) 
> with a single subject for each of the different subjects that you want, and 
> then combine the results?
>
> Cheers, Tony.
>
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Florent Georges
> Sent: 15 May 2016 12:42
> To: MarkLogic Developer Discussion <[email protected]>
> Subject: [MarkLogic Dev General] sem.sparql: get bound placeholders in the 
> result
>
> Hi,
>
> Using `sem.sparql()`, it is possible to bind a SPARQL placeholder to an 
> array, to serve as many alternatives to the placeholder in the triples 
> pattern.  For instance, the following query:
>
>     require('/MarkLogic/semantics').sparql(
>        'SELECT * WHERE { ?s ?p ?o }',
>        { 's': [ sem.iri('#1'), sem.iri('#2') ] })
>
> returns the predicates and values for al triples with the subject equal to 
> either `#1` or `#2`.
>
> Problem is, the bound placeholder is not part of the result (in this example, 
> `?s`).  The result is an iterator over objects of the following form:
>
>     { p: "#pred", o: "value" }
>
> So it is not possible to use the result in a way to would need to know which 
> subject each row is attached to (which I believe is generally the case when 
> binding them to arrays, as opposed to scalar values).
>
> Is there any way to have `sem.sparql()` include bound placeholders in the 
> result?
>
> Regards,
>
> --
> Florent Georges
> http://fgeorges.org/
> http://h2oconsulting.be/
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
> ---
> This e-mail may contain confidential and/or privileged information. If you 
> are not the intended recipient (or have received this e-mail in error) please 
> notify the sender immediately and delete this e-mail. Any unauthorized 
> copying, disclosure or distribution of the material in this e-mail is 
> strictly forbidden.
>
> Please refer to http://www.db.com/en/content/eu_disclosures.htm for 
> additional EU corporate and regulatory disclosures and to 
> http://www.db.com/unitedkingdom/content/privacy.htm for information about 
> privacy.
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to