Project

General

Profile

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-07-17 17:48:51 -0700 (Thu, 17 Jul 2003) $'
11
  * '$Revision: 1735 $'
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 xsl:use-attribute-sets="cellspacing" 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
          Primary Key:</td>
97
          <td width="{$secondColWidth}">
98
            <table xsl:use-attribute-sets="cellspacing" class="tabledefault" width="100%">
99
                 <xsl:call-template name="constraintBaseGroup">
100
                    <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
101
                 </xsl:call-template> 
102
                 <xsl:for-each select="key/attributeReference">
103
                      <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
104
                            <xsl:text>Key:</xsl:text></td>
105
                          <td width="{$secondColWidth}" class="{$secondColStyle}">
106
                            <xsl:value-of select="."/></td>
107
                      </tr>
108
                 </xsl:for-each>
109
            </table>
110
          </td>
111
     </tr>
112
   
113
  </xsl:template>
114
  
115
  <xsl:template name="uniqueKey">
116
    <xsl:param name="constraintfirstColStyle"/>
117
    <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
118
          Unique Key:</td>
119
          <td width="{$secondColWidth}">
120
             <table xsl:use-attribute-sets="cellspacing" class="tabledefault" width="100%">
121
                  <xsl:call-template name="constraintBaseGroup">
122
                     <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
123
                  </xsl:call-template> 
124
                  <xsl:for-each select="key/attributeReference">
125
                     <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
126
                             <xsl:text>Key:</xsl:text></td>
127
                          <td width="{$secondColWidth}" class="{$secondColStyle}">
128
                            <xsl:value-of select="."/></td>
129
                      </tr>
130
                  </xsl:for-each>
131
             </table>
132
          </td>
133
     </tr>
134
  </xsl:template>
135
  
136
   <xsl:template name="checkConstraint">
137
    <xsl:param name="constraintfirstColStyle"/>
138
    <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
139
          Checking Constraint: </td>
140
          <td width="{$secondColWidth}">
141
              <table xsl:use-attribute-sets="cellspacing" class="tabledefault" width="100%">
142
                    <xsl:call-template name="constraintBaseGroup">
143
                       <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
144
                    </xsl:call-template> 
145
                    <xsl:for-each select="checkCondition">
146
                         <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
147
                                   <xsl:text>Check Condition:</xsl:text></td>
148
                             <td width="{$secondColWidth}" class="{$secondColStyle}">
149
                                   <xsl:value-of select="."/></td>
150
                         </tr>
151
                    </xsl:for-each>
152
              </table>
153
          </td>
154
     </tr>
155
   </xsl:template>
156
  
157
  <xsl:template name="foreignKey">
158
     <xsl:param name="constraintfirstColStyle"/>
159
    <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
160
          Foreign Key:</td>
161
          <td width="{$secondColWidth}">
162
              <table xsl:use-attribute-sets="cellspacing" class="tabledefault" width="100%">
163
                  <xsl:call-template name="constraintBaseGroup">
164
                        <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
165
                   </xsl:call-template> 
166
                   <xsl:for-each select="key/attributeReference">
167
                      <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
168
                             <xsl:text>Key:</xsl:text></td>
169
                          <td width="{$secondColWidth}" class="{$secondColStyle}">
170
                             <xsl:value-of select="."/></td>
171
                      </tr>
172
                  </xsl:for-each>
173
                  <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
174
                          <xsl:text>Entity Reference:</xsl:text></td>
175
                       <td width="{$secondColWidth}" class="{$secondColStyle}">
176
                           <xsl:value-of select="entityReference"/></td>
177
                   </tr>
178
                   <xsl:if test="relationshipType and normalize-space(relationshipType)!=''">
179
                        <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
180
                                <xsl:text>Relationship:</xsl:text></td>
181
                             <td width="{$secondColWidth}" class="{$secondColStyle}">
182
                                 <xsl:value-of select="relationshipType"/></td>
183
                         </tr>
184
                    </xsl:if>
185
                    <xsl:if test="cardinality and normalize-space(cardinality)!=''">
186
                          <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
187
                                 <xsl:text>Cardinality:</xsl:text></td>
188
                              <td width="{$secondColWidth}">
189
                                  <table xsl:use-attribute-sets="cellspacing" class="tabledefault" width="100%">
190
                                        <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
191
                                                <xsl:text>Parent:</xsl:text></td>
192
                                             <td width="{$secondColWidth}" class="{$secondColStyle}">
193
                                                 <xsl:value-of select="cardinality/parentOccurences"/></td>
194
                                        </tr>
195
                                        <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
196
                                                <xsl:text>Children</xsl:text></td>
197
                                            <td width="{$secondColWidth}" class="{$secondColStyle}">
198
                                                 <xsl:value-of select="cardinality/childOccurences"/></td>
199
                                         </tr>
200
                                   </table>
201
                               </td>
202
                          </tr>
203
                   </xsl:if>
204
             </table>
205
          </td>
206
     </tr>
207
    
208
  </xsl:template>
209
  
210
  <xsl:template name="joinCondition">
211
    <xsl:param name="constraintfirstColStyle"/>
212
    <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
213
          Join Condition:</td>
214
          <td width="{$secondColWidth}">
215
              <table xsl:use-attribute-sets="cellspacing" class="tabledefault" width="100%">
216
                   <xsl:call-template name="foreignKey">
217
                        <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
218
                   </xsl:call-template> 
219
                   <xsl:for-each select="referencedKey/attributeReference">
220
                      <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
221
                             <xsl:text>Referenced Key:</xsl:text></td>
222
                          <td width="{$secondColWidth}" class="{$secondColStyle}">
223
                              <xsl:value-of select="."/></td>
224
                       </tr>
225
                   </xsl:for-each>
226
             </table>
227
          </td>
228
    </tr>
229
  </xsl:template>
230
  
231
  <xsl:template name="notNullConstraint">
232
    <xsl:param name="constraintfirstColStyle"/>
233
    <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
234
          Not Null Constraint:</td>
235
          <td width="{$secondColWidth}">
236
              <table xsl:use-attribute-sets="cellspacing" class="tabledefault" width="100%">
237
                   <xsl:call-template name="constraintBaseGroup">
238
                       <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
239
                   </xsl:call-template> 
240
                   <xsl:for-each select="key/attributeReference">
241
                        <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
242
                                 <xsl:text>Key:</xsl:text></td>
243
                            <td width="{$secondColWidth}" class="{$secondColStyle}">
244
                                 <xsl:value-of select="."/></td>
245
                        </tr>
246
                   </xsl:for-each>
247
              </table>
248
          </td>
249
     </tr>
250
   </xsl:template>
251
  
252
  <xsl:template name="constraintBaseGroup">
253
    <xsl:param name="constraintfirstColStyle"/>
254
     <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
255
          <xsl:text>Name:</xsl:text></td>
256
          <td width="{$secondColWidth}" class="{$secondColStyle}">
257
         <xsl:value-of select="constraintName"/></td>
258
     </tr>
259
     <xsl:if test="constraintDescription and normalize-space(constraintDescription)!=''">
260
       <tr><td width="{$firstColWidth}" class="{$constraintfirstColStyle}">
261
          <xsl:text>Description:</xsl:text></td>
262
          <td width="{$secondColWidth}" class="{$secondColStyle}">
263
          <xsl:value-of select="constraintDescription"/></td>
264
      </tr>
265
     </xsl:if>
266
  </xsl:template>
267
  
268
</xsl:stylesheet>
(7-7/30)