SPARQL 如何在没有数据方案的情况下打印数据

SPARQL How to print the data without data scheme

我有这个 ontology 型号:

SensorOntology:MedicalCabinet-01 rdf:type owl:NamedIndividual ,
                               SensorOntology:MedicalCabinetSensor ;
                      SensorOntology:hasId "57"^^xsd:int ;
                      SensorOntology:hasValue "0"^^xsd:int .

我写了这个查询

SELECT ?sensor ?value
WHERE { ?sensor:hasId "51"^^xsd:int.
        ?sensor :hasValue ?value}

结果是这样

    sensor            |  value
-------------------------------------------------------------------------
    MedicalCabinet-01 | "0"^^<http://www.w3.org/2001/XMLSchema#int>

有没有办法打印这个:

    sensor            |  value
-------------------------------------------------------------------------
    MedicalCabinet-01 | 0

我不想打印 ^^<http://www.w3.org/2001/XMLSchema#int>

你的意思和想省略的是RDF文字的数据类型IRI:

A literal in an RDF graph consists of two or three elements:

  • a lexical form, being a Unicode [UNICODE] string, which should be in Normal Form C [NFC],
  • a datatype IRI, being an IRI identifying a datatype that determines how the lexical form maps to a literal value, and
  • ...

函数可以返回一个字面量的词法形式STR(注意,那么它会是一个字符串):

SELECT ?sensor (STR(?val) as ?value)
WHERE { ?sensor:hasId "51"^^xsd:int.
        ?sensor :hasValue ?val}