Skip to content

Commit

Permalink
remove authors from DCLP overview script, plus a little refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Elemmire committed Jan 31, 2018
1 parent 2b4dca9 commit e7b1f45
Showing 1 changed file with 45 additions and 150 deletions.
195 changes: 45 additions & 150 deletions pn-scripts/generateCorpusOverview.xsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- script for updating dclp dropdown overview (author, tm, series). needs saxon in classpath -->
<xsl:stylesheet exclude-result-prefixes="#all" version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:papy="Papyrillio"
Expand All @@ -11,81 +10,49 @@
xmlns:functx="http://www.functx.com"
xmlns="http://www.tei-c.org/ns/1.0">

<!-- <xsl:include href="xwalkHelper.xsl"/> -->
<xsl:output method="html" media-type="text/xml" />
<xsl:param name="collection" select="'/srv/data/papyri.info/idp.data/DCLP/?select=[0-9]+.xml;recurse=yes'"/>
<xsl:param name="pathTarget"/>

<xsl:template name="HTML">
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>DCLP</title>
<link href="js/jquery/jquery-ui.css" rel="stylesheet"/>
<style>
body{
font-family: "Trebuchet MS", sans-serif;
margin: 50px;
}
.demoHeaders {
margin-top: 2em;
}
#dialog-link {
padding: .4em 1em .4em 20px;
text-decoration: none;
position: relative;
}
#dialog-link span.ui-icon {
margin: 0 5px 0 0;
position: absolute;
left: .2em;
top: 50%;
margin-top: -8px;
}
#icons {
margin: 0;
padding: 0;
}
#icons li {
margin: 2px;
position: relative;
padding: 4px 0;
cursor: pointer;
float: left;
list-style: none;
}
#icons span.ui-icon {
float: left;
margin: 0 4px;
}
.fakewindowcontain .ui-widget-overlay {
position: absolute;
}
select {
width: 200px;
}
</style>
</head>
<body>
<h1>DCLP</h1>
<div id="browser">
<ul>
<li><a href="#tm">TM</a></li>
<li><a href="#series">Series</a></li>
<li><a href="#author">Author</a></li>
</ul>
<!--
script for updating dclp dropdown overview (author, tm, series). needs saxon in classpath
call from shell, example:
java -Xms512m -Xmx1536m net.sf.saxon.Transform -it:OVERVIEW -xsl:generateCorpusOverview.xsl collectionPath=/Users/elemmire/data/idp.data/dclp/development/DCLP > generateCorpusOverview 2>&1
-->

<xsl:output method="text" media-type="text/plain" />
<xsl:param name="collectionPath">/srv/data/papyri.info/idp.data/DCLP</xsl:param>
<xsl:param name="pathTarget">.</xsl:param>

<xsl:function name="papy:getFolder" as="xs:integer">
<xsl:param name="tm" as="item()"/>
<xsl:value-of select="ceiling(number($tm) div 1000)"/>
</xsl:function>

<xsl:function name="papy:getFrom" as="xs:integer">
<xsl:param name="tm" as="item()"/>
<xsl:value-of select="number($tm) * 1000 - 1000 + 1"/>
</xsl:function>

<xsl:function name="papy:getTo" as="xs:integer">
<xsl:param name="tm" as="item()"/>
<xsl:value-of select="number($tm) * 1000"/>
</xsl:function>

