On 11/07/12 16:26, Cong Wang wrote:
Hi all,

ex:car1 rdfs:subClassOf ex:SportsCar .

Suppose the sparql query is

select ?x
where {
?x ?y ?z .
}

while, I want to get "ex:car1" as a string, then i use str(?x), however it returns 
"http://.…./ex#car1";, with prefix..I just want "ex:car1". Besides,  using afn:namespace 
or afn:localname doesn't work as well….

Anyone knows how to do that?

If you are doing this in java over a local model then take the result from and do:

   model.shortform( valueOfX )

If you have to do this directly in standard SPARQL then you could use REPLACE to manipulate the string, maybe something like:

SELECT (REPLACE(STR(?x), "^http://.../ex#";, "ex:") AS ?prefixed)  ...

Dave

Reply via email to