<?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=DownloadP4toP5.bash</id>
	<title>DownloadP4toP5.bash - 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=DownloadP4toP5.bash"/>
	<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;action=history"/>
	<updated>2026-12-05T00:12:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.4</generator>
	<entry>
		<id>https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=4438&amp;oldid=prev</id>
		<title>Syd: fix wiki-messes-up-my-stuff problem in code that changes entity refs</title>
		<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=4438&amp;oldid=prev"/>
		<updated>2008-05-04T14:19:14Z</updated>

		<summary type="html">&lt;p&gt;fix wiki-messes-up-my-stuff problem in code that changes entity refs&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:19, 4 May 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l171&quot;&gt;Line 171:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 171:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     get &amp;quot;$f&amp;quot; &amp;quot;$0_temp&amp;quot; || echo &amp;quot;WARNING: unable to fetch $f.&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     get &amp;quot;$f&amp;quot; &amp;quot;$0_temp&amp;quot; || echo &amp;quot;WARNING: unable to fetch $f.&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     # ... process temp file into the desired file&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     # ... process temp file into the desired file&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     xsltproc extractCode.xslt $0_temp | perl -pe &#039;s/&amp;amp;lt;/&amp;lt;/g; s/&amp;amp;gt;/&amp;gt;/g;&#039; &amp;gt;  ${f##*/}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     xsltproc extractCode.xslt $0_temp | perl -pe &#039;s/&amp;amp;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;amp;&lt;/ins&gt;lt;/&amp;lt;/g; s/&amp;amp;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;amp;&lt;/ins&gt;gt;/&amp;gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;/g; s/&amp;amp;amp;amp;/&amp;amp;&lt;/ins&gt;/g;&#039; &amp;gt;  ${f##*/}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     done&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     done&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Syd</name></author>
	</entry>
	<entry>
		<id>https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=4437&amp;oldid=prev</id>
		<title>Syd: fix some typos and improve phrase-level encoding, as it were</title>
		<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=4437&amp;oldid=prev"/>
		<updated>2008-05-04T14:13:18Z</updated>

		<summary type="html">&lt;p&gt;fix some typos and improve phrase-level encoding, as it were&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:13, 4 May 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is a shell script that tries to read the [[Category:P4toP5|P4 to P5]] &amp;lt;!-- start stupidity here just because I can&#039;t figure out how to &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;like &lt;/del&gt;to category page at all, let alone w/ alternate text --&amp;gt;category page for&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is a shell script that tries to read the [[Category:P4toP5|P4 to P5]] &amp;lt;!-- start stupidity here just because I can&#039;t figure out how to &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;link &lt;/ins&gt;to category page at all, let alone w/ alternate text --&amp;gt;category page for&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;stylesheets for P4 to P5 conversion&amp;lt;!-- end --&amp;gt;, follow all of the&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;stylesheets for P4 to P5 conversion&amp;lt;!-- end --&amp;gt;, follow all of the&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;links from that page to the articles in this category, download each of those pages, and then extract the actual code from the downloaded page and save it with the expected name.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;links from that page to the articles in this category, download each of those pages, and then extract the actual code from the downloaded page and save it with the expected name.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l5&quot;&gt;Line 5:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 5:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To use this program copy-and-paste the following code into a file in an otherwise empty&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To use this program copy-and-paste the following code into a file in an otherwise empty&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;directory. The new file can be named whatever you like. Here we are going to assume it&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;directory. The new file can be named whatever you like. Here we are going to assume it&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;is called &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&quot;downloadP4toP5&lt;/del&gt;.&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;bash&quot;&lt;/del&gt;. Ensure that this new file is executable (e.g., `chmod a+x downloadP5toP5.bash`). With the current working directory set to the &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;directly downloadP4toP5&lt;/del&gt;.&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;bash &lt;/del&gt;is in, execute it (e.g., `./downloadP5toP5.bash`). No parameters or switches are required, but&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;is called &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;“downloadP4toP5&lt;/ins&gt;.&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;bash”&lt;/ins&gt;. Ensure that this new file is executable (e.g., `&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;tt&amp;gt;&lt;/ins&gt;chmod a+x downloadP5toP5.bash&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/tt&amp;gt;&lt;/ins&gt;`). With the current working directory set to the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;directory that “downloadP4toP5&lt;/ins&gt;.&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;bash” &lt;/ins&gt;is in, execute it (e.g., `&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;tt&amp;gt;&lt;/ins&gt;./downloadP5toP5.bash&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/tt&amp;gt;&lt;/ins&gt;`). No parameters or switches are required, but an internet connection is.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;an internet connection is.&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;#! /bin/bash&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;#! /bin/bash&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Syd</name></author>
	</entry>
	<entry>
		<id>https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=3201&amp;oldid=prev</id>
		<title>Piotr Banski: revert</title>
		<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=3201&amp;oldid=prev"/>
		<updated>2007-06-10T20:09:57Z</updated>

		<summary type="html">&lt;p&gt;revert&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is a shell script that tries to read the [[Category:P4toP5|P4 to P5]] &amp;lt;!-- start stupidity here just because I can&amp;#039;t figure out how to like to category page at all, let alone w/ alternate text --&amp;gt;category page for&lt;br /&gt;