<xsl:template name="OVERVIEW">
<xsl:result-document href="{concat($pathTarget, '/dclp_tm.html')}" method="html" html-version="5.0">
<xsl:call-template name="htmlFrame">
<xsl:with-param name="content">
<div id="tm" class="collection">
<xsl:for-each-group select="collection($collection)" group-by="ceiling(number(//tei:idno[@type='TM']) div 1000)">
<xsl:message select="current-grouping-key()"/>
<h3><xsl:value-of select="current-grouping-key()"/></h3>
<xsl:for-each-group select="collection(concat($collectionPath, '?select=[0-9]+.xml;recurse=yes'))" group-by="papy:getFolder(//tei:idno[@type='TM'])">
<xsl:sort select="papy:getFolder(//tei:idno[@type='TM'])"/>
<xsl:variable name="folder" select="current-grouping-key()"/>
<xsl:variable name="from" select="papy:getFrom($folder)"/>
<xsl:variable name="to" select="papy:getTo($folder)"/>
<xsl:message select="concat($folder, ' (', $from, '...', $to, ')')"/>
<h3><xsl:value-of select="$folder"/></h3>
<ul>
<xsl:for-each select="current-group()">
<xsl:variable name="tm" select="string(//tei:idno[@type='TM'])"></xsl:variable>
<xsl:sort select="string(//tei:idno[@type='TM'])"/>
<xsl:variable name="tm" select="string(//tei:idno[@type='TM'])"/>
<li>
<a href="/dclp/{$tm}"><xsl:value-of select="$tm"/></a>
<xsl:if test="//tei:div[@type='edition'] and string(normalize-space(string-join(//tei:div[@type='edition'], '')))">
Expand Down Expand Up @@ -114,7 +81,7 @@
<xsl:call-template name="htmlFrame">
<xsl:with-param name="content">
<div id="series" class="collection">
<xsl:for-each-group select="collection($collection)" group-by="substring-before(string(tei:TEI/tei:teiHeader[1]/tei:fileDesc[1]/tei:publicationStmt[1]/tei:idno[@type='dclp-hybrid'][1]), ';')">
<xsl:for-each-group select="collection(concat($collectionPath, '?select=[0-9]+.xml;recurse=yes'))" group-by="substring-before(string(tei:TEI/tei:teiHeader[1]/tei:fileDesc[1]/tei:publicationStmt[1]/tei:idno[@type='dclp-hybrid'][1]), ';')">
<xsl:sort select="if(string(tei:TEI/tei:teiHeader[1]/tei:fileDesc[1]/tei:publicationStmt[1]/tei:idno[@type='dclp-hybrid'][1]))then(substring-before(string(tei:TEI/tei:teiHeader[1]/tei:fileDesc[1]/tei:publicationStmt[1]/tei:idno[@type='dclp-hybrid'][1]), ';')) else ('z')"/>
<xsl:variable name="series" select="if(string(current-grouping-key())) then current-grouping-key() else 'TM'"></xsl:variable>
<xsl:message select="$series"/>
Expand Down Expand Up @@ -147,82 +114,8 @@
</xsl:call-template>
</xsl:result-document>

