Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / tools / getfiles.xsl @ 187

History | View | Annotate | Download (3.3 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet xmlns:n="www.example.com" xmlns:tei="http://www.tei-c.org/ns/1.0"
3
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
4
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5
                version="2.0"
6
                exclude-result-prefixes="n tei xs">
7

    
8
  <xsl:param name="debug">false</xsl:param>
9
  <xsl:param name="corpus"/>
10
  <xsl:param name="suffix">xml</xsl:param>
11
  <xsl:param name="corpusList"/>
12
  <xsl:param name="processP4">false</xsl:param>
13
  <xsl:param name="processP5">true</xsl:param>
14
  <xsl:param name="verbose">false</xsl:param>
15
  <xsl:key name="All" match="*" use="1"/>
16
  <xsl:key name="AllTEI" match="tei:*" use="1"/>
17
  <xsl:key name="E" match="*" use="local-name()"/>
18

    
19
  <xsl:template name="main">
20
      <xsl:variable name="pathlist">
21
         <xsl:choose>
22
	   <xsl:when test="$corpusList=''">
23
	     <xsl:value-of select="concat($corpus,'?select=*.',$suffix,';recurse=yes;on-error=warning')"/>
24
	   </xsl:when>
25
	   <xsl:otherwise>
26
	     <xsl:value-of select="$corpusList"/>
27
	   </xsl:otherwise>
28
         </xsl:choose>
29
      </xsl:variable>
30
      <xsl:if test="$debug='true'">
31
	<xsl:message>Process <xsl:value-of select="$pathlist"/></xsl:message>
32
      </xsl:if>
33
      <xsl:variable name="docs" select="collection($pathlist)"/> 
34
      <xsl:variable name="all">
35
         <n:ROOT>
36
	   <xsl:if test="$processP4='true'">
37
	     <xsl:for-each select="$docs/TEI.2">
38
	       <xsl:if test="$verbose='true'">
39
		 <xsl:message>processing <xsl:value-of select="base-uri(.)"/>
40
		 </xsl:message>
41
	       </xsl:if>
42
	       <TEI.2 xn="{base-uri(.)}">
43
		 <xsl:apply-templates select="*|@*" mode="copy"/>
44
	       </TEI.2>
45
	     </xsl:for-each>
46
	   </xsl:if>
47
	   <xsl:if test="$processP5='true'">
48
	     <xsl:for-each select="$docs/tei:*">
49
	       <xsl:if test="$verbose='true'">
50
		 <xsl:message>processing <xsl:value-of select="base-uri(.)"/>
51
		 </xsl:message>
52
	       </xsl:if>
53
	       <tei:TEI xn="{base-uri(.)}">
54
		 <xsl:apply-templates select="*|@*" mode="copy"/>
55
	       </tei:TEI>
56
	     </xsl:for-each>
57
	     <xsl:for-each select="$docs/tei:teiCorpus">
58
	       <xsl:if test="$verbose='true'">
59
		 <xsl:message>processing <xsl:value-of select="base-uri(.)"/>
60
		 </xsl:message>
61
	       </xsl:if>
62
	       <tei:teiCorpus xn="{base-uri(.)}">
63
		 <xsl:copy-of select="@*|*"/>
64
	       </tei:teiCorpus>
65
	     </xsl:for-each>
66
	   </xsl:if>
67
         </n:ROOT>
68
      </xsl:variable>
69
      <xsl:for-each select="$all/*">
70
	<xsl:call-template name="processAll"/>
71
      </xsl:for-each>
72
  </xsl:template>
73

    
74
  <xsl:template name="processAll">
75
      <html>
76
         <body>
77
	   <table border="1">
78
	     <xsl:for-each-group select="key('All',1)" group-by="local-name()">
79
	       <xsl:sort select="current-grouping-key()"/>
80
	       <tr style="vertical-align:top;">
81
		 <td> 
82
		   <xsl:value-of select="current-grouping-key()"/>
83
		 </td> 
84
		 <td> 
85
		   <xsl:value-of select="count(current-group())"/>
86
		 </td> 
87
	       </tr>
88
	     </xsl:for-each-group>
89
	   </table>
90
         </body>
91
      </html>
92
  </xsl:template>
93

    
94
  <xsl:template match="text()|@*" mode="copy">
95
      <xsl:copy-of select="."/>
96
  </xsl:template>
97

    
98
  <xsl:template match="*" mode="copy">
99
      <xsl:copy>
100
         <xsl:apply-templates select="*|@*|text()" mode="copy"/>
101
      </xsl:copy>
102
  </xsl:template>
103
  
104
</xsl:stylesheet>