On Thu, Jan 16, 2025 at 5:36 PM Andy Seaborne <a...@apache.org> wrote:
>
>
>
> On 15/01/2025 23:50, Martynas Jusevičius wrote:
> > Hi,
> >
> > Is it possible to get DESCRIBE results as quads?
>
> No. It's a single model.

Does it have to be though? :) Why shouldn't a quad description be possible?

I have a use case for that: for every triple rendered in a UI I want
to know which named graph it came from, so that I can override the
navigation of external URI resources (<https://example.org/Denis>
being external to the webapp on <https://localhost:4443/>) or
resources described in multiple graphs, and lead the user to the named
graph(s) that contain them.

>
> > I tried requesting
> > text/trig but simply got the data in the default graph:
> >
> > $ curl http://localhost:3031/ds/ -d 'query=DESCRIBE
> > <https://example.org/Denis>' -i -H "Accept: text/trig"
>
> application/trig

Right, my bad. But I re-ran with application/trig and got the same result.

>
> > HTTP/1.1 200 OK
> > Date: Wed, 15 Jan 2025 23:36:46 GMT
> > Fuseki-Request-Id: 552
> > Content-Type: text/trig
>
> text/turtle?

No, Fuseki actually returned text/trig :)

>
> > Transfer-Encoding: chunked
> >
> > <https://example.org/Denis>
> >          a                         <http://schema.org/Person> ;
> >          <http://schema.org/name>  "Denis Villeneuve" ;
> >          <http://schema.org/url>   <https://www.imdb.com/name/nm0898288/> .
> >
> > The result I'm looking for can be obtained using CONSTRUCT ... GRAPH
> > ... WHERE [1] syntax:
> >
> > $ curl http://localhost:3031/ds/ -d 'query=CONSTRUCT { GRAPH ?g {
> > <https://example.org/Denis> ?p ?o . } } WHERE { GRAPH ?g {
> > <https://example.org/Denis> ?p  ?o } }' -i -H "Accept: text/trig"
> > HTTP/1.1 200 OK
> > Date: Wed, 15 Jan 2025 23:36:10 GMT
> > Fuseki-Request-Id: 550
> > Content-Type: text/trig
> > Transfer-Encoding: chunked
> >
> > <https://localhost:4443/8a440293-253e-42f0-bdd6-3e7fc8acb337/> {
> >      <https://example.org/Denis>
> >              a                         <http://schema.org/Person> ;
> >              <http://schema.org/name>  "Denis Villeneuve" ;
> >              <http://schema.org/url>   
> > <https://www.imdb.com/name/nm0898288/> .
> > }
> >
> > Just for curiosity's sake I also tried requesting Turtle with
> > CONSTRUCT ... GRAPH ... WHERE and got an empty result:
> >
> > $ curl http://localhost:3031/ds/ -d 'query=CONSTRUCT { GRAPH ?g {
> > <https://example.org/Denis> ?p ?o . } } WHERE { GRAPH ?g {
> > <https://example.org/Denis> ?p  ?o } }' -i -H "Accept: text/turtle"
> > HTTP/1.1 200 OK
> > Date: Wed, 15 Jan 2025 23:43:04 GMT
> > Fuseki-Request-Id: 554
> > Content-Type: text/turtle
> > Transfer-Encoding: chunked
> >
> > Looking at the above, the DESCRIBE behavior with quads feels inconsistent 
> > to me.
> > I get that the result triples can simply be placed into the default
> > graph when quads are requested. But does that really make sense?
> > IMO DESCRIBE should behave like CONSTRUCT ... GRAPH ... WHERE when
> > quads are requested (i.e. return quads), and return triples when
> > triples are requested (as it always has done).
>
> How do you associate the resources to be described with a graph?

The same way as CONSTRUCT GRAPH does?

If we compare CONSTRUCT GRAPH and DESCRIBE results, we can see that
the <https://example.org/Denis> is actually stored in a named graph.

Are you saying that a resource description cannot be quads? I.e.
cannot be split across multiple named graphs or even combine default
and named graphs? I don't see why not.

What DESCRIBE does to produce triples is simply strip the graph URIs
from the quads (in this case
<https://localhost:4443/8a440293-253e-42f0-bdd6-3e7fc8acb337/>), which
is lost information *when quads are requested*.

>
> >
> > Martynas
> >
> > [1] https://jena.apache.org/documentation/query/construct-quad.html
>

Reply via email to