Skip to content

Commit

Permalink
updated XSLT numbering and filenaming for new workshop plans
Browse files Browse the repository at this point in the history
  • Loading branch information
ebeshero committed Aug 23, 2024
1 parent e61d34d commit 8888512
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 256 deletions.
File renamed without changes
212 changes: 107 additions & 105 deletions xml/1819-01-10-MaryWebb.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions xml/de_hsa-letter-856.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://gams.uni-graz.at/o:hsa.odd/RNG" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://gams.uni-graz.at/o:hsa.odd/RNG" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<!--<?xml-model href="https://gams.uni-graz.at/o:hsa.odd/RNG" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://gams.uni-graz.at/o:hsa.odd/RNG" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>-->
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader xml:lang="de">
<fileDesc>
Expand Down
2 changes: 1 addition & 1 deletion xml/ja_soseki-letter-ex3.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../tei_all_ja_430.rnc" type="application/relax-ng-compact-syntax"?>
<!--<?xml-model href="../tei_all_ja_430.rnc" type="application/relax-ng-compact-syntax"?>-->
<TEI xmlns="http://www.tei-c.org/ns/1.0" xml:lang="ja">
<teiHeader>
<fileDesc>
Expand Down
3 changes: 3 additions & 0 deletions xslt/1_TEItoHTML-template.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
xmlns="http://www.w3.org/1999/xhtml"
version="3.0">

<!-- 2024-08-23 We can begin by processing the Spanish linguistics letter (es_PS4000-TEIP5.xml), since we will
be working with this file throughout the workshop. -->

<xsl:output method="xhtml" html-version="5" indent="yes"/>

<xsl:template match="/">
Expand Down
2 changes: 1 addition & 1 deletion xslt/1a_letter-to-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Notice how the xpath-default-namespace and the xmlns attributes are defined in the XSLT root element!
This is very important because they define the namespace of the input and the output files.
Run this on the es letter, and then one of the other letters (like 1819-01-10-MaryWebb.xml) to compare output.
Run this on the Spanish linguistics letter (es_PS4000-TEIP5.xml), and then one of the other letters (like 1819-01-10-MaryWebb.xml) to compare output.
-->

<xsl:output method="xhtml" html-version="5" indent="yes"/>
Expand Down
9 changes: 5 additions & 4 deletions xslt/1b_letter-to-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
xmlns="http://www.w3.org/1999/xhtml"
version="3.0">

<!-- 2022-07-24 ebb: This XSLT is designed to read a collection of XML files. It will
output a separate HTML file for each TEI XML letter in our letters folder.
You can run it in the XSLT debugger view by selecting any file at all as the XML source.
(We usually choose a file from within the collection.)
<!-- 2022-07-24 ebb: This XSLT is designed to read a collection of XML files.
It will output a separate HTML file for each TEI XML letter in our letters folder.
You can run it in the XSLT debugger view by selecting any xml-formatted file at all as the XML source.
Stored output: output/html-letters
-->

<!-- ebb: Uncomment if processing only one file, and remove the xsl:for-each in the template match on `/`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
xmlns="http://www.w3.org/1999/xhtml"
version="3.0">

<!-- This XSLT is a starting point to output an HTML file with data formatted for a Google pie chart
Input: xml/es_PS4000-TEIP5.xml
Stored Output: output/letter-to-pieChart.html
-->

<xsl:output method="xhtml" html-version="5" indent="yes"></xsl:output>

<!-- MS: and now we can reuse the same example to create a pie chart using the javascript libary Google Charts:
Expand All @@ -14,13 +20,13 @@

<xsl:variable name="spanishLetter" as="document-node()" select="doc('../xml/es_PS4000-TEIP5.xml')"/>

<xsl:variable name="wordCount" as="xs:integer" select="//w => count()"/>
<xsl:variable name="wordCount" as="xs:integer" select="$spanishLetter//w => count()"/>

