kzs
kzs

Reputation: 1111

Is this turtle statement syntactically correct?

I want to set a restriction on mybrandofmercedes class as written below in OWL, is this syntactically correct? should I have square brackets as shown below?

mynamespace: mybrandofmercedes rdf:type owl:Class;

mynamespace: mybrandofmercedes
[

rdf:type owl:Restriction;

owl:onProperty mynamespace:hasOwner;

owl:hasValue mynamespace: Anders

]

Upvotes: 0

Views: 320

Answers (1)

Joshua Taylor
Joshua Taylor

Reputation: 85863

No.

But there are a few different things that can be problems. First, OWL is an abstract language. It can be written in a few different forms, some of which are concrete (e.g., OWL/XML and the OWL Functional Syntax), while some are abstract. An OWL ontology can be serialized into RDF. RDF, like OWL, is also an abstract language, but has several kinds of serializations, or which Turtle is just one. So, there are a few questions you can ask:

  1. Is this legal Turtle?
  2. If this is legal Turtle, is the RDF is represents a legal RDF serialization of an OWL ontology.

First, this isn't legal Turtle. I'll assume that instead of mynamespace: mybrandofmercedes, you meant mynamespace:mybrandofmercedes. Then your text would be the following (reformatted, and with some prefix declarations, and a final period):

@prefix mynamespace: <urn:ex:>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.

mynamespace:mybrandofmercedes
  rdf:type owl:Class ;
  mynamespace:mybrandofmercedes [ rdf:type owl:Restriction;
                                  owl:onProperty mynamespace:hasOwner;
                                  owl:hasValue mynamespace:Anders ] .

Now, that's legal Turtle, but it's probably not the triples that you want. That is, it's not the RDF serialization of an OWL ontology. If we serialize that as N-Triples, you can see the five triples that it contains. I very much don't expect that you wanted to use <urn:ex:mybrandofmercedes> as both a subject and a predicate. At any rate, it's not an OWL ontology.

<urn:ex:mybrandofmercedes> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
<urn:ex:mybrandofmercedes> <urn:ex:mybrandofmercedes> _:B .
_:B <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Restriction> .
_:B <http://www.w3.org/2002/07/owl#onProperty> <urn:ex:hasOwner> .
_:B <http://www.w3.org/2002/07/owl#hasValue> <urn:ex:Anders> .

If you're trying to generate OWL, I'd suggest that you start with an OWL editing tool (e.g., Protégé) or one of the OWL syntaxes that is easier to write, and then get the RDF from that. After quickly firing up Protégé, I came up with an ontology that, serialized in Turtle, looks like this:

@prefix :      <http://example.org/cars#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .

<http://example.org/cars>
        a       owl:Ontology .

:Car    a       owl:Class .
:Person  a      owl:Class .
:hasOwner  a    owl:ObjectProperty .

:Anders  a      owl:NamedIndividual , :Person .

:CarOwnedByAnders  a     owl:Class ;
        rdfs:subClassOf  :Car ;
        rdfs:subClassOf  [ a               owl:Restriction ;
                           owl:hasValue    :Anders ;
                           owl:onProperty  :hasOwner
                         ] .

You specifically asked about the placement of the brackets. That wasn't the real problem with your code snippet, but if you want to read more about them, you can take a look at my answer to Meaning of square brackets "[]" when querying RDF with SPARQL?. It specifically asks about brackets in SPARQL queries, but the syntax is shared with Turtle, so it applies here, too.

Upvotes: 6

Related Questions