# Named Graph and Dereferentiation

**URL:** <https://community.stardog.com/t/named-graph-and-dereferentiation/456>\
**Category:** Support\
**Created:** [July 14, 2017, 11:10am UTC](https://community.stardog.com/t/named-graph-and-dereferentiation/456 "2017-07-14T11:10:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samur\_Araujo](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@Samur\_Araujo](https://community.stardog.com/u/Samur_Araujo)\
**Post date:** [July 14, 2017, 11:10am UTC](https://community.stardog.com/t/named-graph-and-dereferentiation/456/1 "2017-07-14T11:10:32Z")

</div>

Hi all, some implementations of sparql dereferentiate the content from a uri on FROM NAMED GRAPH.

select \*  
FROM NAMED [http://somedomain.com/example.nt](http://somedomain.com/example.nt)  
WHERE {  
?s ?p ?o  
}

That would return all triples in example.nt

Why stardog does not do so? Is there a away to query a remote file (eg. .nt)?

---

<div class="post-metadata">

**Author:** ![pavel](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pavel/32/18_2.png) [@pavel](https://community.stardog.com/u/pavel)\
**Post date:** [July 14, 2017, 11:19am UTC](https://community.stardog.com/t/named-graph-and-dereferentiation/456/2 "2017-07-14T11:19:46Z")

</div>

There’re two things here: first, Stardog won’t dereference IRIs in `FROM NAMED` or `FROM` clauses. Those should be used with named graphs in the data. If you want to query remote sources, you can use the `SERVICE` keyword (assuming there’s a SPARQL endpoint to serve requests). Second, this query wouldn’t return results even if `example.nt` was a local named graph. Since your triple pattern is not within a `graph ?g {...}` block, you should use `FROM`.

Best,  
Pavel

---

<div class="post-metadata">

**Author:** ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)\
**Post date:** [July 14, 2017, 5:04pm UTC](https://community.stardog.com/t/named-graph-and-dereferentiation/456/3 "2017-07-14T17:04:55Z")

</div>

You could get something very close to what you’re looking for with a quick bash command

```
$> URI="http://somedomain.com/example.nt
$> stardog data add myDb --named-graph $URI <(curl -s $URI)

```

I haven’t had a chance to test it but if it’s not correct it should be close. You might need to be explicit with the file type and add “`-format NTRIPLES`” . Hope that helps 🙂

---

<div class="post-metadata">

**Author:** ![rivettp](https://avatars.discourse-cdn.com/v4/letter/r/82dd89/32.png) [@rivettp](https://community.stardog.com/u/rivettp)\
**Post date:** [July 14, 2017, 5:12pm UTC](https://community.stardog.com/t/named-graph-and-dereferentiation/456/4 "2017-07-14T17:12:26Z")

</div>

By the way, I believe the original query is not correct: when using FROM NAMED (as opposed to FROM) you need to actually name the graph in the query. For example:  
`SELECT * FROM NAMED <http://somedomain.com/example.nt> WHERE { GRAPH <http://somedomain.com/example.nt> {?s ?p ?o} }`

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [July 28, 2017, 5:13pm UTC](https://community.stardog.com/t/named-graph-and-dereferentiation/456/5 "2017-07-28T17:13:06Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
