Statistics
| Revision:

root / tmp / org.txm.oriflamms.rcp / res / oriflamms-project-w-id-2-tei-xml-Fontenay.xsl @ 2398

History | View | Annotate | Download (2 kB)

1
<!-- The Identity Transformation -->
2
<xsl:stylesheet version="2.0"
3
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
	xmlns:xs="http://www.w3.org/2001/XMLSchema">
5

    
6
	<xsl:output method="xml" cdata-section-elements="Word"></xsl:output>
7

    
8
	<xsl:param name="words-with-id-file">
9
		Fontenay-w-id-table.xml
10
	</xsl:param>
11

    
12
	<xsl:variable name="words-with-id" as="element()">
13
		<xsl:copy-of select="document($words-with-id-file)//text"></xsl:copy-of>
14
	</xsl:variable>
15

    
16

    
17
	<!-- Whenever you match any node or any attribute -->
18
	<xsl:template match="node()|@*">
19
		<!-- Copy the current node -->
20
		<xsl:copy>
21
			<!-- Including any attributes it has and any child nodes -->
22
			<xsl:apply-templates select="@*|node()" />
23
		</xsl:copy>
24
	</xsl:template>
25

    
26
	<xsl:template match="Word">
27
		<xsl:variable name="position" as="xs:integer">
28
			<xsl:value-of
29
				select="count(preceding::Word[not(matches(.,'__NOISE__'))]) + 1" />
30
			<!--<xsl:number count="Word[not(matches(.,'__NOISE__'))]" level="any"/> -->
31
		</xsl:variable>
32
		<xsl:if
33
			test="$words-with-id/w[$position]/preceding-sibling::*[1][self::w-add]">
34
			<xsl:comment>
35
				Added word:
36
			</xsl:comment>
37
			<Word x1="{@x1 - 5}" y1="{@y1 - 5}" x2="{@x1 - 1}" y2="{@y2}"
38
				valid="0" imgsig="-" leftcorr="0" rightcorr="0">
39
				<xsl:value-of
40
					select="$words-with-id/w[$position]/preceding-sibling::w-add[1]" />
41
			</Word>
42
		</xsl:if>
43
		<xsl:choose>
44
			<xsl:when test="matches(.,'__NOISE__')">
45
				<xsl:comment>
46
					<xsl:copy-of select="."></xsl:copy-of>
47
				</xsl:comment>
48
			</xsl:when>
49
			<xsl:otherwise>
50
				<xsl:copy>
51
					<xsl:apply-templates select="@*" />
52
					<xsl:attribute name="id"><xsl:value-of
53
						select="$words-with-id/w[$position]/@id" /></xsl:attribute>
54
					<xsl:apply-templates />
55
					<xsl:if test="not(. = $words-with-id/w[$position])">
56
						<xsl:comment>
57
							No match!
58
							<xsl:value-of
59
								select="$words-with-id//w[$position]/text()" />
60
						</xsl:comment>
61
					</xsl:if>
62
				</xsl:copy>
63
			</xsl:otherwise>
64
		</xsl:choose>
65

    
66
	</xsl:template>
67
</xsl:stylesheet>