Hi Andy,
Yeah, that's pretty close. I originally posted this thread, cause I found
myself looking at
http://answers.semanticweb.com/questions/10457/calculating-and-extracting-a-substring-in-sparqlagain.
All the answers there were close, but just slightly off. I've
posted what I now think is the
I suspect that the afn:localname is implementing the same algorithm as
Jena's Resource#getLocalname.
That is used to split a URI into a namespace/localname such that the
localname can legally be used in e.g. RDF/XML serialization. That means
it has to be a legal NCNAME which means it can't
A form of localname can be done in SPARQL without the need for
extension functions:
REPLACE(str(?uri), '^.*(#|/)', '')
which returns the part after the last / or #
Andy
makes sense now.
Can I suggest making this small change to the docs (
http://jena.apache.org/documentation/query/library-function.html), for
future travelers:
The local name of ?x if a IRI. Based on splitting the IRI, not on any
prefixes in the query or dataset, in order to achieve the longest
On 07/05/14 19:36, Tim Harsch wrote:
Why does this query:
PREFIX afn:http://jena.hpl.hp.com/ARQ/function#
SELECT ?s2
WHERE
{
BIND(http://example.org/book/book2/sadfju/62eja AS ?uri)
BIND( afn:localname(?uri) AS ?s2 )
}
give this answer:
-
| s2|
=
| eja |
-