root/BADataMunger/trunk/wordstripper.xsl

Revision 1427, 3.8 kB (checked in by thomase, 4 months ago)

sticking a fork in the aspect of BADataMunger that is the creation of batlas ids, or so I hope

  • Property svn:eol-style set to native
Line 
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  ===========================================================================
4  Copyright (C) 2006-2008 Ancient World Mapping Center (UNC-CH) and the
5  Institute for the Study of the Ancient World (NYU)
6
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  GNU General Public License for more details.
16
17  You should have received a copy of the GNU General Public License along
18  with this program; if not, write to the Free Software Foundation, Inc.,
19  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21
22  About Pleiades:
23
24  Pleiades is an international research network and associated web portal and
25  content management system devoted to the study of ancient geography.
26
27  See http://pleiades.stoa.org
28
29  Funding for the creation of this software was provided by a grant from the
30  U.S. National Endowment for the Humanities (http://www.neh.gov), and
31  by the Institute for the Study of the Ancient World at New York University
32  (http://www.nyu.edu/isaw)
33  ===========================================================================
34 -->
35
36 <xsl:stylesheet
37     xmlns="http://www.w3.org/1999/xhtml"
38     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
39    
40     <xsl:output encoding="UTF-8" indent="no" method="xml" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
41
42     <xsl:template match="/"><xsl:apply-templates/></xsl:template>
43    
44     <xsl:template match="/|comment()|processing-instruction()">
45         <xsl:copy>
46             <xsl:apply-templates/>
47         </xsl:copy>
48     </xsl:template>
49
50     <!-- suppress all style and br elements -->
51     <xsl:template match="*[local-name()='style' or local-name()='br' or local-name()='sup']"/>
52    
53     <xsl:template match="*[local-name()='i' and normalize-space(.)='&#803;']">&#803;</xsl:template>
54    
55     <!-- strip span tags, but pass through their sub nodes, note that line breaks may matter :| -->
56     <xsl:template match="*[local-name()='span']">
57         <xsl:choose>
58             <xsl:when test="normalize-space(.)=' ' and not(contains(.,'\n'))"/>
59             <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
60         </xsl:choose>
61     </xsl:template>
62    
63     <xsl:template match="*[local-name()='i' and normalize-space(text()) = ' ']"/>
64    
65     <xsl:template match="*"><xsl:call-template name="elepassthrough"/></xsl:template>
66    
67     <xsl:template name="elepassthrough">
68         <xsl:element name="{local-name()}">
69             <xsl:apply-templates select="@*|node()"/>
70         </xsl:element>
71     </xsl:template>
72    
73    
74    
75     <xsl:template match="@*">
76         <xsl:choose>
77             <!-- suppress various stylelistic attributes that we don't need -->
78             <xsl:when test="local-name(.)='style'"/>
79             <xsl:when test="local-name(.)='lang'"/>
80             <xsl:when test="local-name(.)='class'"/>
81             <xsl:when test="local-name(.)='align'"/>
82             <xsl:when test="local-name(.)='border'"/>
83             <xsl:when test="local-name(.)='cellspacing'"/>
84             <xsl:when test="local-name(.)='cellpadding'"/>
85             <xsl:when test="local-name(.)='width'"/>
86             <xsl:when test="local-name(.)='valign'"/>
87             <xsl:when test="local-name(.)='rowspan'"/>
88             <xsl:when test="local-name(.)='colspan'"/>
89             <xsl:otherwise>
90                 <xsl:attribute name="{local-name()}">
91                     <xsl:value-of select="."/>
92                 </xsl:attribute>
93             </xsl:otherwise>
94         </xsl:choose>
95     </xsl:template>
96    
97 </xsl:stylesheet>
Note: See TracBrowser for help on using the browser.