Project

General

Profile

metacat / lib / style / eml2 / eml-constraint-2.0.0.xsl @ 1689

1
<?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: tao $'
10
  *     '$Date: 2003-06-11 20:05:21 -0700 (Wed, 11 Jun 2003) $'
11
  * '$Revision: 1660 $'
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
  
35
  <!-- This module is for constraint. And it is self contained-->
36
  <xsl:template name="constraint">
37
     <xsl:param name="constraintfirstColStyle"/>
38
     <table class="tabledefault" width="100%">
39
        <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
  </xsl:template>
57
  
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
          <xsl:text>Type</xsl:text></td>
97
          <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
          <xsl:text>Key</xsl:text></td>
106
          <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
          <xsl:text>Type</xsl:text></td>
116
          <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
          <xsl:text>Key</xsl:text></td>
125
          <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
          <xsl:text>Type</xsl:text></td>
135
          <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
          <xsl:text>Check Condition</xsl:text></td>
144
          <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
          <xsl:text>Type</xsl:text></td>
154
          <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
          <xsl:text>Key</xsl:text></td>
163
          <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
          <xsl:text>Entity Reference</xsl:text></td>
169
          <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
          <xsl:text>Relation Ship</xsl:text></td>
175
          <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
          <xsl:text>Cardinality</xsl:text></td>
182
          <td width="{$secondColWidth}" class="{$secondColStyle}">
183
          &#160;</td>
184
      </tr>
185
      <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
186
          &#160;</td>
187
          <td width="{$secondColWidth}" class="{$secondColStyle}">
188
           <table width="100%">
189
              <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
190
                   <xsl:text>Parent</xsl:text></td>
191
                   <td width="{$secondColWidth}" class="{$secondColStyle}">
192
                    <xsl:value-of select="cardinality/parentOccurences"/></td>
193
              </tr>
194
           </table>
195
          </td>
196
      </tr>
197
      <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
198
          &#160;</td>
199
          <td width="{$secondColWidth}" class="{$secondColStyle}">
200
           <table width="100%">
201
              <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
202
                   <xsl:text>Children</xsl:text></td>
203
                   <td width="{$secondColWidth}" class="{$secondColStyle}">
204
                    <xsl:value-of select="cardinality/childOccurences"/></td>
205
              </tr>
206
           </table>
207
          </td>
208
      </tr>
209
    </xsl:if>
210
  </xsl:template>
211
  
212
  <xsl:template name="joinCondition">
213
    <xsl:param name="constraintfirstColStyle"/>
214
    <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
215
          <xsl:text>Type</xsl:text></td>
216
          <td width="{$secondColWidth}" class="{$secondColStyle}">
217
          Join Condition</td>
218
    </tr>
219
    <xsl:call-template name="foreignKey">
220
       <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
221
    </xsl:call-template> 
222
    <xsl:for-each select="referencedKey/attributeReference">
223
       <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
224
          <xsl:text>Referenced Key</xsl:text></td>
225
          <td width="{$secondColWidth}" class="{$secondColStyle}">
226
          <xsl:value-of select="."/></td>
227
     </tr>
228
    </xsl:for-each>
229
  </xsl:template>
230
  
231
  <xsl:template name="notNullConstraint">
232
    <xsl:param name="constraintfirstColStyle"/>
233
    <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
234
          <xsl:text>Type</xsl:text></td>
235
          <td width="{$secondColWidth}" class="{$secondColStyle}">
236
          Not Null Constraint</td>
237
     </tr>
238
    <xsl:call-template name="constraintBaseGroup">
239
       <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
240
    </xsl:call-template> 
241
    <xsl:for-each select="key/attributeReference">
242
       <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
243
          <xsl:text>Key</xsl:text></td>
244
          <td width="{$secondColWidth}" class="{$secondColStyle}">
245
          <xsl:value-of select="."/></td>
246
     </tr>
247
    </xsl:for-each>
248
  </xsl:template>
249
  
250
  <xsl:template name="constraintBaseGroup">
251
    <xsl:param name="constraintfirstColStyle"/>
252
     <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
253
          <xsl:text>Constraint Name</xsl:text></td>
254
          <td width="{$secondColWidth}" class="{$secondColStyle}">
