# STRDT() ignores xsd:nonNegativeInteger datatypes

**URL:** https://community.stardog.com/t/strdt-ignores-xsd-nonnegativeinteger-datatypes/639
**Category:** Bug
**Created:** [October 12, 2017, 1:24pm UTC](https://community.stardog.com/t/strdt-ignores-xsd-nonnegativeinteger-datatypes/639 "2017-10-12T13:24:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![d.kontokostas](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@d.kontokostas](https://community.stardog.com/u/d.kontokostas)
#### Post date: [October 12, 2017, 1:24pm UTC](https://community.stardog.com/t/strdt-ignores-xsd-nonnegativeinteger-datatypes/639/1 "2017-10-12T13:24:56Z")

</div>

Hello, I am using the STRDT() to construct some RDF data and the function ignores the `xsd:nonNegativeInteger` parameters

To reproduce the problem you can run the following:

```auto
insert data {<http://ex.com/s> <http://ex.com/p> 1}

```

```auto
INSERT {
    <http://ex.com/s2> <http://ex.com/p> ?o .
} WHERE {
        <http://ex.com/s> <http://ex.com/p> ?o_raw .
        BIND( STRDT(STR(?o_raw), xsd:nonNegativeInteger) AS ?o)
}

```

running

```auto
select * where {?s <http://ex.com/p> ?o}

```

return values with xsd:integer datatype only

is this behavior expected?

---

<div class="post-metadata">

### Author: ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)
#### Post date: [October 12, 2017, 2:25pm UTC](https://community.stardog.com/t/strdt-ignores-xsd-nonnegativeinteger-datatypes/639/2 "2017-10-12T14:25:54Z")

</div>

Interestingly, anything that is not an integer comes back with the given datatype.

```
stardog query test 'select * where {bind(strdt("test", xsd:nonNegativeInteger) as ?o)}'

"test"^^xsd:nonNegativeInteger

```

Anything that is an integer comes back as an integer

```
stardog query test 'select * where {bind(strdt("1", xsd:nonNegativeInteger) as ?o)}'

1

```

It also behaves similarly for the subtypes xsd:nonPositiveInteger, xsd:long, xsd:nonNegativeInteger. I suspect that it is correct and has something to do with D-Interpretations and Datatype Entailment [RDF 1.1 Semantics](https://www.w3.org/TR/2014/REC-rdf11-mt-20140225/#D_interpretations) but I'm not familiar with all the details there.

---

<div class="post-metadata">

### Author: ![evren](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/evren/32/1515_2.png) [@evren](https://community.stardog.com/u/evren)
#### Post date: [October 12, 2017, 2:56pm UTC](https://community.stardog.com/t/strdt-ignores-xsd-nonnegativeinteger-datatypes/639/3 "2017-10-12T14:56:12Z")

</div>

This is the expected result because Stardog canonicalizes literals. All integer subtypes map to the same value space in the XSD spec so they are equivalent values which is why we do this canonicalization. See the `index.literals.canonical` option mentioned in [1] and described in more detail at [2]. If you disable this option then all literals will use the assigned types. Note that, without this option your queries will need to use the exact same datatypes to match your data or you'll need to rely on `=` FILTERs.

Best,  
Evren

[1] [Home | Stardog Documentation Latest](http://www.stardog.com/docs/#_configuration_options)  
[2] [Stardog-8.2.0 API](http://www.stardog.com/docs/java/snarl/com/complexible/stardog/index/indexoptions#CANONICAL_LITERALS)
