Goodies

Mode

select debug   # debug mode
select more    # approximate search
select check   # type check

Functions

External functions: declare in the namespace the package and the class where an external function is defined:

prefix ext: <function://fr.inria.fun.Extern>
select * (ext:fun(?x) as ?y) where {

}

Semantic similarity for approximate search

select (kg:similarity() as ?sim)  

Semantic similarity between classes

kg:similarity(?c1, ?c2)  

Contain Word Ignore Case And Accent

kg:contains(?text, 'Elégant')

Equal Word Ignore Case And Accent

kg:equal(?text, 'Elégant')

XPath

Mashup of XML data.

select * where {
  graph ?g { <John> foaf:knows ?y }
  {select (xpath(?g, '//foaf:name') as ?name) where {}}
}

SQL

Mashup of relational data.

prefix db: <jdbc:mysql://localhost/>
prefix dr: <com.mysql.jdbc.>

construct {
  ?s foaf:knows ?o
}
where {
  select 
    (sql(db:dbase, dr:Driver, 'username', 'password', 
     'select A, B from C where D') 
    as (?x, ?y)) where {} .
  
  {select (uri(?x) as ?s) (uri(?y) as ?o) where {}}
}

XSLT & SPARQL

XSLT with embedded SPARQL Query with KGRAM/KGRAPH.
Thanx to Fabien Gandon.

public static XSLTQuery create(String xsl, QuerySolver exec);

public String xslt(String doc);
<xsl:stylesheet

xmlns:xalan="http://xml.apache.org/xalan"
xmlns:server="xalan://fr.inria.edelweiss.kgtool.print.XSLTQuery"

extension-element-prefixes="server"
/>

<xsl:param name='engine' />


<xsl:variable name='query1'>
select * where {?x c:FirstName 'John'}
</xsl:variable> 

<xsl:variable name='query2'>
construct {?x c:name 'John'} 
where {?x c:FirstName 'John'}
</xsl:variable> 

<xsl:variable name='res1'  select='server:sparql($engine, $query1)' />

<xsl:variable name='res2'  select='server:sparql($engine, $query2)' />