Revision 2398 tmp/org.txm.oriflamms.rcp/groovy/org/txm/macro/oriflamms/prepare/oriflamms-tokenize-chars-2-identify.xsl

oriflamms-tokenize-chars-2-identify.xsl (revision 2398)
1 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">
2
<xsl:stylesheet
3
	xmlns:edate="http://exslt.org/dates-and-times"
4
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5
	xmlns:tei="http://www.tei-c.org/ns/1.0"
6
	exclude-result-prefixes="tei edate" version="2.0">
5 7

  
6
  <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no"/>
8
	<xsl:output method="xml" encoding="utf-8"
9
		omit-xml-declaration="no" />
7 10

  
8 11
	<xsl:template match="node()|@*">
9 12
		<!-- Copy the current node -->
10 13
		<xsl:copy>
11 14
			<!-- Including any attributes it has and any child nodes -->
12
			<xsl:apply-templates select="@*|node()"/>
15
			<xsl:apply-templates select="@*|node()" />
13 16
		</xsl:copy>
14 17
	</xsl:template>
15 18

  
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
-->
19
	<!-- <xsl:variable name="filename"> <xsl:analyze-string select="document-uri(.)" 
20
		regex="^(.*)/([^/]+)\.[^/]+$"> <xsl:matching-substring> <xsl:value-of select="regex-group(2)"/> 
21
		</xsl:matching-substring> </xsl:analyze-string> </xsl:variable> <xsl:variable 
22
		name="filedir"> <xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+)\.[^/]+$"> 
23
		<xsl:matching-substring> <xsl:value-of select="regex-group(1)"/> </xsl:matching-substring> 
24
		</xsl:analyze-string> </xsl:variable> <xsl:variable name="filenameresult"> 
25
		<xsl:value-of select="replace($filename,'(-ori)?-w$','')"/> </xsl:variable> 
26
		<xsl:variable name="path"> <xsl:value-of select="concat($filedir,'/',$filenameresult,'-c-temp/?select=*.xml;recurse=yes;on-error=warning')"/> 
27
		</xsl:variable> <xsl:variable name="files" select="collection($path)"/> <xsl:template 
28
		match="/"> <root>Processing files from <xsl:value-of select="$filedir/$filenameresult"/>-c-temp 
29
		directory. Result files saved in <xsl:value-of select="$filedir/$filenameresult"/>-c 
30
		directory.</root> <xsl:for-each select="$files"> <xsl:variable name="filename2"> 
31
		<xsl:analyze-string select="document-uri(.)" regex="^(.*)/([^/]+).xml$"> 
32
		<xsl:matching-substring> <xsl:value-of select="regex-group(2)"></xsl:value-of> 
33
		</xsl:matching-substring> </xsl:analyze-string></xsl:variable> <xsl:result-document 
34
		href="{$filedir}/{$filenameresult}-c/{$filename2}-c.xml"> <xsl:apply-templates/> 
35
		</xsl:result-document> </xsl:for-each> </xsl:template> -->
57 36

  
58 37

  
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>
38
	<xsl:template match="tei:c">
39
		<xsl:variable name="w-id">
40
			<xsl:choose>
41
				<xsl:when test="ancestor::tei:pc">
42
					<xsl:value-of select="ancestor::tei:pc[1]/@xml:id" />
43
				</xsl:when>
44
				<xsl:when test="ancestor::tei:w">
45
					<xsl:value-of select="ancestor::tei:w[1]/@xml:id" />
46
				</xsl:when>
47
				<xsl:when test="ancestor::tei:seg[@type='deleted']">
48
					<xsl:value-of
49
						select="ancestor::tei:seg[@type='deleted'][1]/@xml:id" />
50
				</xsl:when>
51
			</xsl:choose>
52
		</xsl:variable>
53
		<xsl:variable name="position">
54
			<xsl:number from="tei:w|tei:pc|tei:seg[@type='deleted']"
55
				level="any" />
56
		</xsl:variable>
57
		<xsl:copy>
58
			<xsl:apply-templates select="@*" />
59
			<xsl:attribute name="xml:id"><xsl:value-of
60
				select="concat('c_',$w-id,'_',$position)" /></xsl:attribute>
61
			<xsl:apply-templates />
62
		</xsl:copy>
63
	</xsl:template>
74 64

  
75
	
76 65

  
66

  
77 67
</xsl:stylesheet>

Also available in: Unified diff