255
         <xsl:value-of select="constraintName"/></td>
256
     </tr>
257
     <xsl:if test="constraintDescription and normalize-space(constraintDescription)!=''">
258
       <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
259
          <xsl:text>Description</xsl:text></td>
260
          <td width="{$secondColWidth}" class="{$secondColStyle}">
261
          <xsl:value-of select="constraintDescription"/></td>
262
      </tr>
263
     </xsl:if>
264
  </xsl:template>
265
  
266

    
267
  <xsl:template match="constraint">
268
      <xsl:if test="normalize-space(constraintType)!=''">
269
            <tr><td width="{$firstColWidth}" class="{$firstColStyle}">
270
        <xsl:text>Type</xsl:text></td><td width="{$secondColWidth}" class="{$secondColStyle}">
271
        <xsl:value-of select="constraintType"/></td></tr>
272
      </xsl:if>
273
      <xsl:if test="normalize-space(constraintName)!=''">
274
        <tr><td width="{$firstColWidth}" class="{$firstColStyle}">
275
        <xsl:text>Name</xsl:text></td><td width="{$secondColWidth}" class="{$secondColStyle}">
276
        <xsl:value-of select="constraintName"/></td></tr>
277
      </xsl:if>
278
      <xsl:if test="normalize-space(constraintDescription)!=''">
279
        <tr><td width="{$firstColWidth}" class="{$firstColStyle}">
280
        <xsl:text>Description</xsl:text></td><td width="{$secondColWidth}" class="{$secondColStyle}">
281
        <xsl:value-of select="constraintDescription"/></td></tr>
282
      </xsl:if>
283
      <xsl:if test="normalize-space(entityId)!=''">
284
        <tr><td width="{$firstColWidth}" class="{$firstColStyle}">
285
        <xsl:text>Entity Id</xsl:text></td><td width="{$secondColWidth}" class="{$secondColStyle}">
286
        <xsl:value-of select="entityId"/></td></tr>
287
      </xsl:if>
288
      <xsl:if test="normalize-space(referencedEntityId)!=''">
289
        <tr><td width="{$firstColWidth}" class="{$firstColStyle}">
290
        <xsl:text>Referenced Entity Id</xsl:text></td><td width="{$secondColWidth}" class="{$secondColStyle}">
291
        <xsl:value-of select="referencedEntityId"/></td></tr>
292
      </xsl:if>
293
      <xsl:if test="normalize-space(referencedKey)!=''">
294
          <xsl:for-each select="referencedKey/attributeName">
295
            <tr><td width="{$firstColWidth}" class="{$firstColStyle}">
296
            <xsl:text>Referenced Key</xsl:text></td><td width="{$secondColWidth}" class="{$secondColStyle}">
297
            <xsl:apply-templates select="."/></td></tr>
298
          </xsl:for-each>
299
      </xsl:if>
300
      <xsl:if test="normalize-space(key)!=''">
301
          <xsl:for-each select="key/attributeName">
302
            <tr><td width="{$firstColWidth}" class="{$firstColStyle}">
303
            <xsl:text>Key</xsl:text></td><td width="{$secondColWidth}" class="{$secondColStyle}">
304
            <xsl:apply-templates select="."/></td></tr>
305
          </xsl:for-each>
306
      </xsl:if>
307
      <xsl:if test="normalize-space(cardinality)!=''">
308
        <tr><td width="{$firstColWidth}" class="{$firstColStyle}">
309
        <xsl:text>Cardinality</xsl:text></td><td width="{$secondColWidth}" class="{$secondColStyle}">
310
        <xsl:value-of select="cardinality"/></td></tr>
311
      </xsl:if>
312
      <xsl:if test="normalize-space(checkCondition)!=''">
313
        <tr><td width="{$firstColWidth}" class="{$firstColStyle}">
314
        <xsl:text>Check Condition</xsl:text></td><td width="{$secondColWidth}" class="{$secondColStyle}">
315
        <xsl:value-of select="checkCondition"/></td></tr>
316
      </xsl:if>
317
   </xsl:template>
318

    
319
   <xsl:template match="attributeName">
320
        <xsl:value-of select="."/>
321
   </xsl:template>
322

    
323

    
324
</xsl:stylesheet>