root / tmp / org.txm.oriflamms.rcp / res / oriflamms-tokenize-chars-2-identify.xsl @ 476
History | View | Annotate | Download (2.8 kB)
1 |
<?xml version="1.0"?> |
---|---|
2 |
<xsl:stylesheet xmlns:edate="http://exslt.org/dates-and-times" |
3 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tei="http://www.tei-c.org/ns/1.0" |
4 |
exclude-result-prefixes="tei edate" version="2.0"> |
5 |
|
6 |
<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no"/> |
7 |
|
8 |
<xsl:template match="node()|@*"> |
9 |
<!-- Copy the current node --> |
10 |
<xsl:copy> |
11 |
<!-- Including any attributes it has and any child nodes --> |
12 |
<xsl:apply-templates select="@*|node()"/> |
13 |
</xsl:copy> |
14 |
</xsl:template> |
15 |
|
16 |
<!-- <xsl:variable name="filename"> |
17 |
<xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+)\.[^/]+$"> |
18 |
<xsl:matching-substring> |
19 |
<xsl:value-of select="regex-group(2)"/> |
20 |
</xsl:matching-substring> |
21 |
</xsl:analyze-string> |
22 |
</xsl:variable> |
23 |
|
24 |
<xsl:variable name="filedir"> |
25 |
<xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+)\.[^/]+$"> |
26 |
<xsl:matching-substring> |
27 |
<xsl:value-of select="regex-group(1)"/> |
28 |
</xsl:matching-substring> |
29 |
</xsl:analyze-string> |
30 |
</xsl:variable> |
31 |
|
32 |
<xsl:variable name="filenameresult"> |
33 |
<xsl:value-of select="replace($filename,'(-ori)?-w$','')"/> |
34 |
</xsl:variable> |
35 |
|
36 |
<xsl:variable name="path"> |
37 |
<xsl:value-of select="concat($filedir,'/',$filenameresult,'-c-temp/?select=*.xml;recurse=yes;on-error=warning')"/> |
38 |
</xsl:variable> |
39 |
|
40 |
<xsl:variable name="files" select="collection($path)"/> |
41 |
|
42 |
<xsl:template match="/"> |
43 |
<root>Processing files from <xsl:value-of select="$filedir/$filenameresult"/>-c-temp directory. Result files saved in <xsl:value-of select="$filedir/$filenameresult"/>-c directory.</root> |
44 |
<xsl:for-each select="$files"> |
45 |
<xsl:variable name="filename2"> |
46 |
<xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+).xml$"> |
47 |
<xsl:matching-substring> |
48 |
<xsl:value-of select="regex-group(2)"></xsl:value-of> |
49 |
</xsl:matching-substring> |
50 |
</xsl:analyze-string></xsl:variable> |
51 |
<xsl:result-document href="{$filedir}/{$filenameresult}-c/{$filename2}-c.xml"> |
52 |
<xsl:apply-templates/> |
53 |
</xsl:result-document> |
54 |
</xsl:for-each> |
55 |
</xsl:template> |
56 |
--> |
57 |
|
58 |
|
59 |
<xsl:template match="tei:c"> |
60 |
<xsl:variable name="w-id"> |
61 |
<xsl:choose> |
62 |
<xsl:when test="ancestor::tei:pc"><xsl:value-of select="ancestor::tei:pc[1]/@xml:id"/></xsl:when> |
63 |
<xsl:when test="ancestor::tei:w"><xsl:value-of select="ancestor::tei:w[1]/@xml:id"/></xsl:when> |
64 |
<xsl:when test="ancestor::tei:seg[@type='deleted']"><xsl:value-of select="ancestor::tei:seg[@type='deleted'][1]/@xml:id"/></xsl:when> |
65 |
</xsl:choose> |
66 |
</xsl:variable> |
67 |
<xsl:variable name="position"><xsl:number from="tei:w|tei:pc|tei:seg[@type='deleted']" level="any"/></xsl:variable> |
68 |
<xsl:copy> |
69 |
<xsl:apply-templates select="@*"/> |
70 |
<xsl:attribute name="xml:id"><xsl:value-of select="concat('c_',$w-id,'_',$position)"/></xsl:attribute> |
71 |
<xsl:apply-templates/> |
72 |
</xsl:copy> |
73 |
</xsl:template> |
74 |
|
75 |
|
76 |
|
77 |
</xsl:stylesheet> |