Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add positive and negative SPARQL 1.2 triple terms syntax tests #144

Merged
merged 10 commits into from
Oct 25, 2024
2 changes: 2 additions & 0 deletions sparql/sparql12/manifest.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ trs:manifest rdf:type mf:Manifest ;
""";
mf:include (
<grouping/manifest.ttl>
<syntax-triple-terms-negative/manifest.ttl>
<syntax-triple-terms-positive/manifest.ttl>
) .
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
<<s :p|:q ?o>>.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
<<s :p|:q ?o ~ :iri >>.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
<<(s :p|:q ?o)>>.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s :p|:q ?o {| ?pp ?oo |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
:p ("abc") :o {| :q 123 |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s :p+ ?o {| ?pp ?oo |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * {
:s :p? :o {| ?p ?o |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
:s+ :p ?o {| ?pp ?oo |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s :p/:q ?o {| ?pp ?oo |}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s1 ?p1/?p2 ?o1 {| ?p2 ?o2 |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/ns#>

SELECT * {
:p ("abc") :o ~ :iri {| :q 123 |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s :p+ ?o ~ :iri {| ?pp ?oo |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * {
:s :p? :o ~ :iri {| ?p ?o |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
:s+ :p ?o ~ :iri {| ?pp ?oo |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s :p/:q ?o ~ :iri {| ?pp ?oo |}.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s :p|:q ?o ~ :iri {| ?pp ?oo |} .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX : <http://example.com/>

SELECT * WHERE {
?s1 ?p1/?p2 ?o1 ~ :iri {| ?p2 ?o2 |}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT * {
?s ?p ?o .
BIND(<< ?s ?p ?o >> AS ?t )
}
4 changes: 4 additions & 0 deletions sparql/sparql12/syntax-triple-terms-negative/bind-reified.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT * {
?s ?p ?o .
BIND(<< ?s ?p ?o ~ :iri >> AS ?t )
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT * {
?s ?p ?o .
BIND(<< [] ?p ?o >> AS ?t )
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT * {
?s ?p ?o .
BIND(<< [] ?p ?o ~ :iri >> AS ?t )
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT * {
?s ?p ?o .
BIND(<<( [] ?p ?o )>> AS ?t )
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
<<?s [] ?o>> ?p2 ?o2 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
<<?s [] ?o ~ :iri>> ?p2 ?o2 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
<<(?s [] ?o)>> ?p2 ?o2 .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
<<?s ?p ?o>> ex:author ex:Bob .
<< ex:Moscow a ex:City >> ex:author ?person .
# TODO: See if this should be throwing an error
<< _:b ex:x () >> ex:broken true .
Comment on lines +7 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the suggestion here that () shouldn't parse as rdf:nil and be disallowed because you shouldn't be able to reify a triple with a list as an object?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was derived from the RDF-star tests.
I suspect you are right.
But I wonder if we really want/need to disallow this.
A message on this exact topic was also just raised on the mailinglist.

@afs perhaps you have some more insights on this?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also w3c/rdf-ucr#26 ("Example 3: RDF Lists").

Copy link
Contributor

@afs afs Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the suggestion here that () shouldn't parse as rdf:nil and be disallowed because you shouldn't be able to reify a triple with a list as an object?

Yes. The only meaning would be to assert the triples into the graph. RDF Collections are messy. In N3, collections are first-class citizens but not in RDF 1.x.

The idea is to keep triple terms as terms, without additional triples asserted in to a graph.
<<:s :p :o >> becomes _:r rdf:reifies <<( :s :p :o )>> -- <<...>> usage is connected to triple terms.

In SPARQL, a query expression can create terms outside a graph. No lists one or greater, no predicate object lists.

In annotation syntax, it is more reasonable to put the asserted triples in the graph although it only puts the head blank node into the triple term.
-- w3c/rdf-ucr#26 ("Example 3: RDF Lists") -- but << >> is not asserting.

() is an odd case because it is a term whereas any other list has triples. It can't occur in expressions as rdf:nil.

See also:

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
<<?s ?p ?o>> ex:author ex:Bob .
<< ex:Moscow a ex:City >> ex:author ?person .
# TODO: See if this should be throwing an error
<< _:b ex:x ( 1 2 3 ) >> ex:broken true .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
<<?s ?p ?o ~ :iri >> ex:author ex:Bob .
<< ex:Moscow a ex:City ~ :iri >> ex:author ?person .
# TODO: See if this should be throwing an error
<< _:b ex:x () ~ :iri >> ex:broken true .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
<<?s ?p ?o ~ :iri >> ex:author ex:Bob .
<< ex:Moscow a ex:City ~ :iri >> ex:author ?person .
# TODO: See if this should be throwing an error
<< _:b ex:x ( 1 2 3 ) ~ :iri >> ex:broken true .
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
<<(?s ?p ?o)>> ex:author ex:Bob .
<<( ex:Moscow a ex:City )>> ex:author ?person .
# TODO: See if this should be throwing an error
<<( _:b ex:x () )>> ex:broken true .
Comment on lines +7 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here as with list-anonreifier-01 – is this about ()/rdf:nil?

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PREFIX ex: <http://example.com/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
<<(?s ?p ?o)>> ex:author ex:Bob .
<<( ex:Moscow a ex:City )>> ex:author ?person .
# TODO: See if this should be throwing an error
<<( _:b ex:x ( 1 2 3 ) )>> ex:broken true .
}
Loading
Loading