Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support Named Graphs #51

Open
FabienGandon opened this issue Jan 31, 2025 · 4 comments
Open

Support Named Graphs #51

FabienGandon opened this issue Jan 31, 2025 · 4 comments
Labels
needs discussion Proposed for discussion in an upcoming meeting spec:new-feature Change adding new functionality (class 4)

Comments

@FabienGandon
Copy link

This issue is to discuss adding minimal support for named graphs in RDF/XML and inspired by the "RDF/XML Source Declaration
W3C Member Submission, 5 September 2007"

One option would be to introduce an rdf:graph attribute and, as suggested for other attributes, the propagation rules would be like xml:lang, with the attribute defining the named graphs of the parsed triples for the descendant elements.
Also, as mentioned in other issues, I believe that it would be a good practice (from now own) to encourage the explicit mention of the RDF version as in rdf:version="1.2"

For instance Example 4 could be adapted as

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
            xmlns:ex="http://example.org/stuff/1.0/"
            xml:base="http://example.org/triples/"
            xmlns:dc="http://purl.org/dc/elements/1.1/"
	    rdf:version="1.2">
			
<rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar" rdf:graph="http://inria.fr/graph1" >
  <ex:editor>
    <rdf:Description rdf:about="http://purl.org/net/dajobe/#me" rdf:graph="http://inria.fr/graph2">
      <ex:homePage rdf:resource="http://purl.org/net/dajobe/" /> 
      <ex:fullName>Dave Beckett</ex:fullName>
    </rdf:Description>
  </ex:editor>
  <dc:title>RDF 1.2 XML Syntax</dc:title>
</rdf:Description>

</rdf:RDF>

parsed as N-quads:

<http://www.w3.org/TR/rdf-syntax-grammar> <http://example.org/stuff/1.0/editor> <http://purl.org/net/dajobe/#me> <http://inria.fr/graph1> .
<http://www.w3.org/TR/rdf-syntax-grammar> <http://purl.org/dc/elements/1.1/title> "RDF 1.2 XML Syntax" <http://inria.fr/graph1> .
<http://purl.org/net/dajobe/#me> <http://example.org/stuff/1.0/homePage> <http://purl.org/net/dajobe/> <http://inria.fr/graph2> .
<http://purl.org/net/dajobe/#me> <http://example.org/stuff/1.0/fullName> "Dave Beckett" <http://inria.fr/graph2> .
@FabienGandon FabienGandon added needs discussion Proposed for discussion in an upcoming meeting spec:new-feature Change adding new functionality (class 4) labels Jan 31, 2025
@Tpt
Copy link

Tpt commented Feb 1, 2025

I am not sure a rdf:graph attribute is enough because it prevents to serialize named graphs with a blank node name.

What about a rdf:Graph node that could have a rdf:about or rdf:nodeID attribute (+ xml:lang...)

Your example would be encoded:

<rdf:Graph rdf:about="http://inria.fr/graph1">
  <rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar">
    <ex:editor rdf:resource="http://purl.org/net/dajobe/#me" />
    <dc:title>RDF 1.2 XML Syntax</dc:title>
  </rdf:Description>
</rdf:Graph>
<rdf:Graph rdf:graph="http://inria.fr/graph2">
   <rdf:Description rdf:about="http://purl.org/net/dajobe/#me">
      <ex:homePage rdf:resource="http://purl.org/net/dajobe/" /> 
     <ex:fullName>Dave Beckett</ex:fullName>
   </rdf:Description>
</rdf:Graph>
</rdf:RDF>

we might even have anonymous named graphs similar to N3:

  <rdf:Description rdf:about="http://example.com/alice">
    <ex:state>
      <rdf:Graph>
        <rdf:Description rdf:about="http://example.com/bob">
          <ex:eat rdf:resource="http://example.com/apple" />
        </rdf:Description>
      </rdf:Graph>
  </rdf:Description>

to encode the TriG:

<http://example.com/alice> ex:state _:g1 .
_:g1 {
     <http://example.com/bob> ex:eat <http://example.com/apple>
}

@afs
Copy link
Contributor

afs commented Feb 1, 2025

+1 to an alternative having a top-level-only element rdf:Graph.

This style is more like an RDF dataset, less like a graph with annotated triple.
It also means a whole graph can be extracted and passed to existing code, encouraging implementers.

While nested rdf:Graph is possible, for now, I suggest we focus on a dataset-like design.

@FabienGandon
Copy link
Author

+1 to the proposed alternative of an rdf:Graph node.

@niklasl
Copy link

niklasl commented Feb 6, 2025

I also favour the graph element option (which also sets it apart from #52 if we do that).

We need to take care not to do it in a way that confuses named graphs in datasets with possible graph terms (which is beyond RDF 1.2). But also doesn't get in the way of such a possible future feature.

I think these graph elements should only be allowed either as child elements of <rdf:RDF> or as standalone root elements. And probably that the attribute giving the name should be required. (Or maybe that <rdf:Graph> functions like <rdf:RDF>...)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
needs discussion Proposed for discussion in an upcoming meeting spec:new-feature Change adding new functionality (class 4)
Projects
None yet
Development

No branches or pull requests

4 participants