stylesheets for P4 to P5 conversion&amp;lt;!-- end --&amp;gt;, follow all of the&lt;br /&gt;
links from that page to the articles in this category, download each of those pages, and then extract the actual code from the downloaded page and save it with the expected name.&lt;br /&gt;
&lt;br /&gt;
To use this program copy-and-paste the following code into a file in an otherwise empty&lt;br /&gt;
directory. The new file can be named whatever you like. Here we are going to assume it&lt;br /&gt;
is called &amp;quot;downloadP4toP5.bash&amp;quot;. Ensure that this new file is executable (e.g., `chmod a+x downloadP5toP5.bash`). With the current working directory set to the directly downloadP4toP5.bash is in, execute it (e.g., `./downloadP5toP5.bash`). No parameters or switches are required, but&lt;br /&gt;
an internet connection is.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;#! /bin/bash&lt;br /&gt;
&lt;br /&gt;
# downloadP4toP5.bash&lt;br /&gt;
# Extract the code from all of the articles listed in the P4toP5 category&lt;br /&gt;
# of the TEI wiki.&lt;br /&gt;
#&lt;br /&gt;
# Written 2006-10-05 by Syd Bauman&lt;br /&gt;
# Copyright 2006 by Syd Bauman and the Text Encoding Initiative Consortium&lt;br /&gt;
# See near bottom of file for complete copyleft notice&lt;br /&gt;
#&lt;br /&gt;
# This routine has been testing in Debian GNU/Linux and in Mac OS X.&lt;br /&gt;
# It may work in other environments, it may not. It downloads the&lt;br /&gt;
# files to its own directory, which had better be writeable or you&amp;#039;ll&lt;br /&gt;
# see a lot of error messages and get no results.&lt;br /&gt;
#&lt;br /&gt;
# Limitations / Future Plans&lt;br /&gt;
# ----------- - ------ -----&lt;br /&gt;
# Currently, this routine requires that you have `xsltproc` and either&lt;br /&gt;
# `wget` or `curl` in your PATH. Perhaps in the future we should make&lt;br /&gt;
# it operate with other XSLT engines and URL fetchers.&lt;br /&gt;
#&lt;br /&gt;
# Should add a -d switch which will cause some tracing the _temp files&lt;br /&gt;
# to remain, otherwise they should be erased.&lt;br /&gt;
#&lt;br /&gt;
# Warning&lt;br /&gt;
# -------&lt;br /&gt;
# This program is really quite fragile. It&amp;#039;s really just a hack, and&lt;br /&gt;
# it will break if anything on the wiki changes in any significant&lt;br /&gt;
# way. E.g., if someone were to add a new article in which the&lt;br /&gt;
# stylesheet code itself were not the 1st &amp;lt;pre&amp;gt;, we&amp;#039;d mess up on that&lt;br /&gt;
# particular stylesheet.&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# error subroutine&lt;br /&gt;
# &lt;br /&gt;
die()&lt;br /&gt;
{&lt;br /&gt;
    echo; echo &amp;quot;ERROR: $@.&amp;quot;&lt;br /&gt;
    D=`date &amp;quot;+%Y-%m-%d %H:%M:%S&amp;quot;`&lt;br /&gt;
    echo &amp;quot;This was a fatal error. $D&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# subroutine to retrieve web page&lt;br /&gt;
# &lt;br /&gt;
if which wget&lt;br /&gt;
then&lt;br /&gt;
    get()&lt;br /&gt;
    {&lt;br /&gt;
	wget --no-directories --output-document=&amp;quot;$2&amp;quot; $1&lt;br /&gt;
    }&lt;br /&gt;
elif which curl&lt;br /&gt;
then&lt;br /&gt;
    get()&lt;br /&gt;
    {&lt;br /&gt;
	curl --silent $1 &amp;gt; $2&lt;br /&gt;
    }&lt;br /&gt;
else&lt;br /&gt;
    die &amp;quot;I can&amp;#039;t find a command with which to download web files, so I&amp;#039;m giving up.&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# create our XSLT file for extracting the list of stylesheets&lt;br /&gt;
# &lt;br /&gt;
cat &amp;gt; extractList.xslt &amp;lt;&amp;lt;EOEL&lt;br /&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;!-- temporary stylesheet for use by shell script that --&amp;gt;&lt;br /&gt;
&amp;lt;!-- sucks P4 to P5 stylesheets from wiki. This routine --&amp;gt;&lt;br /&gt;
&amp;lt;!-- reads in the P4 to P5 index page and produces a --&amp;gt;&lt;br /&gt;
&amp;lt;!-- space-separated list of the links to articles con- --&amp;gt;&lt;br /&gt;
&amp;lt;!-- tained therein. --&amp;gt;&lt;br /&gt;
&amp;lt;xsl:stylesheet xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
  xmlns:x=&amp;quot;http://www.w3.org/1999/xhtml&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;/&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- ignore everything but &amp;lt;table&amp;gt; elements --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:apply-templates select=&amp;quot;//x:table&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- ignore the &amp;lt;table&amp;gt; that&amp;#039;s for the table of contents, too --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:table[@id=&amp;#039;toc&amp;#039;]&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- the only non-TOC table should be the list of articles --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:table&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- for each descendant link ... --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:for-each select=&amp;quot;.//x:a&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;!-- ... write out the target ... --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:value-of select=&amp;quot;@href&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;!-- ... and a blank to separate. --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:text&amp;gt; &amp;lt;/xsl:text&amp;gt;&lt;br /&gt;
    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
EOEL&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# create our XSLT file for extracting code from a page&lt;br /&gt;
# &lt;br /&gt;
cat &amp;gt; extractCode.xslt &amp;lt;&amp;lt;EOEC&lt;br /&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;!-- temporary stylesheet for use by shell script that --&amp;gt;&lt;br /&gt;
&amp;lt;!-- sucks P4 to P5 stylesheets from wiki. --&amp;gt;&lt;br /&gt;
&amp;lt;xsl:stylesheet xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
  xmlns:x=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; version=&amp;quot;1.0&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- There is already an XML declaration in the file --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- we are extracting, and we don&amp;#039;t want two of &amp;#039;em --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:output method=&amp;quot;xml&amp;quot; omit-xml-declaration=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- get the title of this web page --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:variable name=&amp;quot;title&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:value-of select=&amp;quot;//x:head/x:title&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/xsl:variable&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:choose&amp;gt;&lt;br /&gt;
      &amp;lt;!-- special case: if this is the Copy-All.xsl page, --&amp;gt;&lt;br /&gt;
      &amp;lt;!-- take the 2nd &amp;lt;pre&amp;gt; element --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:when test=&amp;quot;starts-with(\$title,&amp;#039;Copy-All.&amp;#039;)&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;//x:pre[2]&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/xsl:when&amp;gt;&lt;br /&gt;
      &amp;lt;!-- for all others take the first (and only) &amp;lt;pre&amp;gt; --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:otherwise&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;//x:pre[1]&amp;quot;/&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:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- when we hit the &amp;lt;pre&amp;gt; we want, just copy it --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- entirely to the output --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:pre&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;/xsl:stylesheet&amp;gt;&lt;br /&gt;
EOEC&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Check that we can process those stylesheets we just created&lt;br /&gt;
# &lt;br /&gt;
which xsltproc || die &amp;quot;I can&amp;#039;t find `xsltproc`, which is the only XSLT processor I know about.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# get the TEI Wiki P4 to P5 index page (which lists all the stylesheets&lt;br /&gt;
# we want to get)&lt;br /&gt;
# &lt;br /&gt;
f=&amp;quot;http://www.tei-c.org/wiki/index.php/Category:P4toP5&amp;quot;&lt;br /&gt;
echo &amp;quot;extracting index page $f to file ${f##*/}&amp;quot;&lt;br /&gt;
get &amp;quot;$f&amp;quot; &amp;quot;${f##*/}&amp;quot; || die &amp;quot;Unable to fetch P4 to P5 index page.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# extract the list of files we want from the list of articles&lt;br /&gt;
# in the index page; then, for each of those files ...&lt;br /&gt;
# &lt;br /&gt;
for f in `xsltproc extractList.xslt Category:P4toP5` ; do&lt;br /&gt;
    # ... generate the web address and announce our intention ...&lt;br /&gt;
    f=&amp;quot;http://www.tei-c.org$f&amp;quot;&lt;br /&gt;
    echo &amp;quot;extracting code from $f to file ${f##*/} ...&amp;quot;&lt;br /&gt;
    # ... get the page from the web, storing as a temp file ...&lt;br /&gt;
    get &amp;quot;$f&amp;quot; &amp;quot;$0_temp&amp;quot; || echo &amp;quot;WARNING: unable to fetch $f.&amp;quot;&lt;br /&gt;
    # ... process temp file into the desired file&lt;br /&gt;
    xsltproc extractCode.xslt $0_temp | perl -pe &amp;#039;s/&amp;amp;lt;/&amp;lt;/g; s/&amp;amp;gt;/&amp;gt;/g;&amp;#039; &amp;gt;  ${f##*/}&lt;br /&gt;
    done&lt;br /&gt;
&lt;br /&gt;
# -----------------------------------------------------&lt;br /&gt;
# Copyright 2006 Syd Bauman and the Text Encoding Initiative&lt;br /&gt;
# Consortium. This program is free software; you can redistribute it&lt;br /&gt;
# and/or modify it under the terms of the GNU General Public License&lt;br /&gt;
# as published by the Free Software Foundation; either version 2 of&lt;br /&gt;
# the License, or (at your option) any later version. This program is&lt;br /&gt;
# distributed in the hope that it will be useful, but WITHOUT ANY&lt;br /&gt;
# WARRANTY; without even the implied warranty of MERCHANTABILITY or&lt;br /&gt;
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License&lt;br /&gt;
# for more details. You should have received a copy of the GNU General&lt;br /&gt;
# Public License along with this program; if not, write to the&lt;br /&gt;
#        Free Software Foundation, Inc.&lt;br /&gt;
#        675 Mass Ave&lt;br /&gt;
#        Cambridge, MA  02139&lt;br /&gt;
#        USA&lt;br /&gt;
#        gnu@prep.ai.mit.edu&lt;br /&gt;
#&lt;br /&gt;
# Syd Bauman, north american editor&lt;br /&gt;
# Text Encoding Initiative Consortium&lt;br /&gt;
# Box 1841&lt;br /&gt;
# Providence, RI  02912-1841&lt;br /&gt;
# 401-863-3835&lt;br /&gt;
# Syd_Bauman@Brown.edu&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
[[Category:P4toP5]]&lt;/div&gt;</summary>
		<author><name>Piotr Banski</name></author>
	</entry>
	<entry>
		<id>https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=3187&amp;oldid=prev</id>
		<title>Piotr Banski: revert - getting the plusses back</title>
		<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=3187&amp;oldid=prev"/>
		<updated>2007-06-06T23:36:12Z</updated>

		<summary type="html">&lt;p&gt;revert - getting the plusses back&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is a shell script that tries to read the [[Category:P4toP5|P4 to P5]] &amp;lt;!-- start stupidity here just because I can&amp;#039;t figure out how to like to category page at all, let alone w/ alternate text --&amp;gt;category page for&lt;br /&gt;
stylesheets for P4 to P5 conversion&amp;lt;!-- end --&amp;gt;, follow all of the&lt;br /&gt;
links from that page to the articles in this category, download each of those pages, and then extract the actual code from the downloaded page and save it with the expected name.&lt;br /&gt;
&lt;br /&gt;
To use this program copy-and-paste the following code into a file in an otherwise empty&lt;br /&gt;
directory. The new file can be named whatever you like. Here we are going to assume it&lt;br /&gt;
is called &amp;quot;downloadP4toP5.bash&amp;quot;. Ensure that this new file is executable (e.g., `chmod a+x downloadP5toP5.bash`). With the current working directory set to the directly downloadP4toP5.bash is in, execute it (e.g., `./downloadP5toP5.bash`). No parameters or switches are required, but&lt;br /&gt;
an internet connection is.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;#! /bin/bash&lt;br /&gt;
&lt;br /&gt;
# downloadP4toP5.bash&lt;br /&gt;
# Extract the code from all of the articles listed in the P4toP5 category&lt;br /&gt;
# of the TEI wiki.&lt;br /&gt;
#&lt;br /&gt;
# Written 2006-10-05 by Syd Bauman&lt;br /&gt;
# Copyright 2006 by Syd Bauman and the Text Encoding Initiative Consortium&lt;br /&gt;
# See near bottom of file for complete copyleft notice&lt;br /&gt;
#&lt;br /&gt;
# This routine has been testing in Debian GNU/Linux and in Mac OS X.&lt;br /&gt;
# It may work in other environments, it may not. It downloads the&lt;br /&gt;
# files to its own directory, which had better be writeable or you&amp;#039;ll&lt;br /&gt;
# see a lot of error messages and get no results.&lt;br /&gt;
#&lt;br /&gt;
# Limitations / Future Plans&lt;br /&gt;
# ----------- - ------ -----&lt;br /&gt;
# Currently, this routine requires that you have `xsltproc` and either&lt;br /&gt;
# `wget` or `curl` in your PATH. Perhaps in the future we should make&lt;br /&gt;
# it operate with other XSLT engines and URL fetchers.&lt;br /&gt;
#&lt;br /&gt;
# Should add a -d switch which will cause some tracing the _temp files&lt;br /&gt;
# to remain, otherwise they should be erased.&lt;br /&gt;
#&lt;br /&gt;
# Warning&lt;br /&gt;
# -------&lt;br /&gt;
# This program is really quite fragile. It&amp;#039;s really just a hack, and&lt;br /&gt;
# it will break if anything on the wiki changes in any significant&lt;br /&gt;
# way. E.g., if someone were to add a new article in which the&lt;br /&gt;
# stylesheet code itself were not the 1st &amp;lt;pre&amp;gt;, we&amp;#039;d mess up on that&lt;br /&gt;
# particular stylesheet.&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# error subroutine&lt;br /&gt;
# &lt;br /&gt;
die()&lt;br /&gt;
{&lt;br /&gt;
    echo; echo &amp;quot;ERROR: $@.&amp;quot;&lt;br /&gt;
    D=`date &amp;quot;+%Y-%m-%d %H:%M:%S&amp;quot;`&lt;br /&gt;
    echo &amp;quot;This was a fatal error. $D&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# subroutine to retrieve web page&lt;br /&gt;
# &lt;br /&gt;
if which wget&lt;br /&gt;
then&lt;br /&gt;
    get()&lt;br /&gt;
    {&lt;br /&gt;
	wget --no-directories --output-document=&amp;quot;$2&amp;quot; $1&lt;br /&gt;
    }&lt;br /&gt;
elif which curl&lt;br /&gt;
then&lt;br /&gt;
    get()&lt;br /&gt;
    {&lt;br /&gt;
	curl --silent $1 &amp;gt; $2&lt;br /&gt;
    }&lt;br /&gt;
else&lt;br /&gt;
    die &amp;quot;I can&amp;#039;t find a command with which to download web files, so I&amp;#039;m giving up.&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# create our XSLT file for extracting the list of stylesheets&lt;br /&gt;
# &lt;br /&gt;
cat &amp;gt; extractList.xslt &amp;lt;&amp;lt;EOEL&lt;br /&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;!-- temporary stylesheet for use by shell script that --&amp;gt;&lt;br /&gt;
&amp;lt;!-- sucks P4 to P5 stylesheets from wiki. This routine --&amp;gt;&lt;br /&gt;
&amp;lt;!-- reads in the P4 to P5 index page and produces a --&amp;gt;&lt;br /&gt;
&amp;lt;!-- space-separated list of the links to articles con- --&amp;gt;&lt;br /&gt;
&amp;lt;!-- tained therein. --&amp;gt;&lt;br /&gt;
&amp;lt;xsl:stylesheet xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
  xmlns:x=&amp;quot;http://www.w3.org/1999/xhtml&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;/&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- ignore everything but &amp;lt;table&amp;gt; elements --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:apply-templates select=&amp;quot;//x:table&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- ignore the &amp;lt;table&amp;gt; that&amp;#039;s for the table of contents, too --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:table[@id=&amp;#039;toc&amp;#039;]&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- the only non-TOC table should be the list of articles --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:table&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- for each descendant link ... --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:for-each select=&amp;quot;.//x:a&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;!-- ... write out the target ... --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:value-of select=&amp;quot;@href&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;!-- ... and a blank to separate. --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:text&amp;gt; &amp;lt;/xsl:text&amp;gt;&lt;br /&gt;
    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
EOEL&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# create our XSLT file for extracting code from a page&lt;br /&gt;
# &lt;br /&gt;
cat &amp;gt; extractCode.xslt &amp;lt;&amp;lt;EOEC&lt;br /&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;!-- temporary stylesheet for use by shell script that --&amp;gt;&lt;br /&gt;
&amp;lt;!-- sucks P4 to P5 stylesheets from wiki. --&amp;gt;&lt;br /&gt;
&amp;lt;xsl:stylesheet xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
  xmlns:x=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; version=&amp;quot;1.0&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- There is already an XML declaration in the file --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- we are extracting, and we don&amp;#039;t want two of &amp;#039;em --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:output method=&amp;quot;xml&amp;quot; omit-xml-declaration=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- get the title of this web page --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:variable name=&amp;quot;title&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:value-of select=&amp;quot;//x:head/x:title&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/xsl:variable&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:choose&amp;gt;&lt;br /&gt;
      &amp;lt;!-- special case: if this is the Copy-All.xsl page, --&amp;gt;&lt;br /&gt;
      &amp;lt;!-- take the 2nd &amp;lt;pre&amp;gt; element --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:when test=&amp;quot;starts-with(\$title,&amp;#039;Copy-All.&amp;#039;)&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;//x:pre[2]&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/xsl:when&amp;gt;&lt;br /&gt;
      &amp;lt;!-- for all others take the first (and only) &amp;lt;pre&amp;gt; --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:otherwise&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;//x:pre[1]&amp;quot;/&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:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- when we hit the &amp;lt;pre&amp;gt; we want, just copy it --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- entirely to the output --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:pre&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;/xsl:stylesheet&amp;gt;&lt;br /&gt;
EOEC&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Check that we can process those stylesheets we just created&lt;br /&gt;
# &lt;br /&gt;
which xsltproc || die &amp;quot;I can&amp;#039;t find `xsltproc`, which is the only XSLT processor I know about.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# get the TEI Wiki P4 to P5 index page (which lists all the stylesheets&lt;br /&gt;
# we want to get)&lt;br /&gt;
# &lt;br /&gt;
f=&amp;quot;http://www.tei-c.org/wiki/index.php/Category:P4toP5&amp;quot;&lt;br /&gt;
echo &amp;quot;extracting index page $f to file ${f##*/}&amp;quot;&lt;br /&gt;
get &amp;quot;$f&amp;quot; &amp;quot;${f##*/}&amp;quot; || die &amp;quot;Unable to fetch P4 to P5 index page.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# extract the list of files we want from the list of articles&lt;br /&gt;
# in the index page; then, for each of those files ...&lt;br /&gt;
# &lt;br /&gt;
for f in `xsltproc extractList.xslt Category:P4toP5` ; do&lt;br /&gt;
    # ... generate the web address and announce our intention ...&lt;br /&gt;
    f=&amp;quot;http://www.tei-c.org$f&amp;quot;&lt;br /&gt;
    echo &amp;quot;extracting code from $f to file ${f##*/} ...&amp;quot;&lt;br /&gt;
    # ... get the page from the web, storing as a temp file ...&lt;br /&gt;
    get &amp;quot;$f&amp;quot; &amp;quot;$0_temp&amp;quot; || echo &amp;quot;WARNING: unable to fetch $f.&amp;quot;&lt;br /&gt;
    # ... process temp file into the desired file&lt;br /&gt;
    xsltproc extractCode.xslt $0_temp | perl -pe &amp;#039;s/&amp;amp;lt;/&amp;lt;/g; s/&amp;amp;gt;/&amp;gt;/g;&amp;#039; &amp;gt;  ${f##*/}&lt;br /&gt;
    done&lt;br /&gt;
&lt;br /&gt;
# -----------------------------------------------------&lt;br /&gt;
# Copyright 2006 Syd Bauman and the Text Encoding Initiative&lt;br /&gt;
# Consortium. This program is free software; you can redistribute it&lt;br /&gt;
# and/or modify it under the terms of the GNU General Public License&lt;br /&gt;
# as published by the Free Software Foundation; either version 2 of&lt;br /&gt;
# the License, or (at your option) any later version. This program is&lt;br /&gt;
# distributed in the hope that it will be useful, but WITHOUT ANY&lt;br /&gt;
# WARRANTY; without even the implied warranty of MERCHANTABILITY or&lt;br /&gt;
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License&lt;br /&gt;
# for more details. You should have received a copy of the GNU General&lt;br /&gt;
# Public License along with this program; if not, write to the&lt;br /&gt;
#        Free Software Foundation, Inc.&lt;br /&gt;
#        675 Mass Ave&lt;br /&gt;
#        Cambridge, MA  02139&lt;br /&gt;
#        USA&lt;br /&gt;
#        gnu@prep.ai.mit.edu&lt;br /&gt;
#&lt;br /&gt;
# Syd Bauman, north american editor&lt;br /&gt;
# Text Encoding Initiative Consortium&lt;br /&gt;
# Box 1841&lt;br /&gt;
# Providence, RI  02912-1841&lt;br /&gt;
# 401-863-3835&lt;br /&gt;
# Syd_Bauman@Brown.edu&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
[[Category:P4toP5]]&lt;/div&gt;</summary>
		<author><name>Piotr Banski</name></author>
	</entry>
	<entry>
		<id>https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=3106&amp;oldid=prev</id>
		<title>Piotr Banski: revert (vandalism) + typos</title>
		<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=3106&amp;oldid=prev"/>
		<updated>2007-04-11T10:15:54Z</updated>

		<summary type="html">&lt;p&gt;revert (vandalism) + typos&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is a shell script that tries to read the [[Category:P4toP5|P4 to P5]] &amp;lt;!-- start stupidity here just because I can&amp;#039;t figure out how to like to category page at all, let alone w/ alternate text --&amp;gt;category page for&lt;br /&gt;
stylesheets for P4 to P5 conversion&amp;lt;!-- end --&amp;gt;, follow all of the&lt;br /&gt;
links from that page to the articles in this category, download each of those pages, and then extract the actual code from the downloaded page and save it with the expected name.&lt;br /&gt;
&lt;br /&gt;
To use this program copy-and-paste the following code into a file in an otherwise empty&lt;br /&gt;
directory. The new file can be named whatever you like. Here we are going to assume it&lt;br /&gt;
is called &amp;quot;downloadP4toP5.bash&amp;quot;. Ensure that this new file is executable (e.g., `chmod a+x downloadP5toP5.bash`). With the current working directory set to the directly downloadP4toP5.bash is in, execute it (e.g., `./downloadP5toP5.bash`). No parameters or switches are required, but&lt;br /&gt;
an internet connection is.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;#! /bin/bash&lt;br /&gt;
&lt;br /&gt;
# downloadP4toP5.bash&lt;br /&gt;
# Extract the code from all of the articles listed in the P4toP5 category&lt;br /&gt;
# of the TEI wiki.&lt;br /&gt;
#&lt;br /&gt;
# Written 2006-10-05 by Syd Bauman&lt;br /&gt;
# Copyright 2006 by Syd Bauman and the Text Encoding Initiative Consortium&lt;br /&gt;
# See near bottom of file for complete copyleft notice&lt;br /&gt;
#&lt;br /&gt;
# This routine has been testing in Debian GNU/Linux and in Mac OS X.&lt;br /&gt;
# It may work in other environments, it may not. It downloads the&lt;br /&gt;
# files to its own directory, which had better be writeable or you&amp;#039;ll&lt;br /&gt;
# see a lot of error messages and get no results.&lt;br /&gt;
#&lt;br /&gt;
# Limitations / Future Plans&lt;br /&gt;
# ----------- - ------ -----&lt;br /&gt;
# Currently, this routine requires that you have `xsltproc` and either&lt;br /&gt;
# `wget` or `curl` in your PATH. Perhaps in the future we should make&lt;br /&gt;
# it operate with other XSLT engines and URL fetchers.&lt;br /&gt;
#&lt;br /&gt;
# Should add a -d switch which will cause some tracing the _temp files&lt;br /&gt;
# to remain, otherwise they should be erased.&lt;br /&gt;
#&lt;br /&gt;
# Warning&lt;br /&gt;
# -------&lt;br /&gt;
# This program is really quite fragile. It&amp;#039;s really just a hack, and&lt;br /&gt;
# it will break if anything on the wiki changes in any significant&lt;br /&gt;
# way. E.g., if someone were to add a new article in which the&lt;br /&gt;
# stylesheet code itself were not the 1st &amp;lt;pre&amp;gt;, we&amp;#039;d mess up on that&lt;br /&gt;
# particular stylesheet.&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# error subroutine&lt;br /&gt;
# &lt;br /&gt;
die()&lt;br /&gt;
{&lt;br /&gt;
    echo; echo &amp;quot;ERROR: $@.&amp;quot;&lt;br /&gt;
    D=`date &amp;quot;+%Y-%m-%d %H:%M:%S&amp;quot;`&lt;br /&gt;
    echo &amp;quot;This was a fatal error. $D&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# subroutine to retrieve web page&lt;br /&gt;
# &lt;br /&gt;
if which wget&lt;br /&gt;
then&lt;br /&gt;
    get()&lt;br /&gt;
    {&lt;br /&gt;
	wget --no-directories --output-document=&amp;quot;$2&amp;quot; $1&lt;br /&gt;
    }&lt;br /&gt;
elif which curl&lt;br /&gt;
then&lt;br /&gt;
    get()&lt;br /&gt;
    {&lt;br /&gt;
	curl --silent $1 &amp;gt; $2&lt;br /&gt;
    }&lt;br /&gt;
else&lt;br /&gt;
    die &amp;quot;I can&amp;#039;t find a command with which to download web files, so I&amp;#039;m giving up.&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# create our XSLT file for extracting the list of stylesheets&lt;br /&gt;
# &lt;br /&gt;
cat &amp;gt; extractList.xslt &amp;lt;&amp;lt;EOEL&lt;br /&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;!-- temporary stylesheet for use by shell script that --&amp;gt;&lt;br /&gt;
&amp;lt;!-- sucks P4 to P5 stylesheets from wiki. This routine --&amp;gt;&lt;br /&gt;
&amp;lt;!-- reads in the P4 to P5 index page and produces a --&amp;gt;&lt;br /&gt;
&amp;lt;!-- space-separated list of the links to articles con- --&amp;gt;&lt;br /&gt;
&amp;lt;!-- tained therein. --&amp;gt;&lt;br /&gt;
&amp;lt;xsl:stylesheet xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
  xmlns:x=&amp;quot;http://www.w3.org/1999/xhtml&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;/&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- ignore everything but &amp;lt;table&amp;gt; elements --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:apply-templates select=&amp;quot;//x:table&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- ignore the &amp;lt;table&amp;gt; that&amp;#039;s for the table of contents, too --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:table[@id=&amp;#039;toc&amp;#039;]&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- the only non-TOC table should be the list of articles --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:table&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- for each descendant link ... --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:for-each select=&amp;quot;.//x:a&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;!-- ... write out the target ... --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:value-of select=&amp;quot;@href&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;!-- ... and a blank to separate. --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:text&amp;gt; &amp;lt;/xsl:text&amp;gt;&lt;br /&gt;
    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
EOEL&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# create our XSLT file for extracting code from a page&lt;br /&gt;
# &lt;br /&gt;
cat &amp;gt; extractCode.xslt &amp;lt;&amp;lt;EOEC&lt;br /&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;!-- temporary stylesheet for use by shell script that --&amp;gt;&lt;br /&gt;
&amp;lt;!-- sucks P4 to P5 stylesheets from wiki. --&amp;gt;&lt;br /&gt;
&amp;lt;xsl:stylesheet xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
  xmlns:x=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; version=&amp;quot;1.0&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- There is already an XML declaration in the file --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- we are extracting, and we don&amp;#039;t want two of &amp;#039;em --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:output method=&amp;quot;xml&amp;quot; omit-xml-declaration=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- get the title of this web page --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:variable name=&amp;quot;title&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:value-of select=&amp;quot;//x:head/x:title&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/xsl:variable&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:choose&amp;gt;&lt;br /&gt;
      &amp;lt;!-- special case: if this is the Copy-All.xsl page, --&amp;gt;&lt;br /&gt;
      &amp;lt;!-- take the 2nd &amp;lt;pre&amp;gt; element --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:when test=&amp;quot;starts-with(\$title,&amp;#039;Copy-All.&amp;#039;)&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;//x:pre[2]&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/xsl:when&amp;gt;&lt;br /&gt;
      &amp;lt;!-- for all others take the first (and only) &amp;lt;pre&amp;gt; --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:otherwise&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;//x:pre[1]&amp;quot;/&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:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- when we hit the &amp;lt;pre&amp;gt; we want, just copy it --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- entirely to the output --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:pre&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;/xsl:stylesheet&amp;gt;&lt;br /&gt;
EOEC&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Check that we can process those stylesheets we just created&lt;br /&gt;
# &lt;br /&gt;
which xsltproc || die &amp;quot;I can&amp;#039;t find `xsltproc`, which is the only XSLT processor I know about.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# get the TEI Wiki P4 to P5 index page (which lists all the stylesheets&lt;br /&gt;
# we want to get)&lt;br /&gt;
# &lt;br /&gt;
f=&amp;quot;http://www.tei-c.org/wiki/index.php/Category:P4toP5&amp;quot;&lt;br /&gt;
echo &amp;quot;extracting index page $f to file ${f##*/}&amp;quot;&lt;br /&gt;
get &amp;quot;$f&amp;quot; &amp;quot;${f##*/}&amp;quot; || die &amp;quot;Unable to fetch P4 to P5 index page.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# extract the list of files we want from the list of articles&lt;br /&gt;
# in the index page; then, for each of those files ...&lt;br /&gt;
# &lt;br /&gt;
for f in `xsltproc extractList.xslt Category:P4toP5` ; do&lt;br /&gt;
    # ... generate the web address and announce our intention ...&lt;br /&gt;
    f=&amp;quot;http://www.tei-c.org$f&amp;quot;&lt;br /&gt;
    echo &amp;quot;extracting code from $f to file ${f##*/} ...&amp;quot;&lt;br /&gt;
    # ... get the page from the web, storing as a temp file ...&lt;br /&gt;
    get &amp;quot;$f&amp;quot; &amp;quot;$0_temp&amp;quot; || echo &amp;quot;WARNING: unable to fetch $f.&amp;quot;&lt;br /&gt;
    # ... process temp file into the desired file&lt;br /&gt;
    xsltproc extractCode.xslt $0_temp | perl -pe &amp;#039;s/&amp;amp;lt;/&amp;lt;/g; s/&amp;amp;gt;/&amp;gt;/g;&amp;#039; &amp;gt;  ${f##*/}&lt;br /&gt;
    done&lt;br /&gt;
&lt;br /&gt;
# -----------------------------------------------------&lt;br /&gt;
# Copyright 2006 Syd Bauman and the Text Encoding Initiative&lt;br /&gt;
# Consortium. This program is free software; you can redistribute it&lt;br /&gt;
# and/or modify it under the terms of the GNU General Public License&lt;br /&gt;
# as published by the Free Software Foundation; either version 2 of&lt;br /&gt;
# the License, or (at your option) any later version. This program is&lt;br /&gt;
# distributed in the hope that it will be useful, but WITHOUT ANY&lt;br /&gt;
# WARRANTY; without even the implied warranty of MERCHANTABILITY or&lt;br /&gt;
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License&lt;br /&gt;
# for more details. You should have received a copy of the GNU General&lt;br /&gt;
# Public License along with this program; if not, write to the&lt;br /&gt;
#        Free Software Foundation, Inc.&lt;br /&gt;
#        675 Mass Ave&lt;br /&gt;
#        Cambridge, MA  02139&lt;br /&gt;
#        USA&lt;br /&gt;
#        gnu@prep.ai.mit.edu&lt;br /&gt;
#&lt;br /&gt;
# Syd Bauman, north american editor&lt;br /&gt;
# Text Encoding Initiative Consortium&lt;br /&gt;
# Box 1841&lt;br /&gt;
# Providence, RI  02912-1841&lt;br /&gt;
# 401-863-3835&lt;br /&gt;
# Syd_Bauman@Brown.edu&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
[[Category:P4toP5]]&lt;/div&gt;</summary>
		<author><name>Piotr Banski</name></author>
	</entry>
	<entry>
		<id>https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=3098&amp;oldid=prev</id>
		<title>Piotr Banski: revert</title>
		<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=3098&amp;oldid=prev"/>
		<updated>2007-04-10T23:49:37Z</updated>

		<summary type="html">&lt;p&gt;revert&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is a shell script that tries to read the [[Category:P4toP5|P4 to P5]] &amp;lt;!-- start stupidity here just because I can&amp;#039;t figure out how to like to category page at all, let alone w/ alternate text --&amp;gt;category page for&lt;br /&gt;
stylesheets for P4 to P5 conversion&amp;lt;!-- end --&amp;gt;, follow all of the&lt;br /&gt;
links from that page to the articles in this category, download each of those pages, and then extract the actual code from the downloaded page and save it with the expected name.&lt;br /&gt;
&lt;br /&gt;
To use this program copy-and-paste the following code into a file in an otherwise empty&lt;br /&gt;
directory. The new file can be named whatever you like. Here we are going to sassume it&lt;br /&gt;
is called &amp;quot;downloadP4toP5.bash&amp;quot;. Ensure that this new file is executable (e.g., `chmod a+x downloadP5toP5.bash`). With the current working directory set to the directy downloadP4toP5.bash is in, execute it (e.g., `./downloadP5toP5.bash`). No parameters or switches are required, but&lt;br /&gt;
an internet connection is.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;#! /bin/bash&lt;br /&gt;
&lt;br /&gt;
# downloadP4toP5.bash&lt;br /&gt;
# Extract the code from all of the articles listed in the P4toP5 category&lt;br /&gt;
# of the TEI wiki.&lt;br /&gt;
#&lt;br /&gt;
# Written 2006-10-05 by Syd Bauman&lt;br /&gt;
# Copyright 2006 by Syd Bauman and the Text Encoding Initiative Consortium&lt;br /&gt;
# See near bottom of file for complete copyleft notice&lt;br /&gt;
#&lt;br /&gt;
# This routine has been testing in Debian GNU/Linux and in Mac OS X.&lt;br /&gt;
# It may work in other environments, it may not. It downloads the&lt;br /&gt;
# files to its own directory, which had better be writeable or you&amp;#039;ll&lt;br /&gt;
# see a lot of error messages and get no results.&lt;br /&gt;
#&lt;br /&gt;
# Limitations / Future Plans&lt;br /&gt;
# ----------- - ------ -----&lt;br /&gt;
# Currently, this routine requires that you have `xsltproc` and either&lt;br /&gt;
# `wget` or `curl` in your PATH. Perhaps in the future we should make&lt;br /&gt;
# it operate with other XSLT engines and URL fetchers.&lt;br /&gt;
#&lt;br /&gt;
# Should add a -d switch which will cause some tracing the _temp files&lt;br /&gt;
# to remain, otherwise they should be erased.&lt;br /&gt;
#&lt;br /&gt;
# Warning&lt;br /&gt;
# -------&lt;br /&gt;
# This program is really quite fragile. It&amp;#039;s really just a hack, and&lt;br /&gt;
# it will break if anything on the wiki changes in any significant&lt;br /&gt;
# way. E.g., if someone were to add a new article in which the&lt;br /&gt;
# stylesheet code itself were not the 1st &amp;lt;pre&amp;gt;, we&amp;#039;d mess up on that&lt;br /&gt;
# particular stylesheet.&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# error subroutine&lt;br /&gt;
# &lt;br /&gt;
die()&lt;br /&gt;
{&lt;br /&gt;
    echo; echo &amp;quot;ERROR: $@.&amp;quot;&lt;br /&gt;
    D=`date &amp;quot;+%Y-%m-%d %H:%M:%S&amp;quot;`&lt;br /&gt;
    echo &amp;quot;This was a fatal error. $D&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# subroutine to retrieve web page&lt;br /&gt;
# &lt;br /&gt;
if which wget&lt;br /&gt;
then&lt;br /&gt;
    get()&lt;br /&gt;
    {&lt;br /&gt;
	wget --no-directories --output-document=&amp;quot;$2&amp;quot; $1&lt;br /&gt;
    }&lt;br /&gt;
elif which curl&lt;br /&gt;
then&lt;br /&gt;
    get()&lt;br /&gt;
    {&lt;br /&gt;
	curl --silent $1 &amp;gt; $2&lt;br /&gt;
    }&lt;br /&gt;
else&lt;br /&gt;
    die &amp;quot;I can&amp;#039;t find a command with which to download web files, so I&amp;#039;m giving up.&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# create our XSLT file for extracting the list of stylesheets&lt;br /&gt;
# &lt;br /&gt;
cat &amp;gt; extractList.xslt &amp;lt;&amp;lt;EOEL&lt;br /&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;!-- temporary stylesheet for use by shell script that --&amp;gt;&lt;br /&gt;
&amp;lt;!-- sucks P4 to P5 stylesheets from wiki. This routine --&amp;gt;&lt;br /&gt;
&amp;lt;!-- reads in the P4 to P5 index page and produces a --&amp;gt;&lt;br /&gt;
&amp;lt;!-- space-separated list of the links to articles con- --&amp;gt;&lt;br /&gt;
&amp;lt;!-- tained therein. --&amp;gt;&lt;br /&gt;
&amp;lt;xsl:stylesheet xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
  xmlns:x=&amp;quot;http://www.w3.org/1999/xhtml&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;/&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- ignore everything but &amp;lt;table&amp;gt; elements --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:apply-templates select=&amp;quot;//x:table&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- ignore the &amp;lt;table&amp;gt; that&amp;#039;s for the table of contents, too --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:table[@id=&amp;#039;toc&amp;#039;]&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- the only non-TOC table should be the list of articles --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:table&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- for each descendant link ... --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:for-each select=&amp;quot;.//x:a&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;!-- ... write out the target ... --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:value-of select=&amp;quot;@href&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;!-- ... and a blank to separate. --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:text&amp;gt; &amp;lt;/xsl:text&amp;gt;&lt;br /&gt;
    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
EOEL&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# create our XSLT file for extracting code from a page&lt;br /&gt;
# &lt;br /&gt;
cat &amp;gt; extractCode.xslt &amp;lt;&amp;lt;EOEC&lt;br /&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;!-- temporary stylesheet for use by shell script that --&amp;gt;&lt;br /&gt;
&amp;lt;!-- sucks P4 to P5 stylesheets from wiki. --&amp;gt;&lt;br /&gt;
&amp;lt;xsl:stylesheet xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
  xmlns:x=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; version=&amp;quot;1.0&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- There is already an XML declaration in the file --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- we are extracting, and we don&amp;#039;t want two of &amp;#039;em --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:output method=&amp;quot;xml&amp;quot; omit-xml-declaration=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- get the title of this web page --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:variable name=&amp;quot;title&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:value-of select=&amp;quot;//x:head/x:title&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/xsl:variable&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:choose&amp;gt;&lt;br /&gt;
      &amp;lt;!-- special case: if this is the Copy-All.xsl page, --&amp;gt;&lt;br /&gt;
      &amp;lt;!-- take the 2nd &amp;lt;pre&amp;gt; element --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:when test=&amp;quot;starts-with(\$title,&amp;#039;Copy-All.&amp;#039;)&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;//x:pre[2]&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/xsl:when&amp;gt;&lt;br /&gt;
      &amp;lt;!-- for all others take the first (and only) &amp;lt;pre&amp;gt; --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:otherwise&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;//x:pre[1]&amp;quot;/&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:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- when we hit the &amp;lt;pre&amp;gt; we want, just copy it --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- entirely to the output --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:pre&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;/xsl:stylesheet&amp;gt;&lt;br /&gt;
EOEC&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Check that we can process those stylesheets we just created&lt;br /&gt;
# &lt;br /&gt;
which xsltproc || die &amp;quot;I can&amp;#039;t find `xsltproc`, which is the only XSLT processor I know about.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# get the TEI Wiki P4 to P5 index page (which lists all the stylesheets&lt;br /&gt;
# we want to get)&lt;br /&gt;
# &lt;br /&gt;
f=&amp;quot;http://www.tei-c.org/wiki/index.php/Category:P4toP5&amp;quot;&lt;br /&gt;
echo &amp;quot;extracting index page $f to file ${f##*/}&amp;quot;&lt;br /&gt;
get &amp;quot;$f&amp;quot; &amp;quot;${f##*/}&amp;quot; || die &amp;quot;Unable to fetch P4 to P5 index page.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# extract the list of files we want from the list of articles&lt;br /&gt;
# in the index page; then, for each of those files ...&lt;br /&gt;
# &lt;br /&gt;
for f in `xsltproc extractList.xslt Category:P4toP5` ; do&lt;br /&gt;
    # ... generate the web address and announce our intention ...&lt;br /&gt;
    f=&amp;quot;http://www.tei-c.org$f&amp;quot;&lt;br /&gt;
    echo &amp;quot;extracting code from $f to file ${f##*/} ...&amp;quot;&lt;br /&gt;
    # ... get the page from the web, storing as a temp file ...&lt;br /&gt;
    get &amp;quot;$f&amp;quot; &amp;quot;$0_temp&amp;quot; || echo &amp;quot;WARNING: unable to fetch $f.&amp;quot;&lt;br /&gt;
    # ... process temp file into the desired file&lt;br /&gt;
    xsltproc extractCode.xslt $0_temp | perl -pe &amp;#039;s/&amp;amp;lt;/&amp;lt;/g; s/&amp;amp;gt;/&amp;gt;/g;&amp;#039; &amp;gt;  ${f##*/}&lt;br /&gt;
    done&lt;br /&gt;
&lt;br /&gt;
# -----------------------------------------------------&lt;br /&gt;
# Copyright 2006 Syd Bauman and the Text Encoding Initiative&lt;br /&gt;
# Consortium. This program is free software; you can redistribute it&lt;br /&gt;
# and/or modify it under the terms of the GNU General Public License&lt;br /&gt;
# as published by the Free Software Foundation; either version 2 of&lt;br /&gt;
# the License, or (at your option) any later version. This program is&lt;br /&gt;
# distributed in the hope that it will be useful, but WITHOUT ANY&lt;br /&gt;
# WARRANTY; without even the implied warranty of MERCHANTABILITY or&lt;br /&gt;
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License&lt;br /&gt;
# for more details. You should have received a copy of the GNU General&lt;br /&gt;
# Public License along with this program; if not, write to the&lt;br /&gt;
#        Free Software Foundation, Inc.&lt;br /&gt;
#        675 Mass Ave&lt;br /&gt;
#        Cambridge, MA  02139&lt;br /&gt;
#        USA&lt;br /&gt;
#        gnu@prep.ai.mit.edu&lt;br /&gt;
#&lt;br /&gt;
# Syd Bauman, north american editor&lt;br /&gt;
# Text Encoding Initiative Consortium&lt;br /&gt;
# Box 1841&lt;br /&gt;
# Providence, RI  02912-1841&lt;br /&gt;
# 401-863-3835&lt;br /&gt;
# Syd_Bauman@Brown.edu&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
[[Category:P4toP5]]&lt;/div&gt;</summary>
		<author><name>Piotr Banski</name></author>
	</entry>
	<entry>
		<id>https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=2817&amp;oldid=prev</id>
		<title>Syd at 04:00, 24 October 2006</title>
		<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=2817&amp;oldid=prev"/>
		<updated>2006-10-24T04:00:07Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:00, 24 October 2006&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is a shell script that tries to read the [[Category:P4toP5]] category page, follow all of the&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is a shell script that tries to read the [[Category:P4toP5&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|P4 to P5&lt;/ins&gt;]] &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;!-- start stupidity here just because I can&#039;t figure out how to like to &lt;/ins&gt;category page &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;at all, let alone w/ alternate text --&amp;gt;category page for&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;stylesheets for P4 to P5 conversion&amp;lt;!-- end --&amp;gt;&lt;/ins&gt;, follow all of the&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;links from that page to the articles in this category, download each of those pages, and then extract the actual code from the downloaded page and save it with the expected name.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;links from that page to the articles in this category, download each of those pages, and then extract the actual code from the downloaded page and save it with the expected name.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Syd</name></author>
	</entry>
	<entry>
		<id>https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=2816&amp;oldid=prev</id>
		<title>Syd at 03:55, 24 October 2006</title>
		<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=2816&amp;oldid=prev"/>
		<updated>2006-10-24T03:55:43Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 03:55, 24 October 2006&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is a shell script that tries to read the [[P4toP5]] category page, follow all of the&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This is a shell script that tries to read the [[&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Category:&lt;/ins&gt;P4toP5]] category page, follow all of the&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;links from that page to the articles in this category, download each of those pages, and then extract the actual code from the downloaded page and save it with the expected name.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;links from that page to the articles in this category, download each of those pages, and then extract the actual code from the downloaded page and save it with the expected name.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Syd</name></author>
	</entry>
	<entry>
		<id>https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=2815&amp;oldid=prev</id>
		<title>Syd: put it into P4 to P5 category</title>
		<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=2815&amp;oldid=prev"/>
		<updated>2006-10-24T03:48:37Z</updated>

		<summary type="html">&lt;p&gt;put it into P4 to P5 category&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 03:48, 24 October 2006&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l197&quot;&gt;Line 197:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 197:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# 401-863-3835&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# 401-863-3835&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Syd_Bauman@Brown.edu&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Syd_Bauman@Brown.edu&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:P4toP5]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Syd</name></author>
	</entry>
	<entry>
		<id>https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=2814&amp;oldid=prev</id>
		<title>Syd: initial check-in of 1st version of stylesheeting-downloading hack</title>
		<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=DownloadP4toP5.bash&amp;diff=2814&amp;oldid=prev"/>
		<updated>2006-10-24T03:47:08Z</updated>

		<summary type="html">&lt;p&gt;initial check-in of 1st version of stylesheeting-downloading hack&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is a shell script that tries to read the [[P4toP5]] category page, follow all of the&lt;br /&gt;
links from that page to the articles in this category, download each of those pages, and then extract the actual code from the downloaded page and save it with the expected name.&lt;br /&gt;
&lt;br /&gt;
To use this program copy-and-paste the following code into a file in an otherwise empty&lt;br /&gt;
directory. The new file can be named whatever you like. Here we are going to sassume it&lt;br /&gt;
is called &amp;quot;downloadP4toP5.bash&amp;quot;. Ensure that this new file is executable (e.g., `chmod a+x downloadP5toP5.bash`). With the current working directory set to the directy downloadP4toP5.bash is in, execute it (e.g., `./downloadP5toP5.bash`). No parameters or switches are required, but&lt;br /&gt;
an internet connection is.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;#! /bin/bash&lt;br /&gt;
&lt;br /&gt;
# downloadP4toP5.bash&lt;br /&gt;
# Extract the code from all of the articles listed in the P4toP5 category&lt;br /&gt;
# of the TEI wiki.&lt;br /&gt;
#&lt;br /&gt;
# Written 2006-10-05 by Syd Bauman&lt;br /&gt;
# Copyright 2006 by Syd Bauman and the Text Encoding Initiative Consortium&lt;br /&gt;
# See near bottom of file for complete copyleft notice&lt;br /&gt;
#&lt;br /&gt;
# This routine has been testing in Debian GNU/Linux and in Mac OS X.&lt;br /&gt;
# It may work in other environments, it may not. It downloads the&lt;br /&gt;
# files to its own directory, which had better be writeable or you&amp;#039;ll&lt;br /&gt;
# see a lot of error messages and get no results.&lt;br /&gt;
#&lt;br /&gt;
# Limitations / Future Plans&lt;br /&gt;
# ----------- - ------ -----&lt;br /&gt;
# Currently, this routine requires that you have `xsltproc` and either&lt;br /&gt;
# `wget` or `curl` in your PATH. Perhaps in the future we should make&lt;br /&gt;
# it operate with other XSLT engines and URL fetchers.&lt;br /&gt;
#&lt;br /&gt;
# Should add a -d switch which will cause some tracing the _temp files&lt;br /&gt;
# to remain, otherwise they should be erased.&lt;br /&gt;
#&lt;br /&gt;
# Warning&lt;br /&gt;
# -------&lt;br /&gt;
# This program is really quite fragile. It&amp;#039;s really just a hack, and&lt;br /&gt;
# it will break if anything on the wiki changes in any significant&lt;br /&gt;
# way. E.g., if someone were to add a new article in which the&lt;br /&gt;
# stylesheet code itself were not the 1st &amp;lt;pre&amp;gt;, we&amp;#039;d mess up on that&lt;br /&gt;
# particular stylesheet.&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# error subroutine&lt;br /&gt;
# &lt;br /&gt;
die()&lt;br /&gt;
{&lt;br /&gt;
    echo; echo &amp;quot;ERROR: $@.&amp;quot;&lt;br /&gt;
    D=`date &amp;quot;+%Y-%m-%d %H:%M:%S&amp;quot;`&lt;br /&gt;
    echo &amp;quot;This was a fatal error. $D&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# subroutine to retrieve web page&lt;br /&gt;
# &lt;br /&gt;
if which wget&lt;br /&gt;
then&lt;br /&gt;
    get()&lt;br /&gt;
    {&lt;br /&gt;
	wget --no-directories --output-document=&amp;quot;$2&amp;quot; $1&lt;br /&gt;
    }&lt;br /&gt;
elif which curl&lt;br /&gt;
then&lt;br /&gt;
    get()&lt;br /&gt;
    {&lt;br /&gt;
	curl --silent $1 &amp;gt; $2&lt;br /&gt;
    }&lt;br /&gt;
else&lt;br /&gt;
    die &amp;quot;I can&amp;#039;t find a command with which to download web files, so I&amp;#039;m giving up.&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# create our XSLT file for extracting the list of stylesheets&lt;br /&gt;
# &lt;br /&gt;
cat &amp;gt; extractList.xslt &amp;lt;&amp;lt;EOEL&lt;br /&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;!-- temporary stylesheet for use by shell script that --&amp;gt;&lt;br /&gt;
&amp;lt;!-- sucks P4 to P5 stylesheets from wiki. This routine --&amp;gt;&lt;br /&gt;
&amp;lt;!-- reads in the P4 to P5 index page and produces a --&amp;gt;&lt;br /&gt;
&amp;lt;!-- space-separated list of the links to articles con- --&amp;gt;&lt;br /&gt;
&amp;lt;!-- tained therein. --&amp;gt;&lt;br /&gt;
&amp;lt;xsl:stylesheet xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
  xmlns:x=&amp;quot;http://www.w3.org/1999/xhtml&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;/&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- ignore everything but &amp;lt;table&amp;gt; elements --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:apply-templates select=&amp;quot;//x:table&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- ignore the &amp;lt;table&amp;gt; that&amp;#039;s for the table of contents, too --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:table[@id=&amp;#039;toc&amp;#039;]&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- the only non-TOC table should be the list of articles --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:table&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- for each descendant link ... --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:for-each select=&amp;quot;.//x:a&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;!-- ... write out the target ... --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:value-of select=&amp;quot;@href&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;!-- ... and a blank to separate. --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:text&amp;gt; &amp;lt;/xsl:text&amp;gt;&lt;br /&gt;
    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
EOEL&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# create our XSLT file for extracting code from a page&lt;br /&gt;
# &lt;br /&gt;
cat &amp;gt; extractCode.xslt &amp;lt;&amp;lt;EOEC&lt;br /&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;!-- temporary stylesheet for use by shell script that --&amp;gt;&lt;br /&gt;
&amp;lt;!-- sucks P4 to P5 stylesheets from wiki. --&amp;gt;&lt;br /&gt;
&amp;lt;xsl:stylesheet xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot;&lt;br /&gt;
  xmlns:x=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; version=&amp;quot;1.0&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- There is already an XML declaration in the file --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- we are extracting, and we don&amp;#039;t want two of &amp;#039;em --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:output method=&amp;quot;xml&amp;quot; omit-xml-declaration=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;/&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;!-- get the title of this web page --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:variable name=&amp;quot;title&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:value-of select=&amp;quot;//x:head/x:title&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/xsl:variable&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:choose&amp;gt;&lt;br /&gt;
      &amp;lt;!-- special case: if this is the Copy-All.xsl page, --&amp;gt;&lt;br /&gt;
      &amp;lt;!-- take the 2nd &amp;lt;pre&amp;gt; element --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:when test=&amp;quot;starts-with(\$title,&amp;#039;Copy-All.&amp;#039;)&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;//x:pre[2]&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/xsl:when&amp;gt;&lt;br /&gt;
      &amp;lt;!-- for all others take the first (and only) &amp;lt;pre&amp;gt; --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:otherwise&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:apply-templates select=&amp;quot;//x:pre[1]&amp;quot;/&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:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- when we hit the &amp;lt;pre&amp;gt; we want, just copy it --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- entirely to the output --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;x:pre&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;/xsl:stylesheet&amp;gt;&lt;br /&gt;
EOEC&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Check that we can process those stylesheets we just created&lt;br /&gt;
# &lt;br /&gt;
which xsltproc || die &amp;quot;I can&amp;#039;t find `xsltproc`, which is the only XSLT processor I know about.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# get the TEI Wiki P4 to P5 index page (which lists all the stylesheets&lt;br /&gt;
# we want to get)&lt;br /&gt;
# &lt;br /&gt;
f=&amp;quot;http://www.tei-c.org/wiki/index.php/Category:P4toP5&amp;quot;&lt;br /&gt;
echo &amp;quot;extracting index page $f to file ${f##*/}&amp;quot;&lt;br /&gt;
get &amp;quot;$f&amp;quot; &amp;quot;${f##*/}&amp;quot; || die &amp;quot;Unable to fetch P4 to P5 index page.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# extract the list of files we want from the list of articles&lt;br /&gt;
# in the index page; then, for each of those files ...&lt;br /&gt;
# &lt;br /&gt;
for f in `xsltproc extractList.xslt Category:P4toP5` ; do&lt;br /&gt;
    # ... generate the web address and announce our intention ...&lt;br /&gt;
    f=&amp;quot;http://www.tei-c.org$f&amp;quot;&lt;br /&gt;
    echo &amp;quot;extracting code from $f to file ${f##*/} ...&amp;quot;&lt;br /&gt;
    # ... get the page from the web, storing as a temp file ...&lt;br /&gt;
    get &amp;quot;$f&amp;quot; &amp;quot;$0_temp&amp;quot; || echo &amp;quot;WARNING: unable to fetch $f.&amp;quot;&lt;br /&gt;
    # ... process temp file into the desired file&lt;br /&gt;
    xsltproc extractCode.xslt $0_temp | perl -pe &amp;#039;s/&amp;amp;lt;/&amp;lt;/g; s/&amp;amp;gt;/&amp;gt;/g;&amp;#039; &amp;gt;  ${f##*/}&lt;br /&gt;
    done&lt;br /&gt;
&lt;br /&gt;
# -----------------------------------------------------&lt;br /&gt;
# Copyright 2006 Syd Bauman and the Text Encoding Initiative&lt;br /&gt;
# Consortium. This program is free software; you can redistribute it&lt;br /&gt;
# and/or modify it under the terms of the GNU General Public License&lt;br /&gt;
# as published by the Free Software Foundation; either version 2 of&lt;br /&gt;
# the License, or (at your option) any later version. This program is&lt;br /&gt;
# distributed in the hope that it will be useful, but WITHOUT ANY&lt;br /&gt;
# WARRANTY; without even the implied warranty of MERCHANTABILITY or&lt;br /&gt;
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License&lt;br /&gt;
# for more details. You should have received a copy of the GNU General&lt;br /&gt;
# Public License along with this program; if not, write to the&lt;br /&gt;
#        Free Software Foundation, Inc.&lt;br /&gt;
#        675 Mass Ave&lt;br /&gt;
#        Cambridge, MA  02139&lt;br /&gt;
#        USA&lt;br /&gt;
#        gnu@prep.ai.mit.edu&lt;br /&gt;
#&lt;br /&gt;
# Syd Bauman, north american editor&lt;br /&gt;
# Text Encoding Initiative Consortium&lt;br /&gt;
# Box 1841&lt;br /&gt;
# Providence, RI  02912-1841&lt;br /&gt;
# 401-863-3835&lt;br /&gt;
# Syd_Bauman@Brown.edu&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Syd</name></author>
	</entry>
</feed>