virtuoso-opensource icon indicating copy to clipboard operation
virtuoso-opensource copied to clipboard

datatype of a literal with a language tag

Open galgonek opened this issue 10 years ago • 9 comments
trafficstars

Hi,

the function datatype should return rdf:langString, if the literal has a language tag. However, the following query does not return the expected result:

select ?literal datatype(?literal) as ?type where
{
  values ?literal { "simple" "typed"^^xsd:string "lang"@en }
}

galgonek avatar Jun 17 '15 17:06 galgonek

+1 @HughWilliams Is this planned to be fixed?

jakubklimek avatar Dec 18 '15 08:12 jakubklimek

What is the expectation, that datatype of the "lang" literal of the query below, is returned as http://www.w3.org/1999/02/22-rdf-syntax-ns#langString i.e. rdf:langString rather than "NULL" ?

SQL> sparql select ?literal datatype(?literal) as ?type where {   values ?literal { "simple" "typed"^^xsd:string "lang"@en } };
literal                                                                           type
LONG VARCHAR                                                                      LONG VARCHAR
_______________________________________________________________________________

simple                                                                            http://www.w3.org/2001/XMLSchema#string
typed                                                                             http://www.w3.org/2001/XMLSchema#string
lang                                                                              NULL

3 Rows. -- 5 msec.
SQL>

HughWilliams avatar Dec 28 '15 23:12 HughWilliams

Yes, exactly.

jakubklimek avatar Dec 29 '15 09:12 jakubklimek

ok, I have logged this for development to look into and fix ...

HughWilliams avatar Dec 29 '15 10:12 HughWilliams

@HughWilliams any info on this? The same issue is with literals with no datatype and language tag. Those should be xsd:string according to RDF 1.1 (https://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal)

jakubklimek avatar Jun 20 '17 07:06 jakubklimek

This is still be be looked into by development, I have added the additional information to the internal bug report on this ...

HughWilliams avatar Jun 23 '17 10:06 HughWilliams

Still an issue, but the behavior also depends on the language tag:

SELECT * WHERE {
  VALUES ?v {"" "a" "b" ""@en "a"@en "b"@en ""@de "a"@de "b"@de ""@es "a"@es "b"@es ""@nl "a"@nl "b"@nl }
  BIND(lang(?v) AS ?ln)
  BIND(datatype(?v) AS ?dt)
  BIND(BOUND(LANG(?v)) AS ?lnBound) 
  BIND(BOUND(datatype(?v)) AS ?dtBound)
}

returns

v ln dt lnBound dtBound
"" http://www.w3.org/2001/XMLSchema#string 1 1
"a" http://www.w3.org/2001/XMLSchema#string 1 1
"b" http://www.w3.org/2001/XMLSchema#string 1 1
""@en http://www.w3.org/2001/XMLSchema#string 1 1
"a"@en http://www.w3.org/2001/XMLSchema#string 1 1
"b"@en http://www.w3.org/2001/XMLSchema#string 1 1
""@de http://www.w3.org/2001/XMLSchema#string 1 1
"a"@de de 1 0
"b"@de de 1 0
""@es es 1 0
"a"@es es 1 0
"b"@es es 1 0
""@nl http://www.w3.org/2001/XMLSchema#string 1 1
"a"@nl http://www.w3.org/2001/XMLSchema#string 1 1
"b"@nl http://www.w3.org/2001/XMLSchema#string 1 1

What is wrong:

  • different behavior for different language tags (e.g. "a"@en vs. "a"@de)
  • different behavior for different lexicals (e.g. ""@de vs. "a"@de)
  • lnBound = 1 but ln is empty, even if no lang tag was defined
  • no/wrong datatype (expected rdf:langString) for literals with lang tag

I think, #946 is related to this.

jmkeil avatar Feb 01 '22 13:02 jmkeil

Thanks for the extra detail, @jmkeil. I've connected this with our internal tracker for this issue, bug#17168.

TallTed avatar Feb 01 '22 16:02 TallTed

Experiencing the same issue regarding literals with language tag, datatype(?literal) is NULL instead of rdf:langString. Please, note that this issue is not among the test cases listed in #946 by @jakubklimek

rogargon avatar Apr 01 '22 17:04 rogargon