This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
import module namespace http = "http://expath.org/ns/http-client"; | |
let $url := 'http://history.state.gov/education/modules/border-vanishes-intro' | |
let $links := doc($url)//*:a[ends-with(@href, '.pdf')] | |
return | |
<results n="{count($links)}">{ | |
for $link in $links | |
let $href := if (starts-with($link/@href, '//')) then concat('http:', $link/@href) else $link/@href/string() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml-model href="../../schemas/frus.rnc" type="application/relax-ng-compact-syntax"?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
import module namespace functx="http://www.functx.com"; | |
(: Prepare XFDF data to use with PDFtk to populate a blank form SF702, | |
e.g., http://www.archives.gov/isoo/security-forms/sf702.pdf, | |
with data for each month of the year :) | |
let $data-collection := xmldb:create-collection('/db', 'sf702') | |
let $year := 2014 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
let $file-system-target-base-directory := | |
(: Mac :) | |
(: '/Users/Joe/workspace/paho-trunk' :) | |
(: Windows :) | |
'C:\Users\wicentowskijc\oxygensvn\paho-trunk' | |
let $source-collection := '/db/cms/apps/tei-content/data/short-history' | |
for $doc in collection($source-collection) | |
let $target := |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
declare namespace tei="http://www.tei-c.org/ns/1.0"; | |
let $site-base-url := 'http://history.state.gov/milestones' | |
let $milestones-files := collection('/db/cms/apps/tei-content/data/milestones')/tei:TEI | |
let $tab-delimited-cells := | |
for $file in $milestones-files | |
let $filename := substring-before(util:document-name($file), '.xml') | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
let $roles := collection('/db/cms/apps/principals-chiefs/code-tables/roles/data')/role | |
let $countries := collection('/db/cms/apps/countries/data')/country | |
let $start-date := '1969-01-20' | |
let $end-date := '1974-08-09' | |
let $appointments := collection('/db/cms/apps/principals-chiefs/data')//event[@type='appointed' and @when gt $start-date and @when lt $end-date]/parent::role[@class='chief' and @type ne 'charge-daffaires-ad-interim'] | |
return | |
<div> | |
<p>{count($appointments)} Chiefs of Mission who were appointed between {format-date(xs:date($start-date), "[MNn] [D], [Y]")} and {format-date(xs:date($end-date), "[MNn] [D], [Y]")}.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
for $ambassador in collection('/db/cms/apps/principals-chiefs/data')/person | |
let $postings := $ambassador/role | |
let $how-many-postings := count($postings) | |
group by $how-many-postings | |
order by $how-many-postings descending | |
return | |
<group postings="{$how-many-postings}" people-in-this-group="{count($ambassador)}"> | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
(: Functions to dehyphenate a word or a paragraph suffering from improper hyphenation. | |
Uses a dictionary (a list of known words), such as those available at: | |
https://github.com/marklogic/dictionaries/tree/master/dictionaries | |
:) | |
declare namespace fn="http://www.w3.org/2005/xpath-functions"; | |
declare namespace spell="http://marklogic.com/xdmp/spell"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
(: find the shortest and longest article and get the average word count of a collection of TEI XML articles :) | |
declare namespace tei="http://www.tei-c.org/ns/1.0"; | |
(: in our case, 'articles' are TEI divs that have @xml:id attributes and no child divs; | |
we filter out the foreward since they're not full articles. :) | |
let $milestone-articles := collection('/db/cms/apps/tei-content/data/milestones')//tei:div[@xml:id and not(.//tei:div)][@xml:id ne 'foreword'] | |
let $article-infos := |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
declare namespace fn="http://www.w3.org/2005/xpath-functions"; | |
(: Fix problems with mis-capitalized names. For example: | |
Before: MACARTHUR, Douglas II | |
After: MacArthur, Douglas II | |
:) | |
declare function local:fix-name-capitalization($name as xs:string) { | |
(: |