gaspanic
gaspanic

Reputation: 279

How bind values within RDF-star triples to variables?

Using RDF-star, say I have:

?couple :isA :Couple .

and ?couple takes values such as this one:

<< :Bill :marriedTo :Mary >> :isA :Couple .

Is there any way to extract :Bill and :Mary from the triples variable ?couple, and bind them to variables ?husband and ?wife?

I know I could do this:

<< ?husband :marriedTo ?wife >> :isA :Couple .

but I also want the variable ?couple and have this linked to ?husband and ?wife.

Upvotes: 0

Views: 183

Answers (2)

AndyS
AndyS

Reputation: 16680

There are functions to access the components of a quoted triple:

  ?couple :isA :Couple .
  BIND(subject(?couple) AS ?husband)
  BIND(object(?couple) AS ?wife)

gives

--------------------------------------------------
| couple                       | husband | wife  |
==================================================
| << :Bill :marriedTo :Mary >> | :Bill   | :Mary |
--------------------------------------------------

Upvotes: 2

IS4
IS4

Reputation: 13207

One option is to create ?couple from its constituents:

<< ?husband :marriedTo ?wife >> :isA :Couple .
BIND(<< ?husband :marriedTo ?wife >> AS ?couple)

There is no difference between a triple constructed in this way and the ?couple from your original example.

Another possibility is to introduce a zero-length property path between ?couple and another node:

?couple :isA :Couple .
?couple <about:invalid>? << ?husband :marriedTo ?wife >> .

Since there is most likely no triple using about:invalid as the predicate, the subject will have to match the object.

Upvotes: 3

Related Questions