Hi I don't really understand the difference between xsd:string and the PlainLiteral. My purpose is to store text with language tag. which one should I use?


asked 13 Nov '12, 03:46

Mutaz's gravatar image

accept rate: 0%

Plain literals are literals that may have a language tag, while xsd:string never has a language tag. But in fact, plain literals without language tag (what SPARQL calls "simple literals") are exactly the same as xsd:string-typed literals, provided that the tool used to manipulate the literals have support for this XSD datatype. In some cases, it may happen that a tool has no support for datatypes (which is uncommon), and in this case "blabla"^^xsd:string just looks like "blabla"^^xyz:abc.

rdf:PlainLiteral was made essentially to be able to specify that a property has a range restricted to plain literals, and similar assertions (which were not possible otherwise) but it's not intended to be used in a literal.

In any case, do not use PlainLiteral. For two reasons:

  1. The specification says so: "rdf:PlainLiteral literals are written as RDF plain literals in RDF and SPARQL syntaxes", which means, one has to write "abc" instead of "abc@"^^rdf:PlainLiteral, and "hello"@en instead of "hello@en"^^rdf:PlainLiteral.
  2. The RDF 1.1 Working Group is preparing a new version of RDF where the notion of plain literals will disappear. The concrete syntax remains the same, but "abc" in concrete syntax will be a short cut for "abc"^^xsd:string, and language-tagged plain literals will be in fact typed literals with type rdf:langString. See Section 3.3 Literals of RDF 1.1 Concepts and Abstract Syntax.
permanent link

answered 13 Nov '12, 04:14

Antoine%20Zimmermann's gravatar image

Antoine Zimm... ♦
accept rate: 34%

edited 13 Nov '12, 04:15

Thanks Antoine for the comprehensive answer. So you think using rdf:langString for language-tagged strings is a good idea?

(13 Nov '12, 05:43) Mutaz Mutaz's gravatar image

I'm using TopBraid composer and rdf:langString doesn't seem to be available as a literal type. I think I will use xsd:string in this case. What do you think?

(13 Nov '12, 05:54) Mutaz Mutaz's gravatar image

In fact, you don't explicitly use rdf:langString in a literal. The type is implicit whenever you use a language tag, e.g., "hello"@en looks untyped but it is, according to RDF 1.1 specification, a literal of type rdf:langString. This type never appears in a literal. However, you may use rdf:langString as a range for a property, in order to say that the property requires natural language rather than plain strings.

(13 Nov '12, 14:44) Antoine Zimm... ♦ Antoine%20Zimmermann's gravatar image

So, currently in october 2013, as RDF 1.1 is not implemented yet in the existing tools, what would you suggest to use as a range for a property when it is a plain literal ? is it ok to simply use "xsd:string", and have triples containing a "mytext"@en ? Thanks.

(02 Oct '13, 03:29) Fabian Cretton Fabian%20Cretton's gravatar image

Fabian, language tagged literals are not of type xsd:string, neither in RDF 1.1, nor in RDF 1.0, nor in OWL 2. If you want to express that a datatype property has a range in language-tagged literals, use rdf:PlainLiteral for the moment and possibly add rdf:langString too.

(02 Oct '13, 06:35) Antoine Zimm... ♦ Antoine%20Zimmermann's gravatar image

thank you, but I just read your post here above saying "In any case, do not use PlainLiteral"...so quite a bit confusing ;-)

(02 Oct '13, 07:25) Fabian Cretton Fabian%20Cretton's gravatar image
showing 5 of 6 show 1 more comments
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 13 Nov '12, 03:46

question was seen: 1,764 times

last updated: 02 Oct '13, 07:28