w3c / N3

W3C's Notation 3 (N3) Community Group
48 stars 18 forks source link

URI Query String Mapping Syntax #109

Open AdamSobieski opened 1 year ago

AdamSobieski commented 1 year ago

Hello. I would like to propose some new syntactic options for accessing and utilizing the query string portions of URIs in N3 and, perhaps, other Semantic Web languages.

The first proposed syntax resembles: prefix:localname??(... list ...).

The following two examples showcase the proposed syntax:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex:  <http://example.org/#> . 

[] rdf:type ex:Widget??(ex:Foo ex:Foo2 ex:Foo3) .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex:  <http://example.org/#> . 

[] rdf:type ex:Widget??(("p1" ex:Foo) ("p2" ex:Foo2) ("p3" ex:Foo3)) .

This syntax ex:Widget??(ex:Foo ex:Foo2 ex:Foo3) maps to a URI: http://example.org/?T[]=http%3A%2F%2Fexample.org%2F%23Foo&T[]=http%3A%2F%2Fexample.org%2F%23Foo2&T[]=http%3A%2F%2Fexample.org%2F%23Foo3#Widget.

This syntax ex:Widget??(("p1" ex:Foo) ("p2" ex:Foo2) ("p3" ex:Foo3)) maps to a URI: http://example.org?p1=http%3A%2F%2Fexample.org%2F%23Foo&p2=http%3A%2F%2Fexample.org%2F%23Foo2&p3=http%3A%2F%2Fexample.org%2F%23Foo3#Widget.

The default parameter array name, e.g., T[] or _[], would be a matter for discussion.

The second proposed syntax resembles: $"literal" and $<uri>.

The $ symbol could be utilized, including in contexts with variables, to indicate that arguments are to be processed into RDF literal strings. For example:

ex:alice ex:says $"Hello {?x}" .

A similar notation could be utilized for URI nodes:

[] rdf:type $<http://example.org/?T[]={ex:Foo}&T[]={ex:Foo2}&T[]={ex:Foo3}#Widget> .
[] rdf:type $<http://example.org/?p1={ex:Foo}&p2={ex:Foo2}&p3={ex:Foo3}#Widget> .
[] rdf:type $<http://example.org/?p1={?x}&p2={?y}&p3={?z}#Widget> .

In my opinion, either proposed syntax would be generally useful. Any thoughts on these syntactic options for N3? Thank you.


See also: https://github.com/w3c-cg/planning/discussions/27#discussion-4656864