Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / nlm / nlm_3_to_nlm_2.3.xsl @ 187

History | View | Annotate | Download (5.7 kB)

1
<?xml version="1.0"?>
2
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="#all">
3

    
4
  <!--
5
        Written by Martin Holmes, University of Victoria Humanities Computing and 
6
    Media Centre, beginning in 2008.
7
    
8
    This file is released under the Mozilla Public Licence version 1.1 (MPL 1.1).
9
    
10
    This transformation is designed to convert NLM 3.0 documents to NLM 2.3;
11
    it works only with the subset of NLM 3.0 used by the conversion from teiJournal
12
    documents to NLM 3.0.
13
    
14
    NLM is:
15
    
16
    The National Center for Biotechnology Information (NCBI) of the National Library of
17
    Medicine (NLM) created the Journal Archiving and Interchange Tag Suite.
18
    
19
    Our source is actually the NLM Journal Publishing Tag Set, described here:
20
    
21
    http://dtd.nlm.nih.gov/publishing/tag-library/3.0/index.html
22
    
23
    and the target is the older 2.3 version, described here:
24
    
25
    http://dtd.nlm.nih.gov/publishing/tag-library/2.3/index.html
26
    
27
    The reason for creating NLM conversion is that Open Journal Systems has committed 
28
    to supporting NLM, so this provides a method of migrating data from teiJournal 
29
    to OJS; however, OJS will initially support only NLM 2.3.
30
    
31
    -->
32
  <xsl:output method="xml" doctype-public="-//NLM//DTD Journal Publishing DTD v2.3 20070202//EN" doctype-system="http://dtd.nlm.nih.gov/publishing/2.3/journalpublishing.dtd" xpath-default-namespace="" indent="yes"></xsl:output>
33

    
34
  <xsl:template match="/">
35

    
36
       
37
       <xsl:apply-templates></xsl:apply-templates>
38
       
39

    
40
  </xsl:template>
41
  
42
  <!--    Root element needs its article-type attribute massaging a bit. -->
43
    <!-- We have an ontology of TEI contribution types; this does not match 
44
     NLM at all. In NLM 3.0, the list of article-type values is suggested but 
45
     not fixed, so we can use those which are appropriate, and use our own 
46
     where there's no match. In 2.3, the list is fixed, so we'd have to convert 
47
     all our non-matching ones to "other". -->
48
     <xsl:template match="article">
49
       <article xmlns:xlink="http://www.w3.org/1999/xlink"
50
          xmlns:mml="http://www.w3.org/1998/Math/MathML"
51
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
52
       <xsl:choose>
53
<xsl:when test="@article-type='fiction'">
54
  <xsl:attribute name="article-type">other</xsl:attribute>
55
</xsl:when>
56
<xsl:when test="@article-type='poetry'">
57
  <xsl:attribute name="article-type">other</xsl:attribute>
58
</xsl:when>
59
          <xsl:otherwise><xsl:attribute name="article-type" select="@article-type" /></xsl:otherwise>
60
       </xsl:choose>
61
         <xsl:apply-templates/>
62
       </article>
63
     </xsl:template>
64
  
65
<!-- The 3.0 element-citation is just citation in 2.3. -->
66
  <xsl:template match="element-citation">
67
    <citation>
68
      <xsl:apply-templates />
69
    </citation>
70
  </xsl:template>
71
  
72
<!-- The 3.0 element <styled-content> doesn't exist. Each type of content 
73
will need to be handled separately. -->
74
  <xsl:template match="styled-content[@style-type='scare quotes']">
75
    &quot;<xsl:apply-templates/>&quot;
76
  </xsl:template>
77
    <xsl:template match="styled-content[@style-type='term' or @style-type='mentioned']">
78
    <italic><xsl:apply-templates/></italic>
79
    </xsl:template>
80
    <xsl:template match="styled-content[@style-type='XML tag']">
81
    <monospace>&lt;<xsl:apply-templates/>&gt;</monospace>
82
  </xsl:template>
83
  
84
<!-- The @orientation attribute is required in 3.0 and not allowed in 2.3. -->
85
  <xsl:template match="@orientation"></xsl:template>
86
  
87
<!-- @specific-use is not allowed on table-wrap. -->
88
  <xsl:template match="table-wrap">
89
    <xsl:element name="table-wrap">
90
      <xsl:if test="@specific-use">
91
        <xsl:attribute name="content-type" select="@specific-use" />
92
      </xsl:if>
93
      <xsl:apply-templates />
94
    </xsl:element>
95
  </xsl:template>
96
  
97
<!-- @specific-use is also not allowed on disp-quote. -->
98
  <xsl:template match="disp-quote">
99
    <xsl:element name="disp-quote">
100
      <xsl:if test="@specific-use">
101
        <xsl:attribute name="content-type" select="@specific-use" />
102
      </xsl:if>
103
      <xsl:apply-templates />
104
    </xsl:element>
105
  </xsl:template>
106
  
107
  
108
<!-- The person-group/@person-group-type attribute in 2.3 is limited to a 
109
fixed list of items.  Some of our types will not do. -->
110
  <xsl:template match="person-group">
111
    <person-group>
112
      <xsl:if test="@person-group-type">
113
        <xsl:if test="@person-group-type='allauthors' or 
114
                      @person-group-type='assignee' or 
115
                      @person-group-type='author' or 
116
                      @person-group-type='compiler' or 
117
                      @person-group-type='director' or 
118
                      @person-group-type='editor' or 
119
                      @person-group-type='guest-editor' or 
120
                      @person-group-type='inventor' or 
121
                      @person-group-type='transed' or 
122
                      @person-group-type='translator'">
123
            <xsl:copy-of select="@person-group-type"></xsl:copy-of>
124
          </xsl:if>
125
      </xsl:if>
126
      <xsl:apply-templates />
127
    </person-group>
128
  </xsl:template>
129
  
130
<!-- named-content elements cannot occur inside ext-link. -->
131
  <xsl:template match="named-content[ancestor::ext-link]">
132
    <xsl:value-of select="." />
133
  </xsl:template>
134
  
135
<!--  Lastly, a generic copy-all template with low priority, so that stuff not 
136
      handled above is copied to the output. -->
137
      <xsl:template match="@*|node()|text()|comment()|processing-instruction()" priority="-1">
138
        <xsl:copy>
139
            <xsl:apply-templates select="@*|node()|text()|comment()|processing-instruction()"/>
140
        </xsl:copy>
141
    </xsl:template>
142
  
143
</xsl:stylesheet>