2

Is it possible in OWL to restrict a Property with a range like

demo:property rdfs:range rdf:langString

so that we only allow "en" and "de" as languages?

So

demo:object demo:property "hello"@en

would be allowed, but

demo:object demo:property "bonjour"@fr

would not.

Natan Cox
  • 1,495
  • 2
  • 15
  • 28
  • 1
    `rdf:langString` was created and standardised with RDF 1.1 in 2014, while the latest version of OWL, OWL 2, was standardised in 2009, then updated in 2012. So OWL does not use `rdf:langString` at all. Instead, it defines the special datatype `rdf:PlainLiteral` which works as [Stanislav](https://stackoverflow.com/a/49425926/1260887) explains in his answer. – Antoine Zimmermann Aug 27 '18 at 20:05

1 Answers1

3

From 4.3 Strings:

The OWL 2 datatype map provides the rdf:PlainLiteral datatype for the representation of strings in a particular language. The definitions of the value space, the lexical space, the facet space, and the necessary mappings are given in [RDF:PLAINLITERAL]. The normative constraining facets for rdf:PlainLiteral are xsd:length, xsd:minLength, xsd:maxLength, xsd:pattern, and rdf:langRange; furthermore, only basic language ranges [BCP 47] are supported in the rdf:langRange constraining facet.

Thus, in the Manchester syntax:

DataProperty: demo:property
    Range: 
        (rdf:PlainLiteral[langRange "de"] or rdf:PlainLiteral[langRange "en"]

In Turtle:

demo:property a owl:DatatypeProperty ;
    rdfs:range [ rdf:type rdfs:Datatype ;
        owl:unionOf ( [ rdf:type rdfs:Datatype ;
                        owl:onDatatype rdf:PlainLiteral ;
                        owl:withRestrictions ( [ rdf:langRange "de" ] )
                      ]
                      [ rdf:type rdfs:Datatype ;
                        owl:onDatatype rdf:PlainLiteral ;
                        owl:withRestrictions ( [ rdf:langRange "en" ] )
                      ]
                    )
                ] .

Now create 3 individuals (in Turtle):

demo:object_en a owl:NamedIndividual ;
               demo:property "demo"@en .

demo:object_de a owl:NamedIndividual ;
               demo:property "demo"@de .

demo:object_fr a owl:NamedIndividual ;
               demo:property "demo"@fr .

Then start a reasoner and look into inconsistency explanation.

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58