Hi  Andy,
 
I tried this (based on what you suggested):
 
PREFIX hazop:<http://www.owl-ontologies.com/Ontology1372961464.owl#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
SELECT ?No ?Desvio (REPLACE(str(?YourVariable), '^.*(/|#)') AS ?localName) 
WHERE { ?No hazop:hasDeviation ?Desvio.
                  ?Desvio rdfs:label ?localName.}
 
It didn't work and I got this error message:
 
Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: Lexical 
error at line 1, column 147.  Encountered: "(" (40), after : "REPLACE"
 at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:96)
 at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse(ParserSPARQL11.java:40)
 at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:132)
 at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:69)
 at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:40)
 at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:28)
 at testesontologia.TestesOntologiaHazop.main(TestesOntologiaHazop.java:91)
 
Thank you for your help,
 
Anthony Diniz
  

________________________________
 From: Andy Seaborne <[email protected]>
To: [email protected] 
Sent: Tuesday, July 23, 2013 2:03 PM
Subject: Re: Doubt about SPARQL
  

On 23/07/13 17:53, Anthony Diniz wrote:
> Thank you, Joshua.
> My case is the 3rd one. Can you give me an example? I have 
> foo:someIndividual, but I would like just "someIndividual", without having to 
> process the answer as string with Java.
>
> Thank you again,
>
> Anthony


REPLACE(str(?YourVariable), '^.*(/|#)')

will calculate the local part for your example.

SELECT ... ?localName {
...
    BIND(REPLACE(str(?YourVariable), '^.*(/|#)') AS ?localName)
....
}


or
SELECT ... (REPLACE(str(?YourVariable), '^.*(/|#)') AS ?localName)
WHERE
{ ... }


>
> Enviado via iPhone
>
> Em 2013-07-23, às 12:24, Joshua TAYLOR <[email protected]> escreveu:
>
>> On Tue, Jul 23, 2013 at 9:57 AM, Anthony Ramalho
>> <[email protected]> wrote:
>>> I'd like to know if somebody knows a way of hiding the prefix from results 
>>> in SPARQL queries.
>>> If yes, is it possible showing some kind of example?
>>
>> What do you mean by "hiding the prefix"?

And how are you processing the results?  Using ResultSetFormatter?

>>
>>
>> 1) Are you currently getting results like: foo:someIndividual but you
>> want <http://foo.com/.../someIndividual>, i.e., you want to to show
>> the full IRI, and not use a prefix?
>>
>> 2) Are you currently getting results like
>> <http://foo.com/.../someIndividual> and you want to hide the prefix
>> (of the IRI) "http://foo.com/.../"; and show foo:someIndividual
>> instead?
>>
>> 3) Are you currently getting results like
>> <http://foo.com/.../someIndividual> or foo:someIndividual, and you
>> want to just have someIndividual instead?
>>
>> All three are possible, but they require different approaches.
>>
>> //JT
>> --
>> Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Reply via email to