Re: decompose a URI by colon in SPARQL

On 2011-11-22, at 15:54, Jitao Yang wrote:

> Dear all,
> 
> In SPARQL, how to decompose a URI in the form of   a:b  just by the colon(:), assumed that we do not know what a or b is, such as we can not use STRLEN to calculate their length.

In SPARQL 1.1 you can use REPLACE. http://www.w3.org/2009/sparql/docs/query-1.1/rq25.xml#func-replace

BIND(REPLACE(?uri, ":.*$", "") AS ?prefix))
BIND(REPLACE(?uri, "^.*:", "") AS ?postfix))

Will give you bit before the : of ?uri in ?prefix, and the rest in ?postfix.

REPLACE is probably not implemented in all that many systems yet though, so you might want to see if someone else has a solution.

- Steve

-- 
Steve Harris, CTO, Garlik Limited
1-3 Halford Road, Richmond, TW10 6AW, UK
+44 20 8439 8203  http://www.garlik.com/
Registered in England and Wales 535 7233 VAT # 849 0517 11
Registered office: Thames House, Portsmouth Road, Esher, Surrey, KT10 9AD

Received on Tuesday, 22 November 2011 17:36:15 UTC