<xsl:result-document href="{concat($pathTarget, '/dclp_authors.html')}" method="html" html-version="5.0">
<xsl:call-template name="htmlFrame">
<xsl:with-param name="content">
<div id="author" class="collection">
<xsl:for-each-group select="collection($collection)" group-by="normalize-space(/tei:TEI/tei:text[1]/tei:body[1]/tei:div[@type='bibliography'][@subtype='ancientEdition'][1]/tei:listBibl[1]/tei:bibl[@type='publication'][@subtype='ancient'][1]/tei:author[1])">
<xsl:sort select="if(string(normalize-space(/tei:TEI/tei:text[1]/tei:body[1]/tei:div[@type='bibliography'][@subtype='ancientEdition'][1]/tei:listBibl[1]/tei:bibl[@type='publication'][@subtype='ancient'][1]/tei:author[1])))then(normalize-space(/tei:TEI/tei:text[1]/tei:body[1]/tei:div[@type='bibliography'][@subtype='ancientEdition'][1]/tei:listBibl[1]/tei:bibl[@type='publication'][@subtype='ancient'][1]/tei:author[1]))else('z')"/>
<xsl:variable name="author" select="if(string(current-grouping-key())) then current-grouping-key() else 'No Author'"></xsl:variable>
<xsl:message select="$author"/>
<h3><xsl:value-of select="$author"/></h3>
<ul>
<xsl:for-each-group select="current-group()" group-by="normalize-space(/tei:TEI/tei:text[1]/tei:body[1]/tei:div[@type='bibliography'][@subtype='ancientEdition'][1]/tei:listBibl[1]/tei:bibl[@type='publication'][@subtype='ancient'][1]/tei:title[1])">
<xsl:sort select="normalize-space(/tei:TEI/tei:text[1]/tei:body[1]/tei:div[@type='bibliography'][@subtype='ancientEdition'][1]/tei:listBibl[1]/tei:bibl[@type='publication'][@subtype='ancient'][1]/tei:title[1])"/>
<xsl:variable name="work" select="if(string(current-grouping-key()))then(current-grouping-key())else('No Work')"/>
<xsl:message select="$work"/>
<li>
<xsl:value-of select="$work"/>
<ul>
<xsl:for-each select="current-group()">
<xsl:variable name="tm" select="string(tei:TEI/tei:teiHeader[1]/tei:fileDesc[1]/tei:publicationStmt[1]/tei:idno[@type='TM'])"></xsl:variable>
<xsl:variable name="dclpHybrid" select="string(tei:TEI/tei:teiHeader[1]/tei:fileDesc[1]/tei:publicationStmt[1]/tei:idno[@type='dclp-hybrid'][1])"></xsl:variable>
<li>
<a href="/dclp/{$tm}">
<xsl:value-of select="$author"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="$work"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$tm"/>
<xsl:value-of select="if(string($dclpHybrid))then(concat(' (', $dclpHybrid, ')'))else()"/>
</a>
<xsl:if test="//tei:div[@type='edition'] and string(normalize-space(string-join(//tei:div[@type='edition'], '')))">
<span>
<xsl:text> (</xsl:text>
<xsl:if test="//tei:div[@type='edition']/@xml:lang">
<xsl:value-of select="string-join(//tei:language[@ident=//tei:div[@type='edition'][string(.)]/@xml:lang], ', ')"/>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:text>text available)</xsl:text>
</span>
</xsl:if>
<xsl:call-template name="viewIn">
<xsl:with-param name="tm" select="$tm"/>
</xsl:call-template>
</li>
</xsl:for-each>
</ul>
</li>
</xsl:for-each-group>
</ul>
</xsl:for-each-group>
</div>
</xsl:with-param>
</xsl:call-template>
</xsl:result-document>

</div>

<script src="js/jquery/external/jquery/jquery.js"></script>
<script src="js/jquery/jquery-ui.js"></script>
<script>
$(function(){
$('.collection').accordion({
heightStyle: "content",
collapsible: true,
animate: false
});

$('#browser').tabs();

});

</script>

</body>
</html>
</xsl:template>

<xsl:template name="htmlFrame">
<xsl:param name="content"/>
<html xmlns="http://www.tei-c.org/ns/1.0" lang="en">
Expand All @@ -231,8 +124,11 @@
<title>DCLP</title>
<link rel="stylesheet" href="/css/yui/reset-fonts-grids.css" type="text/css" media="screen" title="no title" charset="utf-8"></link>
<link rel="stylesheet" href="/css/master.css" type="text/css" media="screen" title="no title" charset="utf-8"></link>
<link rel="stylesheet" href="/css/custom-theme/jquery-ui-1.8.14.custom.css" type="text/css" media="screen" title="no title" charset="utf-8"></link><script src="js/jquery-1.5.1.min.js" type="text/javascript" charset="utf-8"></script><script src="js/jquery-ui-1.8.14.custom.min.js" type="text/javascript" charset="utf-8"></script><script src="js/init.js" type="text/javascript" charset="utf-8"></script><script type="text/javascript">

<link rel="stylesheet" href="/css/custom-theme/jquery-ui-1.8.14.custom.css" type="text/css" media="screen" title="no title" charset="utf-8"></link>
<script src="js/jquery-1.5.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery-ui-1.8.14.custom.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/init.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-19774706-1']);
_gaq.push(['_trackPageview']);
Expand All @@ -242,7 +138,6 @@
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script></head>
<body onload="init()">
<div id="d">
Expand Down Expand Up @@ -319,7 +214,7 @@
</script></body>
</html>
</xsl:template>

<xsl:template name="viewIn">
<xsl:param name="tm"/>
view in
Expand All @@ -331,5 +226,5 @@
github
</a>
</xsl:template>

</xsl:stylesheet>

0 comments on commit e7b1f45

Please sign in to comment.