root / tmp / org.txm.oriflamms.rcp / res / oriflamms-project-w-id-2-tei-xml-qgraal_cm.xsl @ 476
History | View | Annotate | Download (3.9 kB)
1 |
<!-- The Identity Transformation --> |
---|---|
2 |
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
3 |
xmlns:tei="http://www.tei-c.org/ns/1.0" |
4 |
xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
5 |
|
6 |
<xsl:output method="xml"></xsl:output> |
7 |
|
8 |
<xsl:param name="valid-zones-file">qgraalTest-zones-words.xml</xsl:param> |
9 |
|
10 |
<xsl:variable name="valid-zones-element" as="element()"> |
11 |
<xsl:copy-of select="document($valid-zones-file)//tei:facsimile"></xsl:copy-of> |
12 |
</xsl:variable> |
13 |
|
14 |
|
15 |
<!-- Whenever you match any node or any attribute --> |
16 |
<xsl:template match="node()|@*"> |
17 |
<!-- Copy the current node --> |
18 |
<xsl:copy> |
19 |
<!-- Including any attributes it has and any child nodes --> |
20 |
<xsl:apply-templates select="@*|node()"/> |
21 |
</xsl:copy> |
22 |
</xsl:template> |
23 |
|
24 |
<!--<xsl:template match="//tei:facsimile"> |
25 |
<xsl:copy> |
26 |
<xsl:copy-of select="$valid-zones-file"></xsl:copy-of> |
27 |
</xsl:copy> |
28 |
</xsl:template> |
29 |
--> |
30 |
<xsl:template match="//tei:zone[@type='word']"> |
31 |
|
32 |
<xsl:variable name="myId"><xsl:value-of select="substring-after(@xml:id,'zone-')"/></xsl:variable> |
33 |
|
34 |
<xsl:variable name="myIdWp"> |
35 |
<xsl:if test="matches($myId,'wp')"> |
36 |
<xsl:value-of select="replace($myId,'wp_qgraal_cmTest_(.+)_[12]$','$1')"/> |
37 |
</xsl:if> |
38 |
</xsl:variable> |
39 |
|
40 |
<xsl:copy> |
41 |
<xsl:apply-templates select="@*"/> |
42 |
<xsl:choose> |
43 |
<xsl:when test="$valid-zones-element//tei:zone[@type='word'][substring-after(@corresp,'#')=$myId]"> |
44 |
<xsl:variable name="matching-zone" as="element()"> |
45 |
<xsl:copy-of select="$valid-zones-element//tei:zone[@type='word'][substring-after(@corresp,'#')=$myId]"/> |
46 |
</xsl:variable> |
47 |
<xsl:attribute name="ulx"><xsl:value-of select="$matching-zone/@ulx"/></xsl:attribute> |
48 |
<xsl:attribute name="uly"><xsl:value-of select="$matching-zone/@uly"/></xsl:attribute> |
49 |
<xsl:attribute name="lrx"><xsl:value-of select="$matching-zone/@lrx"/></xsl:attribute> |
50 |
<xsl:attribute name="lry"><xsl:value-of select="$matching-zone/@lry"/></xsl:attribute> |
51 |
</xsl:when> |
52 |
<xsl:when test="$valid-zones-element//tei:zone[@type='word'][substring-after(@corresp,'#')=$myIdWp and matches($myId,'_1$')]"> |
53 |
<xsl:variable name="matching-zone" as="element()"> |
54 |
<dummy><xsl:copy-of select="$valid-zones-element//tei:zone[@type='word'][substring-after(@corresp,'#')=$myIdWp]"/></dummy> |
55 |
</xsl:variable> |
56 |
<xsl:attribute name="ulx"><xsl:value-of select="$matching-zone/tei:zone[1]/@ulx"/></xsl:attribute> |
57 |
<xsl:attribute name="uly"><xsl:value-of select="$matching-zone/tei:zone[1]/@uly"/></xsl:attribute> |
58 |
<xsl:attribute name="lrx"><xsl:value-of select="$matching-zone/tei:zone[1]/@lrx"/></xsl:attribute> |
59 |
<xsl:attribute name="lry"><xsl:value-of select="$matching-zone/tei:zone[1]/@lry"/></xsl:attribute> |
60 |
</xsl:when> |
61 |
<xsl:when test="$valid-zones-element//tei:zone[@type='word'][substring-after(@corresp,'#')=$myIdWp and matches($myId,'_2$')]"> |
62 |
<xsl:variable name="matching-zone" as="element()"> |
63 |
<dummy><xsl:copy-of select="$valid-zones-element//tei:zone[@type='word'][substring-after(@corresp,'#')=$myIdWp]"/></dummy> |
64 |
</xsl:variable> |
65 |
<xsl:attribute name="ulx"><xsl:value-of select="$matching-zone/tei:zone[2]/@ulx"/></xsl:attribute> |
66 |
<xsl:attribute name="uly"><xsl:value-of select="$matching-zone/tei:zone[2]/@uly"/></xsl:attribute> |
67 |
<xsl:attribute name="lrx"><xsl:value-of select="$matching-zone/tei:zone[2]/@lrx"/></xsl:attribute> |
68 |
<xsl:attribute name="lry"><xsl:value-of select="$matching-zone/tei:zone[2]/@lry"/></xsl:attribute> |
69 |
</xsl:when> |
70 |
<xsl:otherwise><xsl:comment>No matching validated zone found!</xsl:comment></xsl:otherwise> |
71 |
</xsl:choose> |
72 |
<xsl:apply-templates/> |
73 |
</xsl:copy> |
74 |
|
75 |
|
76 |
</xsl:template> |
77 |
</xsl:stylesheet> |