I'm trying to solve simple 3x3 Sudoku game inside query.wikidata.org using SPARQL and OWL.
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT ?a12 ?a13 ?a21 ?a23 ?a31 ?a32 WHERE{
:Zahl a owl:Class;
owl:oneOf (:1 :2 :3) .
?a12 a :Zahl.
?a13 a :Zahl.
?a21 a :Zahl.
?a23 a :Zahl.
?a31 a :Zahl.
?a32 a :Zahl.
?a11 owl:sameAs :1.
?a22 owl:sameAs :2.
?a33 owl:sameAs :3.
?a12 owl:differentFrom ?a11 ?a13 ?a22 ?a32.
?a13 owl:differentFrom ?a11 ?a12 ?a23 ?a33.
?a21 owl:differentFrom ?a22 ?a23 ?a11 ?a31.
?a23 owl:differentFrom ?a22 ?a21 ?a13 ?a33.
?a31 owl:differentFrom ?a11 ?a21 ?a32 ?a33.
?a32 owl:differentFrom ?a12 ?a22 ?a31 ?a33.
}
But i get this error:
Query is malformed: Encountered " <PNAME_LN> "owl:oneOf "" at line 5, column 19.
Could somebody please point out my mistake?
Hello my fellow friend from Karlsruhe,
your basic mistake is that you try to define objects in your query - :Zahl a owl:Class; owl:oneOf (:1 :2 :3) .
The query is not the place for that. This can only be done in the rdf document - which should not be changed in the exercise. Another mistake is a wrong understanding of objects and literals: ...owl:oneOf (:1 :2 :3) . ... ?a11 owl:sameAs :1. ?a22 owl:sameAs :2. ?a33 owl:sameAs :3.
owl:sameAs does not wirk on literals, so these are objects named 1, 2, and 3. You could work with objects named 1,2,3, but it is a lot easier to work with numbers (literals) and use filters (FILTER (?a11 = 1)).
Based on our source rdf, i think this is the way things should be done, as these are defined literals: ex:field ex:allowed "1"^^xsd:int, "2"^^xsd:int, "3"^^xsd:int. Cheers!