Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / docx / misc / checkword.xsl @ 187

History | View | Annotate | Download (3.5 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
                xmlns="http://www.tei-c.org/ns/1.0"
4
                xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006"
5
                xmlns:o="urn:schemas-microsoft-com:office:office"
6
                xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
7
                xmlns:rel="http://schemas.openxmlformats.org/package/2006/relationships"
8
                xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
9
                xmlns:v="urn:schemas-microsoft-com:vml"
10
                xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
11
                xmlns:w10="urn:schemas-microsoft-com:office:word"
12
                xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
13
                xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
14
                xmlns:mml="http://www.w3.org/1998/Math/MathML"
15
                xmlns:tbx="http://www.lisa.org/TBX-Specification.33.0.html"
16
                version="2.0"
17
                exclude-result-prefixes="ve o r m v wp w10 w wne mml tbx">
18

    
19
  <xsl:key name="RIDS" match="*[@r:id]" use="1"/>
20
  <xsl:key name="RIDS" match="*[@r:embed]" use="1"/>
21
  <xsl:key name="STYLES" match="w:rStyle" use="1"/>
22
  <xsl:key name="STYLES" match="w:pStyle" use="1"/>
23
  <xsl:key name="STYLELIST" match="w:pStyle" use="@w:val"/>
24
  <xsl:key name="STYLELIST" match="w:rStyle" use="@w:val"/>
25
  <xsl:key name="R" match="rel:Relationship" use="@Id"/>
26
  <xsl:key name="S" match="w:style" use="@w:styleId"/>
27
  <xsl:output indent="yes"/>
28
  <xsl:template match="/">
29
      <xsl:message>Check whether styles used match styles defined: </xsl:message>
30
      <xsl:for-each select="key('STYLES',1)">
31
         <xsl:if test="generate-id() =generate-id(key('STYLELIST',@w:val)[1])">
32
	           <xsl:variable name="v" select="@w:val"/>
33
	           <xsl:message>Examine style <xsl:value-of select="$v"/>
34
            </xsl:message>
35
	           <xsl:for-each select="document('styles.xml',/)">
36
	              <xsl:choose>
37
	                 <xsl:when test="count(key('S',$v))=0">
38
	                    <xsl:message>ERROR: no entry for <xsl:value-of select="$v"/>
39
                     </xsl:message>
40
	                 </xsl:when>
41
	                 <xsl:otherwise>
42
	                    <xsl:for-each select="key('S',$v)">
43
		                      <xsl:message> .... <xsl:value-of select="$v"/>: <xsl:value-of select="w:name/@w:val"/>
44
		                      </xsl:message>
45
	                    </xsl:for-each>
46
	                 </xsl:otherwise>
47
	              </xsl:choose>
48
	           </xsl:for-each>
49
         </xsl:if>
50
      </xsl:for-each>
51

    
52
      <xsl:message>Check whether rIds are listed in document rels: </xsl:message>
53
      <xsl:for-each select="key('RIDS',1)">
54
         <xsl:variable name="i">
55
	   <xsl:value-of select="@r:id|@r:embed"/>
56
	 </xsl:variable>
57
	 <xsl:for-each select="document('_rels/document.xml.rels',/)">
58
	   <xsl:choose>
59
	     <xsl:when test="count(key('R',$i))=0">
60
	       <xsl:message>ERROR: no entry for <xsl:value-of select="$i"/>
61
	       </xsl:message>
62
	     </xsl:when>
63
	     <xsl:otherwise>
64
	       <xsl:for-each select="key('R',$i)">
65
		 <xsl:message> .... <xsl:value-of select="$i"/>: <xsl:value-of select="@Target"/>
66
		 </xsl:message>
67
	       </xsl:for-each>
68
	     </xsl:otherwise>
69
	   </xsl:choose>
70
         </xsl:for-each>
71
      </xsl:for-each>
72
  </xsl:template>
73

    
74
</xsl:stylesheet>