0

I'm uploading triples to an AG store from a graph generated in python by rdflib. Some of the objects in my triples are floats, so I add them to the graph like this:

Literal(float(float_value), datatype=XSD.float)

When I serialize the graph using rdflib I get "0.8049"^^xsd:float as intended.

But, after uploading it to the AG store, when I query the store, the literals I get back are like this (trix)

<typedLiteral datatype="http://www.w3.org/2001/XMLSchema#float">8.049E-1</typedLiteral>

I've tried all sorts of combinations, like uploading it as a string "8049E-0", or just as a string "0.8049" and such, but I haven't hit on the right incantation to get the decimal in the right place.

Any thoughts?

Jon

jjon
  • 680
  • 1
  • 8
  • 23
  • 1
    A typed literal is a combination of a lexical form and a datatype, and represents some particular value in the data space. The literals `"0.8049"^^xsd:float` and `"0.049E-1"^^xsd:float` represent the same data value (notice the `E-1` at the end of the lexical form of the latter). They're just different printed representations of the same value. It's rather suspicious if you're doing something where the printed representation of a value makes a difference. In general, there may lots of different ways a value can be serialized. – Joshua Taylor Dec 03 '13 at 13:08

1 Answers1

0

Doh!

Not the first time I've made things more complicated than they need to be. These Literals aren't floats, they're just decimal numbers. XSD has a perfectly good datatype for these.

added to the graph in rdflib thus:

Literal(value, datatype=XSD.decimal)

returns from the AG store thus:

<typedLiteral datatype="http://www.w3.org/2001/XMLSchema#decimal">0.8049</typedLiteral>

sorry for the noise, jjc

jjon
  • 680
  • 1
  • 8
  • 23