'Handling NaN (xsd:double) in Turtle

While the special value of NaN is in the value space of xsd:double, and it can be abbreviated in Turtle, Jena 4.4.0 ( riot --sink ) says Unrecognized keyword: NaN. Is this a Jena's specification?

  1. https://www.w3.org/TR/rdf11-concepts/#xsd-datatypes
  2. https://www.w3.org/TR/turtle/#grammar-production-DOUBLE


Solution 1:[1]

A literal in Turtle in full form is lexicalform ^^ datatype .

"1.234e0"^^xsd:double

so NaN as a double is:

"NaN"^^xsd:double

There is an abbreviated form to allow most doubles, for example 1.234e0.

[21]    DOUBLE  ::=     [+-]? ( [0-9]+ '.' [0-9]* EXPONENT   |
                                '.' [0-9]+ EXPONENT          |
                                [0-9]+ EXPONENT
                              )

This abbreviated form does not cover NaN so it can not be abbreviated in Turtle as defined by the standard.

It can be written in the full form.

:s :p "NaN"^^xsd:double .

which Apache Jena parses.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1