Skip to content

Instantly share code, notes, and snippets.

View pastokes's full-sized avatar

Peter Stokes pastokes

View GitHub Profile
@pastokes
pastokes / UnicodeTableGenerator.xsl
Created May 19, 2020 08:45
Script to extract content from Unicode 13.0 Character Code Charts - Scripts (https://www.unicode.org/charts/#scripts)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
version="2.0">
<!--
Script to extract content from Unicode 13.0 Character Code Charts - Scripts (https://www.unicode.org/charts/#scripts)
The ultimate goal is to get a more or less machine-readable table of code points for all scripts in ISO15924.
This information must surely be online already, but I haven't yet managed to find it.
The XSLT is interesting for use of tail recursion with the so-called 'Kayessian' method for structuring flat sequences of elements
by their attributes.
<?xml version="1.0" encoding="UTF-8"?>
<!--
This stylesheet is designed to be used as an API transform in the Archetype framework (http://archetype.ink).
To use, set up an instance of Archetype, log in to the back end, then create a new API Transform. Paste this code into the 'Template'
field. The request needs to be of the form hand/?@format=xml&@select=item_part,label,*assigned_date,min_weight,max_weight,date
You will need to add a filter to the request, such as _graphs__graph_components__features__name=turned left
For further information on API requests see https://github.com/kcl-ddh/digipal/wiki/The-Web-API-Syntax
Note that Archetype is based on libraries that only accept XSLT1.0. The code could be significantly simplified with XSLT 2.0.
Much of the code is also taken up with a lookup table for the blurred bars. This could also probably be simplified by using
@pastokes
pastokes / CCCC367PartsII&V-imageList.xml
Last active March 20, 2018 13:49
A model of Cambridge, Corpus Christi College MS 367, Parts II and V, for representation using VisColl. To recreate the visualisation, upload these files to http://138.197.87.173:8080/xproc-z/visualize-collation/. VisColl is by Dot Porter et al. and documented at https://github.com/leoba/VisColl ; codicology based on description by Elaine Treharn…
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>Stokes, Peter</Author>
<LastAuthor>Stokes, Peter</LastAuthor>
@pastokes
pastokes / tei-name-index.xsl
Created January 23, 2017 22:20
Sample of for-each-group in XSLT. Reads in a TEI file, then looks for all name elements. Produces an alphabetical list of names according to the @ref, with a list of spellings from the original file. Handles extra white space and differences in capitalisation. By Peter Stokes and Elena Pierazzo, January 2017.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Sample of for-each-group in XSLT.
Reads in a TEI file, then looks for all name elements. Produces an alphabetical list of names according to the @ref,
with a list of spellings from the original file. Handles extra white space and differences in capitalisation.
By Peter Stokes and Elena Pierazzo, January 2017.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
version="2.0" xpath-default-namespace="http://www.tei-c.org/ns/1.0">
<xsl:output method="xhtml" indent="no" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
@pastokes
pastokes / cross-search.xsl
Last active January 23, 2017 22:22
First, very rough proof-of-concept of a script to search instances of the DigiPal framework using the API.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Cross-searching script. First rough proof of concept of a script to search different instances of the DigiPal framework.
As presented this requires access rights to some of the 'private' DigiPal instances so won't work unless you are part of the DigiPal team.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
version="1.0">
<xsl:param name="limit">100</xsl:param>
@pastokes
pastokes / codicology-tei.sch
Last active April 4, 2020 19:04
Partial implementation of model discussed at TEI conference. See further http://tei2015.huma-num.fr/en/papers/#acc-41 and http://www.exondomesday.ac.uk
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<ns uri="http://www.tei-c.org/ns/1.0" prefix="tei"/>
<ns uri="http://exondomesday.ac.uk" prefix="exon"/>
<!--<pattern id="checkText">
<rule context="page[@textFollows]">
<assert test="@textFollows = preceding::page[1]/@id">Text on page <value-of select="@id"/> does not follow (expected <value-of
select="@textFollows"/>, found <value-of select="preceding::page[1]/@id"/>).</assert>
</rule>
@pastokes
pastokes / StdNormLookup.xml
Created June 17, 2015 13:02
Lookup table for a standard normal distribution
<table>
<td>
<tr>x</tr>
<tr>Std Norm</tr>
</td>
<tr>
<td>-3.00</td>
<td>0.004431848</td>
</tr>
<tr>
@pastokes
pastokes / normDist.xsl
Created June 17, 2015 12:59
Generate Normal distributions
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" exclude-result-prefixes="xs xd"
version="2.0">
<xd:doc scope="stylesheet">
<xd:desc>
<xd:p><xd:b>Created on:</xd:b> Jun 24, 2011</xd:p>
<xd:p><xd:b>Author:</xd:b> pstokes</xd:p>
<xd:p/>
</xd:desc>
</xd:doc>
@pastokes
pastokes / svgPlot.xsl
Last active August 29, 2015 14:23
Template to generate scatter graph or histogram in SVG
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0" exclude-result-prefixes="#all">
<!-- Parameters. All values are in pixles unless otherwise specified.
bins - the data to be displayed on the histogram. bin: label, value+
bin_inner_offset - number of pixels between the y axis and the edge of the first bin
bin_outer_offset - number of pixels between the edge of the last bin and the end of the x axis
bingap - number of pixels from the tick on the h axis to the edge of the bin rectangle. Space between bins is therefore
@pastokes
pastokes / codicology.rnc
Created April 25, 2015 22:53
RelaxNG compact schema for the codicology model (non-TEI version) implemented by codicology.xml.
Codex = element codex { Gathering+ }
Gathering = element gathering {
(attribute id { xsd:ID }? &
Ruling?),
Singleton*, Bifolium?, Singleton*
}
Singleton = element singleton {
attribute id { xsd:ID }?,