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) { | |
(: |
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 "1.0"; | |
(: A naive approach to sentence tokenization inspired by http://stackoverflow.com/a/2103653/659732 | |
: | |
: Works well with edited text like newspapers. Parameters like punctuation can/should be edited; | |
: see the section below called "criteria". | |
: | |
: For a more sophisticated approach, see Tibor Kiss and Jan Strunk, "Unsupervised Multilingual | |
: Sentence Boundary Detection", Computational Linguistics, Volume 32, Issue 4, December 2006, | |
: pp. 485-525. Also, see these discussions of sentence tokenization: |
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
javascript:(function({ | |
var INSTAPAPER=true,w=window,d=document,pageSelectedTxt=w.getSelection?w.getSelection():(d.getSelection)?d.getSelection():(d.selection?d.selection.createRange().text:0),pageTitle=d.title,pageUri=w.location.href,tmplt=""; | |
tmplt="From ["+pageTitle+"]("+pageUri+"):\n\n"; | |
if(pageSelectedTxt!="") { | |
pageSelectedTxt=">%20"+pageSelectedTxt; | |
pageSelectedTxt=pageSelectedTxt.replace(/(\r\n|\n+|\r)/gm,"\n"); | |
pageSelectedTxt=pageSelectedTxt.replace(/\n/g,"\n>%20\n>%20"); | |
w.location.href="nvalt://make/?txt="+encodeURIComponent(tmplt+pageSelectedTxt)+"&title="+encodeURIComponent(pageTitle) | |
} | |
else { |
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
<!-- | |
title: selectAllExceptFirstAndLast | |
description: sélectionne tout sauf le premier et le dernier élément dans une liste | |
version: xslt 1.0 | |
--> | |
<xsl:for-each select="element[not(position() = (1, last() ))]"> | |
<xsl:value-of select="." separator=", "/> | |
</xsl:for-each> |
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
(: list all files in the directory of your query file in BaseX :) | |
let $dir := file:parent(static-base-uri()) | |
for $file in file:list($dir) | |
return $dir || $file |
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
(: find out the current working directory in BaseX :) | |
file:parent('.') |
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 version="1.0" encoding="UTF-8"?> | |
<!-- | |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | |
@Name : .xsl | |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | |
@version : 000 | |
@creaDate : 2014/ | |
@modifDate | |
@vXslt: 2.0 | |
@autor : Emmanuel Château [email protected] |
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
<!-- Split content as attribute value --> | |
<xsl:template match="element[@id]"> | |
<xsl:variable name="att-values" select="tokenize(@id, ', ')"/> | |
<xsl:for-each select="tokenize(., '; ')"> | |
<xsl:variable name="pos" select="position()"/> | |
<xsl:if test="position() gt 1"><xsl:text>; </xsl:text></xsl:if> | |
<a href="#{$att-values[$pos]}"> | |
<xsl:value-of select="."/> | |
</a> | |
</xsl:for-each> |
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
<div> | |
<h2>{$heading} - {count($actions/generate)}</h2> | |
<p>Actions are processes that generate a new item from an existing item.</p> | |
<div> | |
{$partial("action1.xml","action",$actions/generate )} | |
</div> | |
</div> |
OlderNewer