Skip to content

Instantly share code, notes, and snippets.

View CliffordAnderson's full-sized avatar

Clifford Anderson CliffordAnderson

View GitHub Profile
@CliffordAnderson
CliffordAnderson / marcxml.xqy
Created August 26, 2015 23:54
Example XQuery for Sara S.
xquery version "3.1";
declare namespace marc = "http://www.loc.gov/MARC21/slim";
let $individual := <ignore-me><marc:controlfield tag="008">141001s2012 gaua 000 p eng d</marc:controlfield></ignore-me>
let $header := $individual/marc:controlfield[@tag='008']/text()
let $publoc := fn:substring($header,16,3)
where $publoc = ("gau", "other", "codes")
return $publoc
@CliffordAnderson
CliffordAnderson / expression.xqy
Last active August 28, 2015 15:26
Examples for XQuery Workgroup
xquery version "3.1";
import module namespace corpus = "http://library.vanderbilt.edu/baudelaire" at "corpus.xqm";
corpus:search("chat")
@CliffordAnderson
CliffordAnderson / sorting-marc.xqy
Created August 28, 2015 18:29
Tricky Metadata Problem
xquery version "3.1";
declare namespace marc="http://www.loc.gov/MARC21/slim";
let $csv := element csv {
let $records := fn:doc("https://raw.githubusercontent.com/sterkenburgsara/MARCXML-projects/master/Artists'%20Books/artistsbk.xml")//marc:collection/marc:record
for $record in $records
let $leader := $record/marc:leader/text()
let $title :=
($record//marc:datafield[@tag='245']//text()
except $record//marc:subfield[@code="c"]/text())
@CliffordAnderson
CliffordAnderson / mods.xml
Created February 6, 2014 21:09
A model MODS document
<?xml version="1.0" encoding="UTF-8"?>
<mods xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-5.xsd">
<titleInfo>
<title/>
</titleInfo>
<name type="personal"/>
<typeOfResource>text</typeOfResource>
<language>
<languageTerm/>
@CliffordAnderson
CliffordAnderson / oxygen
Created February 7, 2014 22:34
Webdav URL
http://localhost:8080/exist/webdav/db/
@CliffordAnderson
CliffordAnderson / twilio-auth.xml
Last active August 29, 2015 13:56
Twilio Authorization File
<!-- Enter your Twilio username and password -->
<auth xmlns="http://twilio/auth">
<userName>##################</userName>
<password>##################</password>
<phoneNumber>##########</phoneNumber>
</auth>
@CliffordAnderson
CliffordAnderson / twilio-contacts.xml
Created February 8, 2014 21:24
Twilio Contact Card
<ids xmlns="http://twilio/contacts">
<phone number="+1##########" option="1">
<name>####</name>
</phone>
<phone number="+1##########" option="2">
<name>####</name>
</phone>
<phone number="+1##########" option="3">
<name>####</name>
</phone>
@CliffordAnderson
CliffordAnderson / tei-info.xqy
Created February 10, 2014 22:57
Here's the query we started in class today.
xquery version "3.0";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
let $tei := fn:doc("db/test/tei.xml")
let $title := $tei/tei:TEI/tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:title/text()
let $author := $tei/tei:TEI/tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:author/text()
return ($author, $title)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@CliffordAnderson
CliffordAnderson / tei-to-mods.xqy
Last active August 29, 2015 13:56
Sample query for class
xquery version "3.0";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare namespace mods = "http://www.loc.gov/mods/v3";
declare function local:gather-information($tei as document-node()) as xs:string* {
let $fileDesc := $tei/tei:TEI/tei:teiHeader/tei:fileDesc
let $title := $fileDesc/tei:titleStmt/tei:title/text()
let $name := $fileDesc/tei:titleStmt/tei:author/text()
let $language := $fileDesc/tei:sourceDesc/tei:p/string(@xml:lang)
let $place := $fileDesc/tei:publicationStmt/tei:pubPlace/text()