Project

General

Profile

1 553 tao
<?xml version="1.0"?>
2
<!--
3
  *  '$RCSfile$'
4
  *      Authors: Matthew Brooke
5
  *    Copyright: 2000 Regents of the University of California and the
6
  *               National Center for Ecological Analysis and Synthesis
7
  *  For Details: http://www.nceas.ucsb.edu/
8
  *
9
  *   '$Author$'
10
  *     '$Date$'
11
  * '$Revision$'
12
  *
13
  * This program is free software; you can redistribute it and/or modify
14
  * it under the terms of the GNU General Public License as published by
15
  * the Free Software Foundation; either version 2 of the License, or
16
  * (at your option) any later version.
17
  *
18
  * This program is distributed in the hope that it will be useful,
19
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
  * GNU General Public License for more details.
22
  *
23
  * You should have received a copy of the GNU General Public License
24
  * along with this program; if not, write to the Free Software
25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
  *
27
  * This is an XSLT (http://www.w3.org/TR/xslt) stylesheet designed to
28
  * convert an XML file that is valid with respect to the eml-dataset.dtd
29
  * module of the Ecological Metadata Language (EML) into an HTML format
30
  * suitable for rendering with modern web browsers.
31
-->
32
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
33
  <xsl:output method="html" encoding="iso-8859-1"/>
34 1660 tao
35
  <!-- This module is for constraint. And it is self contained-->
36
  <xsl:template name="constraint">
37
     <xsl:param name="constraintfirstColStyle"/>
38 1696 tao
     <table xsl:use-attribute-sets="cellspacing" class="tabledefault" width="100%">
39 1660 tao
        <xsl:choose>
40
         <xsl:when test="references!=''">
41
          <xsl:variable name="ref_id" select="references"/>
42
          <xsl:variable name="references" select="$ids[@id=$ref_id]" />
43
          <xsl:for-each select="$references">
44
            <xsl:call-template name="constraintCommon">
45
             <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
46
            </xsl:call-template>
47
          </xsl:for-each>
48
        </xsl:when>
49
        <xsl:otherwise>
50
           <xsl:call-template name="constraintCommon">
51
             <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
52
            </xsl:call-template>
53
        </xsl:otherwise>
54
      </xsl:choose>
55
    </table>
56 553 tao
  </xsl:template>
57 1660 tao
58
  <xsl:template name="constraintCommon">
59
    <xsl:param name="constraintfirstColStyle"/>
60
    <xsl:for-each select="primaryKey">
61
       <xsl:call-template name="primaryKey">
62
          <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
63
       </xsl:call-template>
64
    </xsl:for-each>
65
    <xsl:for-each select="uniqueKey">
66
       <xsl:call-template name="uniqueKey">
67
          <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
68
       </xsl:call-template>
69
    </xsl:for-each>
70
    <xsl:for-each select="checkConstraint">
71
       <xsl:call-template name="checkConstraint">
72
          <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
73
       </xsl:call-template>
74
    </xsl:for-each>
75
    <xsl:for-each select="foreignKey">
76
       <xsl:call-template name="foreignKey">
77
          <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
78
       </xsl:call-template>
79
    </xsl:for-each>
80
    <xsl:for-each select="joinCondition">
81
       <xsl:call-template name="joinCondition">
82
          <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
83
       </xsl:call-template>
84
    </xsl:for-each>
85
    <xsl:for-each select="notNullConstraint">
86
       <xsl:call-template name="notNullConstraint">
87
          <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
88
       </xsl:call-template>
89
    </xsl:for-each>
90
  </xsl:template>
91
92
  <!--Keys part-->
93
  <xsl:template name="primaryKey">
94
    <xsl:param name="constraintfirstColStyle"/>
95
    <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
96 1711 tao
          <xsl:text>Type:</xsl:text></td>
97 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
98
          Primary Key</td>
99
     </tr>
100
    <xsl:call-template name="constraintBaseGroup">
101
       <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
102
    </xsl:call-template>
103
    <xsl:for-each select="key/attributeReference">
104
       <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
105 1711 tao
          <xsl:text>Key:</xsl:text></td>
106 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
107
          <xsl:value-of select="."/></td>
108
     </tr>
109
    </xsl:for-each>
110
  </xsl:template>
111
112
  <xsl:template name="uniqueKey">
113
    <xsl:param name="constraintfirstColStyle"/>
114
    <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
115 1711 tao
          <xsl:text>Type:</xsl:text></td>
116 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
117
          Unique Key</td>
118
     </tr>
119
    <xsl:call-template name="constraintBaseGroup">
120
       <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
121
    </xsl:call-template>
122
    <xsl:for-each select="key/attributeReference">
123
       <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
124 1711 tao
          <xsl:text>Key:</xsl:text></td>
125 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
126
          <xsl:value-of select="."/></td>
127
     </tr>
128
    </xsl:for-each>
129
  </xsl:template>
130
131
   <xsl:template name="checkConstraint">
132
    <xsl:param name="constraintfirstColStyle"/>
133
    <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
134 1711 tao
          <xsl:text>Type:</xsl:text></td>
135 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
136
          Checking Constraint</td>
137
     </tr>
138
    <xsl:call-template name="constraintBaseGroup">
139
       <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
140
    </xsl:call-template>
141
    <xsl:for-each select="checkCondition">
142
       <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
143 1711 tao
          <xsl:text>Check Condition:</xsl:text></td>
144 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
145
          <xsl:value-of select="."/></td>
146
     </tr>
147
    </xsl:for-each>
148
  </xsl:template>
149
150
  <xsl:template name="foreignKey">
151
     <xsl:param name="constraintfirstColStyle"/>
152
    <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
153 1711 tao
          <xsl:text>Type:</xsl:text></td>
154 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
155
          Foreign Key</td>
156
     </tr>
157
    <xsl:call-template name="constraintBaseGroup">
158
       <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
159
    </xsl:call-template>
160
    <xsl:for-each select="key/attributeReference">
161
       <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
162 1711 tao
          <xsl:text>Key:</xsl:text></td>
163 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
164
          <xsl:value-of select="."/></td>
165
     </tr>
166
    </xsl:for-each>
167
    <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
168 1711 tao
          <xsl:text>Entity Reference:</xsl:text></td>
169 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
170
          <xsl:value-of select="entityReference"/></td>
171
    </tr>
172
    <xsl:if test="relationshipType and normalize-space(relationshipType)!=''">
173
      <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
174 1711 tao
          <xsl:text>Relationship:</xsl:text></td>
175 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
176
          <xsl:value-of select="relationshipType"/></td>
177
      </tr>
178
    </xsl:if>
179
    <xsl:if test="cardinality and normalize-space(cardinality)!=''">
180
      <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
181 1711 tao
          <xsl:text>Cardinality:</xsl:text></td>
182 1706 tao
          <td width="{$secondColWidth}">
183 1711 tao
          <table xsl:use-attribute-sets="cellspacing" class="tabledefault" width="100%">
184 1660 tao
              <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
185 1711 tao
                   <xsl:text>Parent:</xsl:text></td>
186 1660 tao
                   <td width="{$secondColWidth}" class="{$secondColStyle}">
187
                    <xsl:value-of select="cardinality/parentOccurences"/></td>
188 1711 tao
               </tr>
189
               <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
190 1660 tao
                   <xsl:text>Children</xsl:text></td>
191
                   <td width="{$secondColWidth}" class="{$secondColStyle}">
192
                    <xsl:value-of select="cardinality/childOccurences"/></td>
193
              </tr>
194
           </table>
195
          </td>
196
      </tr>
197
    </xsl:if>
198
  </xsl:template>
199
200
  <xsl:template name="joinCondition">
201
    <xsl:param name="constraintfirstColStyle"/>
202
    <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
203 1711 tao
          <xsl:text>Type:</xsl:text></td>
204 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
205
          Join Condition</td>
206
    </tr>
207
    <xsl:call-template name="foreignKey">
208
       <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
209
    </xsl:call-template>
210
    <xsl:for-each select="referencedKey/attributeReference">
211
       <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
212 1711 tao
          <xsl:text>Referenced Key:</xsl:text></td>
213 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
214
          <xsl:value-of select="."/></td>
215
     </tr>
216
    </xsl:for-each>
217
  </xsl:template>
218
219
  <xsl:template name="notNullConstraint">
220
    <xsl:param name="constraintfirstColStyle"/>
221
    <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
222 1711 tao
          <xsl:text>Type:</xsl:text></td>
223 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
224
          Not Null Constraint</td>
225
     </tr>
226
    <xsl:call-template name="constraintBaseGroup">
227
       <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
228
    </xsl:call-template>
229
    <xsl:for-each select="key/attributeReference">
230
       <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
231 1711 tao
          <xsl:text>Key:</xsl:text></td>
232 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
233
          <xsl:value-of select="."/></td>
234
     </tr>
235
    </xsl:for-each>
236
  </xsl:template>
237
238
  <xsl:template name="constraintBaseGroup">
239
    <xsl:param name="constraintfirstColStyle"/>
240
     <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
241 1711 tao
          <xsl:text>Constraint Name:</xsl:text></td>
242 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
243
         <xsl:value-of select="constraintName"/></td>
244
     </tr>
245
     <xsl:if test="constraintDescription and normalize-space(constraintDescription)!=''">
246
       <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
247 1711 tao
          <xsl:text>Description:</xsl:text></td>
248 1660 tao
          <td width="{$secondColWidth}" class="{$secondColStyle}">
249
          <xsl:value-of select="constraintDescription"/></td>
250
      </tr>
251
     </xsl:if>
252
  </xsl:template>
253
254 553 tao
</xsl:stylesheet>