Saturday, July 01, 2006

SPARQL query for classification

After spidering uBio the next task is how to display the classification of a taxon. The following SPARQL query does the trick:

PREFIX ubio: <>
PREFIX gla: <>
PREFIX rdf: <>
PREFIX dc: <>

SELECT DISTINCT ?node, ?title, ?rank, ?name, ?description

<> gla:objectiveSynonym ?display .
?class ubio:namebankIdentifier ?display .
?class ubio:classificationName ?name
?class ubio:classificationDescription ?description .
?class gla:lineage ?seq .
?seq ?li ?node .
?node dc:title ?title .
?node gla:rank ?rank

This query takes a canonical name in uBio, finds the display form, and from that the classification. The lines

?class gla:lineage ?seq .
?seq ?li ?node .

fetch the lineage which is stored as a sequence:

<rdf:li rdf:resource=""/>
<rdf:li rdf:resource=""/>
<rdf:li rdf:resource=""/>

This method of describing a taxonomic lineage was described in my paper in
Biodiversity Informatics
. uBio serves the lineage from lower to higher taxon (i.e., bottom up), but I want to display it top down. I do all display using XSLT style sheets, so we use the <xsl:sort order="descending"> trick (see here for an example). Then it's simply a case of indenting each node using <xsl:value-of select="18 * (position()-1)"/>, and borrowing uBio's end.png to get the tree effect.


Post a Comment

<< Home