GithubHelp home page GithubHelp logo

mathias-goebel / exist-sparql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ljo/exist-sparql

0.0 2.0 0.0 4.72 MB

Integrates SPARQL and RDF indexing through the Jena TDB libraries into eXist-db.

License: GNU General Public License v3.0

Emacs Lisp 10.11% Java 56.03% XQuery 15.20% HTML 5.41% CSS 13.24%

exist-sparql's Introduction

exist-sparql

Integrates SPARQL and RDF indexing through the Jena TDB libraries into eXist-db.

Compile and install

If you installed the app through the package manager you only need to do step 5 and restart.

  1. clone the github repository: https://github.com/ljo/exist-sparql.git

  2. You may then either build with Apache Maven (preferred) or Apache Ant.

    1. To build with Apache Maven: mvn clean compile package

    2. or, to build with Apache Ant: ant

  3. upload the xar file found in target/ into eXist-db using the dashboard

  4. enable the Index module in conf.xml, by adding one module declaration under "indexer/modules":

<module id="rdf-index" class="org.exist.indexing.rdf.TDBRDFIndex"/>
  1. Restart eXist-db.

Overview

Currently there is one function with the signature sparql:query($sparql-query as xs:string) as node() available. See the usage example below.

Usage example

xquery version "3.0";
import module namespace sparql="http://exist-db.org/xquery/sparql" at
 "java:org.exist.xquery.modules.rdf.SparqlModule";

declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
let $rdftest-coll := xmldb:create-collection("/db", "rdftest")
let $rdftest-conf-coll := xmldb:create-collection("/db/system/config/db", "rdftest")
let $rdf-conf :=
    <collection xmlns="http://exist-db.org/collection-config/1.0">
       <index xmlns:xs="http://www.w3.org/2001/XMLSchema">
          <rdf />
       </index>
    </collection>;
let $rdf-xml-1 :=
    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:myhouse="myhouse://">
        <rdf:Description rdf:about="myhouse://table">
            <rdf:type rdf:resource="myhouse://furniture" />
            <myhouse:room rdf:resource="kitchen" />
            <myhouse:count>1</myhouse:count>
        </rdf:Description>
    </rdf:RDF>;
let $rdf-xml-2 :=
    <rdf:RDF
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:myhouse="myhouse://">
        <rdf:Description rdf:about="myhouse://chair">
            <rdf:type rdf:resource="myhouse://furniture" />
            <myhouse:room rdf:resource="kitchen" />
            <myhouse:count>2</myhouse:count>
        </rdf:Description>
        <rdf:Description rdf:about="myhouse://window">
            <myhouse:count>3</myhouse:count>
        </rdf:Description>
    </rdf:RDF>
let $dummy1 := xmldb:store($rdftest-conf-coll, "collection.xconf", $rdf-conf)
let $dummy2 := (xmldb:store($rdftest-coll, "myhouse1.rdf", $rdf-xml-1),
               	xmldb:store($rdftest-coll, "myhouse2.rdf", $rdf-xml-2))

let $query1 := ("PREFIX myhouse: <myhouse://>
                SELECT ?x
                WHERE { ?x a myhouse:furniture }
                ORDER BY ?x")

(: ("myhouse://chair", "myhouse://table") :)

let $query2 := ("PREFIX myhouse: <myhouse://>
                SELECT ?x ?c
                WHERE { ?x myhouse:count ?c ; a myhouse:furniture }
                ORDER BY ASC(?c)")
(: ("myhouse://table", "1", "myhouse://chair", "2") :)

let $query3 := ("PREFIX myhouse: <myhouse://>
                SELECT ?x ?r
                WHERE { ?x myhouse:room ?r }
                ORDER BY ASC(?c)")
(: ("myhouse://chair", "kitchen", "myhouse://table", "kitchen") :)

let $queries := ($query1, $query2, $query3)

return
  for $query in $queries
    (: return sparql:query($query)//text() :)
    return sparql:query($query)//sr:uri

exist-sparql's People

Contributors

adamretter avatar ljo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.