root / tmp / org.txm.oriflamms.rcp / res / oriflamms-project-w-id-2-tei-xml-Fontenay.xsl @ 476
History | View | Annotate | Download (2 kB)
1 |
<!-- The Identity Transformation --> |
---|---|
2 |
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
3 |
|
4 |
<xsl:output method="xml" cdata-section-elements="Word"></xsl:output> |
5 |
|
6 |
<xsl:param name="words-with-id-file">Fontenay-w-id-table.xml</xsl:param> |
7 |
|
8 |
<xsl:variable name="words-with-id" as="element()"> |
9 |
<xsl:copy-of select="document($words-with-id-file)//text"></xsl:copy-of> |
10 |
</xsl:variable> |
11 |
|
12 |
|
13 |
<!-- Whenever you match any node or any attribute --> |
14 |
<xsl:template match="node()|@*"> |
15 |
<!-- Copy the current node --> |
16 |
<xsl:copy> |
17 |
<!-- Including any attributes it has and any child nodes --> |
18 |
<xsl:apply-templates select="@*|node()"/> |
19 |
</xsl:copy> |
20 |
</xsl:template> |
21 |
|
22 |
<xsl:template match="Word"> |
23 |
<xsl:variable name="position" as="xs:integer"> |
24 |
<xsl:value-of select="count(preceding::Word[not(matches(.,'__NOISE__'))]) + 1"/> |
25 |
<!--<xsl:number count="Word[not(matches(.,'__NOISE__'))]" level="any"/>--> |
26 |
</xsl:variable> |
27 |
<xsl:if test="$words-with-id/w[$position]/preceding-sibling::*[1][self::w-add]"> |
28 |
<xsl:comment>Added word: </xsl:comment> |
29 |
<Word x1="{@x1 - 5}" y1="{@y1 - 5}" x2="{@x1 - 1}" y2="{@y2}" valid="0" imgsig="-" leftcorr="0" rightcorr="0"> |
30 |
<xsl:value-of select="$words-with-id/w[$position]/preceding-sibling::w-add[1]"/> |
31 |
</Word> |
32 |
</xsl:if> |
33 |
<xsl:choose> |
34 |
<xsl:when test="matches(.,'__NOISE__')"> |
35 |
<xsl:comment><xsl:copy-of select="."></xsl:copy-of></xsl:comment> |
36 |
</xsl:when> |
37 |
<xsl:otherwise> |
38 |
<xsl:copy> |
39 |
<xsl:apply-templates select="@*"/> |
40 |
<xsl:attribute name="id"><xsl:value-of select="$words-with-id/w[$position]/@id"/></xsl:attribute> |
41 |
<xsl:apply-templates/> |
42 |
<xsl:if test="not(. = $words-with-id/w[$position])"> |
43 |
<xsl:comment>No match! <xsl:value-of select="$words-with-id//w[$position]/text()"/></xsl:comment> |
44 |
</xsl:if> |
45 |
</xsl:copy> |
46 |
</xsl:otherwise> |
47 |
</xsl:choose> |
48 |
|
49 |
</xsl:template> |
50 |
</xsl:stylesheet> |