<xsl:variable name="countTypes" as="xs:integer">
<xsl:value-of select="//w/@pos ! normalize-space() => distinct-values() => count()"/>
<xsl:value-of select="$spanishLetter//w/@pos ! normalize-space() => distinct-values() => count()"/>
</xsl:variable>

<xsl:variable name="wordTypes" as="xs:string+" select="//w/@pos ! normalize-space() => distinct-values()"/>
<xsl:variable name="wordTypes" as="xs:string+" select="$spanishLetter//w/@pos ! normalize-space() => distinct-values()"/>



Expand Down
12 changes: 9 additions & 3 deletions xslt/5_TEI-to-pieChart.xsl → xslt/3_TEI-to-pieChart.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@
xmlns="http://www.w3.org/1999/xhtml"
version="3.0">

<!-- This XSLT outputs and HTML file with data formatted for a Google pie chart
Input: xml/es_PS4000-TEIP5.xml
Output: output/letter-to-pieChart.html
-->

<xsl:output method="xhtml" html-version="5" indent="yes"></xsl:output>


<xsl:variable name="spanishLetter" as="document-node()" select="doc('../xml/es_PS4000-TEIP5.xml')"/>

<xsl:variable name="wordCount" as="xs:integer" select="//w => count()"/>
<xsl:variable name="wordCount" as="xs:integer" select="$spanishLetter//w => count()"/>

<xsl:variable name="countTypes" as="xs:integer">
<xsl:value-of select="//w/@pos ! normalize-space() => distinct-values() => count()"/>
<xsl:value-of select="$spanishLetter//w/@pos ! normalize-space() => distinct-values() => count()"/>
</xsl:variable>

<xsl:variable name="wordTypes" as="xs:string+" select="//w/@pos ! normalize-space() => distinct-values()"/>
<xsl:variable name="wordTypes" as="xs:string+" select="$spanishLetter//w/@pos ! normalize-space() => distinct-values()"/>



Expand Down
18 changes: 13 additions & 5 deletions xslt/3_TEI-to-SVG-template.xsl → xslt/4_TEI-to-SVG-template.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@

<xsl:output method="xml" indent="yes"/>

<!-- ebb: This will plot an SVG that reads the Spanish letter file and outputs a value for each
<!-- ebb: This will plot an SVG that reads the Spanish linguistics letter file and outputs a value for each
part of speech and its percentage representation among all the words in the letter.
Input: xml/es_PS4000-TEIP5.xml
Stored Output: output/letters-to-svg.svg
-->

<xsl:variable name="spanishLetter" as="document-node()" select="doc('../xml/es_PS4000-TEIP5.xml')"/>

<xsl:variable name="wordCount" as="xs:integer" select="//w => count()"/>
<xsl:variable name="wordCount" as="xs:integer" select="$spanishLetter//w => count()"/>

<xsl:variable name="countTypes" as="xs:integer">
<xsl:value-of select="//w/@pos ! normalize-space() => distinct-values() => count()"/>
<xsl:value-of select="$spanishLetter//w/@pos ! normalize-space() => distinct-values() => count()"/>
</xsl:variable>

<xsl:variable name="wordTypes" as="xs:string+" select="//w/@pos ! normalize-space() => distinct-values()"/>
<xsl:variable name="wordTypes" as="xs:string+" select="$spanishLetter//w/@pos ! normalize-space() => distinct-values()"/>

<xsl:variable name="colors" as="xs:string+" select="'coral', 'pink', 'lavender'"/>

Expand All @@ -36,10 +40,14 @@
<svg viewBox="0 0 600 500"> >

<g transform="translate(50, 300)">
<!-- X and Y axis lines: Line elements in SVG have a start point (x1,y1) and an endpoint (x2,y2)
Draw the X-axis line across the screen with x1 and x2 changing, and y1 and y2 at 0.
Draw the Y-axis line UP the screen (multiplying by the negative $ySpacer value), with x1 and x2 at 0.
-->
<line id="x-Axis" x1="0" y1="0" x2="{$countTypes * $xSpacer}" y2="0" stroke="black" stroke-width="2"/>
<line id="y-Axis" x1="0" y1="0" x2="0" y2="{50 * $ySpacer}" stroke="black" stroke-width="2"/>
<text class="y-hash" x="-30" y="{50 * $ySpacer + 5}">50%</text>

