Skip to content

Instantly share code, notes, and snippets.

let $books :=
<books>
<book class="fiction">Book of Strange New Things</book>
<book class="nonfiction">Programming Scala</book>
<book class="fiction">Absurdistan</book>
<book class="nonfiction">Art of R Programming</book>
<book class="fiction">I, Robot</book>
</books>
for $book in $books/book
let $title := $book/text()||"&#10;"
@baskaufs
baskaufs / gist:5fd10712361e27b7c2c4
Created April 17, 2015 21:30
finding document URIs for attributes with leading or trailing whitespace
xquery version "3.0";
declare namespace vra="http://www.vraweb.org/vracore4.htm";
for $name in fn:collection("Metadata")//vra:agent
(:where substring($name/vra:name/text(),1,5)="Burri":)
where normalize-space($name/vra:name/@refid/data()) != $name/vra:name/@refid/data()
return $name/vra:name/text()||"&#10;"||base-uri($name/vra:name)||"&#10;"||"&#10;"
@baskaufs
baskaufs / gist:045687fa9c14df8d33b9
Created May 26, 2015 14:57
query with problematic default namespace declaration
xquery version "3.0";
declare namespace sitemap="http://www.sitemaps.org/schemas/sitemap/0.9";
(:
*********** Get data from GitHub *********
:)
let $textOrganisms := http:send-request(<http:request method='get' href='https://raw.githubusercontent.com/baskaufs/Bioimages/master/organisms.csv'/>)[2]
let $xmlOrganisms := csv:parse($textOrganisms, map { 'header' : true(),'separator' : "|" })
(:
@baskaufs
baskaufs / generic-image-query.rq
Created May 28, 2015 18:15
generic SPARQL query to screen images
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dwc: <http://rs.tdwg.org/dwc/terms/>
PREFIX ac: <http://rs.tdwg.org/ac/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dsw: <http://purl.org/dsw/>
PREFIX Iptc4xmpExt: <http://iptc.org/std/Iptc4xmpExt/2008-02-29/>
SELECT DISTINCT ?genus ?species ?uri
WHERE {
?organism foaf:depiction ?image.
@baskaufs
baskaufs / gist:55d5377422a641c5447c
Created May 30, 2015 11:54
cURL syntax to query the TDWG sandbox SPARQL endpoint
curl --data-urlencode "[email protected]" http://tdwg-rdf.phylodiversity.net/store2/sparql
@baskaufs
baskaufs / gist:f44b931263b006e13fd0
Created May 30, 2015 12:56
GBIF API call to retrieve JSON for an occurrence record by its occurrenceID
http://api.gbif.org/v1/occurrence/search?occurrenceID=http%3A%2F%2Fbioimages.vanderbilt.edu%2Find-baskauf%2F28747%232003-07-25
@baskaufs
baskaufs / test.sparql
Created May 30, 2015 14:09
very simple SPARQL query to test retrieving results from and entpoint
SELECT DISTINCT ?image WHERE {
<http://bioimages.vanderbilt.edu/ind-baskauf/00000> <http://xmlns.com/foaf/0.1/depiction> ?image.
}
@baskaufs
baskaufs / gist:cfd09ce81a776110b408
Created May 31, 2015 12:20
URL to query the TDWG sandbox SPARQL endpoint
http://tdwg-rdf.phylodiversity.net/store2/sparql?query=SELECT%20DISTINCT%20%3Fimage%20WHERE%20%7B%3Chttp%3A%2F%2Fbioimages.vanderbilt.edu%2Find-baskauf%2F00000%3E%20%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2Fdepiction%3E%20%3Fimage.%7D
@baskaufs
baskaufs / javascript-http-get.htm
Created May 31, 2015 18:07
test using Javascript to request a cross-domain HTTP GET
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>test HTTP GET from cross-domain URL using Javascript</title>
</head>
<body>
This will send an HTTP GET request to a URL.
<script type="text/javascript">
var http = new XMLHttpRequest();
var url = "http://api.gbif.org/v1/occurrence/search?occurrenceID=http%3A%2F%2Fbioimages.vanderbilt.edu%2Find-baskauf%2F28747%232003-07-25";
@baskaufs
baskaufs / gist:f3eca39d586a2d35ec11
Created June 1, 2015 12:19
modified ajax with error handler
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>test HTTP GET from cross-domain URL using Javascript</title>
</head>
<body>
This will send an HTTP GET request to a URL.
<script type="text/javascript">
var http = new XMLHttpRequest();
var url = "http://api.gbif.org/v1/occurrence/search?occurrenceID=http%3A%2F%2Fbioimages.vanderbilt.edu%2Find-baskauf%2F28747%232003-07-25";