solid-tutorial-rdflib.js icon indicating copy to clipboard operation
solid-tutorial-rdflib.js copied to clipboard

Example of how to select based on blank nodes

Open adynata opened this issue 9 years ago • 1 comments

I'm trying to retrieve attributes of an item that I need to reach by way of a blank node:

var resource = store.statementsMatching($rdf.sym(key), VRA("placeOfPublication") , undefined); for (var i=0; i < resource.length; i++) { res = resource[i]; var locName = store.statementsMatching($rdf.sym(res.object.value), undefined, undefined); }

This would be used to traverse data that looks like this in xml/rdf:

<vra:placeOfPublication> <rdf:Description> <rdf:type rdf:resource="http://purl.org/vra/Place"/> <vra:containedIn> <rdf:Description rdf:about="http://vocab.getty.edu/tgn/7014406"> <rdf:type rdf:resource="http://purl.org/vra/Place"/> <vra:name>Philadelphia</vra:name> </rdf:Description> </vra:containedIn> <vra:name>published: Philadelphia, Pa.</vra:name> <vra:description/> </rdf:Description> </vra:placeOfPublication>

The first pass through returns blank nodes. For other similar queries (that don't return blank nodes) I am using the result of the first call to drill down to the information I need. For this particular section in my data, that won't work. I'm wondering if there's a more depth-first approach to this sort of query, and also how to get data associated with these specific blank nodes using wildcards.

Example of BlankNode:

BlankNode {id: 19, value: "19"}

adynata avatar Mar 28 '16 20:03 adynata

To get email-addresses from a Solid Pod i also first retrieved the blank nodes that were objects, and then used them as subjects in the next query (using two consecutive forEach calls):

fetcher.load(profile).then(response => {
    store.each(me, VCARD("hasEmail")).forEach((emailBlankId) => {
      store.each($rdf.sym(emailBlankId), VCARD("value")).forEach((emailAddress) => {
        emailAddress = emailAddress.value;
      })
    });
};

geistinme avatar Feb 25 '19 08:02 geistinme