<!-- A text label in SVG has a single x and y coordinate. -->
<text id="title" x="100" y="{50 * $ySpacer - 20}">Proportions of Word Types in the Spanish Letter</text>


Expand Down
27 changes: 21 additions & 6 deletions xslt/3_TEI-to-SVG.xsl → xslt/4_TEI-to-SVG.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
<!-- ebb: This will plot an SVG that reads the Spanish linguistics-markup letter file and outputs a value for each
part of speech and its percentage representation among all the words in the letter.
Input: es_PS4000-TEIP5.xml
Input: xml/es_PS4000-TEIP5.xml
Output:
Stored Output: output/letters-to-svg.svg
-->

<xsl:variable name="spanishLetter" as="document-node()" select="doc('../xml/es_PS4000-TEIP5.xml')"/>

<xsl:variable name="wordCount" as="xs:integer" select="//w => count()"/>
<xsl:variable name="wordCount" as="xs:integer" select="$spanishLetter//w => count()"/>

<xsl:variable name="countTypes" as="xs:integer">
<xsl:value-of select="//w/@pos ! normalize-space() => distinct-values() => count()"/>
<xsl:value-of select="$spanishLetter//w/@pos ! normalize-space() => distinct-values() => count()"/>
</xsl:variable>

<xsl:variable name="wordTypes" as="xs:string+" select="//w/@pos ! normalize-space() => distinct-values()"/>
<xsl:variable name="wordTypes" as="xs:string+" select="$spanishLetter//w/@pos ! normalize-space() => distinct-values()"/>

<xsl:variable name="colors" as="xs:string+" select="'coral', 'pink', 'indianred'"/>

Expand Down Expand Up @@ -68,7 +68,22 @@
<xsl:value-of select="$currentCount div $wordCount * 100"/>
</xsl:variable>

<line x1="{position() * $xSpacer - $xSpacer div 2}" x2="{position() * $xSpacer - $xSpacer div 2}" y1="0" y2="{$percentage * $ySpacer}" stroke="{$colors[abs(3 - $currentPos mod 3)]}" stroke-width="{$xSpacer div 2}"/>
<line x1="{position() * $xSpacer - $xSpacer div 2}" x2="{position() * $xSpacer - $xSpacer div 2}" y1="0" y2="{$percentage * $ySpacer}" stroke="{$colors[3 - $currentPos mod 3]}" stroke-width="{$xSpacer div 2}"/>
<!-- ebb: To set the colors in @stroke, look at the $colors variable: We stored three color values in sequence, and each one has a position value of 1, 2, and 3.
So, we can do a little XPath arithmetic to determine which of the three color values is applied:
We are processing each member of the sequence of $wordTypes, and we have three colors.
We can divide the position value by 3 and output the remainder of the division, known as the modulo. This is found with the XPath mod operator.
But when a number is divisible by 3, we will have '0' as result, and that is not a position on our color list.
So, we subtract 3 - current position in the sequence of $wordTypes:
3 - 1 mod 3 = 3 - 2 = 1 (coral)
3 - 2 mod 3 = 3 - 1 = 2 (pink)
3 - 3 mod 3 = 3 - 0 = 3 (indianred)
...
3 - 6 mod 3 = 3 - 0 = 3 (indianred)
3 - 7 mod 3 = 3 - 1 = 2 (pink)
(etc.)
So we work with the remainders of a division by 3, and ensure that values are always 1, 2, or 3.
-->

<text class="wordType" x="{position() * $xSpacer - $xSpacer div 2}" y="20"><xsl:value-of select="current()"/></text>

Expand Down
78 changes: 0 additions & 78 deletions xslt/4_TEI-to-text-template.xsl

This file was deleted.

48 changes: 0 additions & 48 deletions xslt/4_TEI-to-text.xsl

This file was deleted.

0 comments on commit 8888512

Please sign in to comment.