Hello Rajeev,

SPARQL-compilant way is

select ?s, ?label where { ?s rdfs:label ?label FILTER(
> langMatches(?label, "ml_IN") || langMatches(?label, "en_IN") ||
> lang(?label) = "" ). } order by ?s

then do application-level sorting.

Virtuoso-specific way could be

select ?s (bif:coalesce (?mllabel, ?enlabel, ?label)) as ?label
where {
  graph ?g {
    { ?s rdfs:label ?label . FILTER(langMatches(?label, "ml_IN")  ||
langMatches(?label, "en_IN") || lang(?label) = "" ) }
    optional { ?s rdfs:label ?mllabel . FILTER(langMatches(?mllabel,
"ml_IN")) }
    optional { ?s rdfs:label ?enlabel . FILTER(langMatches(?enlabel,
"en_IN")) } } }
 order by ?s

but that's inefficient. In SQL it could be possible to write
user-defined aggregate that work like MAX() but choose one best readable
value out of a given list rather than the biggest one out of the list.
Unfortunately, Virtuoso SPARQL does not support user-defined aggregates
ATM.

Best Regards,

Ivan Mikhailov,
OpenLink Software.


On Thu, 2008-04-03 at 09:59 +0530, Rajeev J Sebastian wrote:
> Hello all friends,
> 
> I want to write a query for retrieving rdfs:label's in a
> localization-capable way. I.e., I want to be able to do something like
> 
> select ?s, ?label where { ?s rdfs:label ?label FILTER(
> langMatches(?label, "ml_IN, en_IN") ). }
> 
> In other words, I want a "cascade" of languages i.e., select the ml_IN
> label if it exists, else fallback to the en_IN label, else fallback to
> label with no language set.
> 
> Is this possible in Virtuoso SPARQL ? from the langMatches spec on the
> W3C site and the RFC, I think it is not possible. Could someone give
> some hint how I can achieve this effectively ?
> 
> Regards
> Rajeev J Sebastian
> 
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> Virtuoso-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/virtuoso-devel


Reply via email to