开发者

How can you remove the XML schema datattype from sparql query?

开发者 https://www.devze.com 2022-12-13 22:09 出处:网络
Im running a sparql query on a file that contains <User rdf:about=\"#RJ\"> <hasName rdf:datatype=\"http://www.w3.org/2001/XMLSchema#string\">RJ</hasName>

Im running a sparql query on a file that contains

<User rdf:about="#RJ">
<hasName rdf:datatype="http://www.w3.org/2001/XMLSchema#string">RJ</hasName>
</User>

I want to return only the name i.e. 'RJ' but when i enter my query

SELECT ?name
FROM <example.com> 
WHERE { 
       assign:RJ assign:hasName ?name .   
}  

where assign is the correct namespace i return this :

"RJ" ^^<http://www.w3.org/2001/XMLSchema#string>

does anyone have any advice on ho开发者_运维知识库w to remove the xml schema type for a sparql noob?

thanks in advance


Whether you can do this depends on the SPARQL implementation you are using. Under SPARQL 1.0 this isn't possible, however with SPARQL 1.1 which is now widely supported by most implementations having become a W3C recommendation in March 2013 you can use Project Expressions as follows:

SELECT (STR(?name) AS ?StringName)
FROM <example.com>
WHERE {
    assign:RJ assign:hasName ?name
}

Basically a project expression allows you to use any valid SPARQL expression which you could use elsewhere to calculate a new value based on the variables which are previously bound.

0

精彩评论

暂无评论...
验证码 换一张
取 消