<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.tei-c.org/index.php?action=history&amp;feed=atom&amp;title=Count_Metrical_Lines_P4.xslt</id>
	<title>Count Metrical Lines P4.xslt - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.tei-c.org/index.php?action=history&amp;feed=atom&amp;title=Count_Metrical_Lines_P4.xslt"/>
	<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=Count_Metrical_Lines_P4.xslt&amp;action=history"/>
	<updated>2026-04-22T00:00:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.32.0</generator>
	<entry>
		<id>https://wiki.tei-c.org/index.php?title=Count_Metrical_Lines_P4.xslt&amp;diff=2502&amp;oldid=prev</id>
		<title>Syd: Initial upload of stylesheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=Count_Metrical_Lines_P4.xslt&amp;diff=2502&amp;oldid=prev"/>
		<updated>2006-02-20T19:38:31Z</updated>

		<summary type="html">&lt;p&gt;Initial upload of stylesheet&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Counting &amp;lt;l&amp;gt; elements in a TEI document is pretty easy. But when a metrical line is broken in order to handle overlap, e.g., often two or more TEI &amp;lt;l&amp;gt; elements are used to represent a single metrical line. There are several mechanisms for indicating this fact, two of the more common of which are the use of the part= attribute and the use of the next= &amp;amp; prev= attributes. This stylesheet counts metrical lines in a TEI P4 document, taking into consideration those that have been encoded using several &amp;lt;l&amp;gt; elements using these mechanisms. It does not take other mechanisms (e.g., &amp;lt;join&amp;gt;) into account.&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!-- Count lines of poetry, P4 version --&amp;gt;&lt;br /&gt;
&amp;lt;!-- Conceived and written 2006-02-19 by Syd Bauman --&amp;gt;&lt;br /&gt;
&amp;lt;!-- Copyleft 2006 Syd Bauman --&amp;gt;&lt;br /&gt;
&amp;lt;xsl:stylesheet xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot; version=&amp;quot;1.0&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;xsl:output method=&amp;quot;text&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;/TEI.2&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:apply-templates/&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- Only look at &amp;lt;l&amp;gt; elements inside the outermost &amp;lt;text&amp;gt; element --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- (Not likely that there are &amp;lt;l&amp;gt; elements in the &amp;lt;teiHeader&amp;gt;, but --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- you never know.) --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;/TEI.2/text&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:text&amp;gt;There are &amp;lt;/xsl:text&amp;gt;&lt;br /&gt;
    &amp;lt;!-- count all lines that do not claim to be continuations of another line elsewhere --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:value-of select=&amp;quot;count(.//l[not(@prev) and not(@part='M') and not(@part='F')])&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:text&amp;gt; metrical lines in “&amp;lt;/xsl:text&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:apply-templates&lt;br /&gt;
      select=&amp;quot;/TEI.2/teiHeader/fileDesc/titleStmt/title[@type='main' or not(@type)][1]&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:text&amp;gt;”&amp;lt;/xsl:text&amp;gt;&lt;br /&gt;
    &amp;lt;!-- &amp;lt;l&amp;gt; with part=&amp;quot;Y&amp;quot; are metrically incomplete lines, which need to be reported separately --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:variable name=&amp;quot;incomplete&amp;quot; select=&amp;quot;count(.//l[@part='Y'])&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:if test=&amp;quot;$incomplete &amp;gt; 0&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:text&amp;gt;, of which &amp;lt;/xsl:text&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:value-of select=&amp;quot;$incomplete&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;!-- singular or plural? --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:choose&amp;gt;&lt;br /&gt;
	&amp;lt;xsl:when test=&amp;quot;$incomplete = 1&amp;quot;&amp;gt;&lt;br /&gt;
	  &amp;lt;xsl:text&amp;gt; is&amp;lt;/xsl:text&amp;gt;&lt;br /&gt;
	&amp;lt;/xsl:when&amp;gt;&lt;br /&gt;
	&amp;lt;xsl:otherwise&amp;gt;&lt;br /&gt;
	  &amp;lt;xsl:text&amp;gt; are&amp;lt;/xsl:text&amp;gt;&lt;br /&gt;
	&amp;lt;/xsl:otherwise&amp;gt;&lt;br /&gt;
      &amp;lt;/xsl:choose&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:text&amp;gt; incomplete&amp;lt;/xsl:text&amp;gt;&lt;br /&gt;
    &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:text&amp;gt;.&amp;lt;/xsl:text&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- for a &amp;lt;title&amp;gt;, just return the string-value of its children --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- (We don't have to worry about this template applying except --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- when we ask for it, above, because any other ancestor will --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- be completely ignored anyway (see below).) --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;title&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:apply-templates/&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;!-- Just ignore most anything and everything else --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;*&amp;quot;/&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
[[Category:XSLT]]&lt;/div&gt;</summary>
		<author><name>Syd</name></author>
		
	</entry>
</feed>