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: cjones $'
10
  *     '$Date: 2006-11-17 13:37:07 -0800 (Fri, 17 Nov 2006) $'
11
  * '$Revision: 3094 $'
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
              doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
35
              doctype-system="http://www.w3.org/TR/html4/loose.dtd"
36
              indent="yes" />  
37

    
38
  <!-- This module is for constraint. And it is self contained-->
39
  <xsl:template name="constraint">
40
     <xsl:param name="constraintfirstColStyle"/>
41
     <table class="{$tabledefaultStyle}">
42
        <xsl:choose>
43
         <xsl:when test="references!=''">
44
          <xsl:variable name="ref_id" select="references"/>
45
          <xsl:variable name="references" select="$ids[@id=$ref_id]" />
46
          <xsl:for-each select="$references">
47
            <xsl:call-template name="constraintCommon">
48
             <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
49
            </xsl:call-template>
50
          </xsl:for-each>
51
        </xsl:when>
52
        <xsl:otherwise>
53
           <xsl:call-template name="constraintCommon">
54
             <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
55
            </xsl:call-template>
56
        </xsl:otherwise>
57
      </xsl:choose>
58
    </table>
59
  </xsl:template>
60

    
61
  <xsl:template name="constraintCommon">
62
    <xsl:param name="constraintfirstColStyle"/>
63
    <xsl:for-each select="primaryKey">
64
       <xsl:call-template name="primaryKey">
65
          <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
66
       </xsl:call-template>
67
    </xsl:for-each>
68
    <xsl:for-each select="uniqueKey">
69
       <xsl:call-template name="uniqueKey">
70
          <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
71
       </xsl:call-template>
72
    </xsl:for-each>
73
    <xsl:for-each select="checkConstraint">
74
       <xsl:call-template name="checkConstraint">
75
          <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
76
       </xsl:call-template>
77
    </xsl:for-each>
78
    <xsl:for-each select="foreignKey">
79
       <xsl:call-template name="foreignKey">
80
          <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
81
       </xsl:call-template>
82
    </xsl:for-each>
83
    <xsl:for-each select="joinCondition">
84
       <xsl:call-template name="joinCondition">
85
          <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
86
       </xsl:call-template>
87
    </xsl:for-each>
88
    <xsl:for-each select="notNullConstraint">
89
       <xsl:call-template name="notNullConstraint">
90
          <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
91
       </xsl:call-template>
92
    </xsl:for-each>
93
  </xsl:template>
94

    
95
  <!--Keys part-->
96
  <xsl:template name="primaryKey">
97
    <xsl:param name="constraintfirstColStyle"/>
98
    <tr><td class="{$constraintfirstColStyle}">
99
          Primary Key:</td>
100
          <td>
101
            <table class="{$tabledefaultStyle}">
102
                 <xsl:call-template name="constraintBaseGroup">
103
                    <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
104
                 </xsl:call-template>
105
                 <xsl:for-each select="key/attributeReference">
106
                      <tr><td class="{$constraintfirstColStyle}">
107
                            <xsl:text>Key:</xsl:text></td>
108
                          <td class="{$secondColStyle}">
109
                            <xsl:value-of select="."/></td>
110
                      </tr>
111
                 </xsl:for-each>
112
            </table>
113
          </td>
114
     </tr>
115

    
116
  </xsl:template>
117

    
118
  <xsl:template name="uniqueKey">
119
    <xsl:param name="constraintfirstColStyle"/>
120
    <tr><td class="{$constraintfirstColStyle}">
121
          Unique Key:</td>
122
          <td>
123
             <table class="{$tabledefaultStyle}">
124
                  <xsl:call-template name="constraintBaseGroup">
125
                     <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
126
                  </xsl:call-template>
127
                  <xsl:for-each select="key/attributeReference">
128
                     <tr><td class="{$constraintfirstColStyle}">
129
                             <xsl:text>Key:</xsl:text></td>
130
                          <td class="{$secondColStyle}">
131
                            <xsl:value-of select="."/></td>
132
                      </tr>
133
                  </xsl:for-each>
134
             </table>
135
          </td>
136
     </tr>
137
  </xsl:template>
138

    
139
   <xsl:template name="checkConstraint">
140
    <xsl:param name="constraintfirstColStyle"/>
141
    <tr><td class="{$constraintfirstColStyle}">
142
          Checking Constraint: </td>
143
          <td>
144
              <table class="{$tabledefaultStyle}">
145
                    <xsl:call-template name="constraintBaseGroup">
146
                       <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
147
                    </xsl:call-template>
148
                    <xsl:for-each select="checkCondition">
149
                         <tr><td class="{$constraintfirstColStyle}">
150
                                   <xsl:text>Check Condition:</xsl:text></td>
151
                             <td class="{$secondColStyle}">
152
                                   <xsl:value-of select="."/></td>
153
                         </tr>
154
                    </xsl:for-each>
155
              </table>
156
          </td>
157
     </tr>
158
   </xsl:template>
159

    
160
  <xsl:template name="foreignKey">
161
     <xsl:param name="constraintfirstColStyle"/>
162
    <tr><td class="{$constraintfirstColStyle}">
163
          Foreign Key:</td>
164
          <td>
165
              <table class="{$tabledefaultStyle}">
166
                  <xsl:call-template name="constraintBaseGroup">
167
                        <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
168
                   </xsl:call-template>
169
                   <xsl:for-each select="key/attributeReference">
170
                      <tr><td class="{$constraintfirstColStyle}">
171
                             <xsl:text>Key:</xsl:text></td>
172
                          <td class="{$secondColStyle}">
173
                             <xsl:value-of select="."/></td>
174
                      </tr>
175
                  </xsl:for-each>
176
                  <tr><td class="{$constraintfirstColStyle}">
177
                          <xsl:text>Entity Reference:</xsl:text></td>
178
                       <td class="{$secondColStyle}">
179
                           <xsl:value-of select="entityReference"/></td>
180
                   </tr>
181
                   <xsl:if test="relationshipType and normalize-space(relationshipType)!=''">
182
                        <tr><td class="{$constraintfirstColStyle}">
183
                                <xsl:text>Relationship:</xsl:text></td>
184
                             <td class="{$secondColStyle}">
185
                                 <xsl:value-of select="relationshipType"/></td>
186
                         </tr>
187
                    </xsl:if>
188
                    <xsl:if test="cardinality and normalize-space(cardinality)!=''">
189
                          <tr><td class="{$constraintfirstColStyle}">
190
                                 <xsl:text>Cardinality:</xsl:text></td>
191
                              <td>
192
                                  <table class="{$tabledefaultStyle}">
193
                                        <tr><td class="{$constraintfirstColStyle}">
194
                                                <xsl:text>Parent:</xsl:text></td>
195
                                             <td class="{$secondColStyle}">
196
                                                 <xsl:value-of select="cardinality/parentOccurences"/></td>
197
                                        </tr>
198
                                        <tr><td class="{$constraintfirstColStyle}">
199
                                                <xsl:text>Children</xsl:text></td>
200
                                            <td class="{$secondColStyle}">
201
                                                 <xsl:value-of select="cardinality/childOccurences"/></td>
202
                                         </tr>
203
                                   </table>
204
                               </td>
205
                          </tr>
206
                   </xsl:if>
207
             </table>
208
          </td>
209
     </tr>
210

    
211
  </xsl:template>
212

    
213
  <xsl:template name="joinCondition">
214
    <xsl:param name="constraintfirstColStyle"/>
215
    <tr><td class="{$constraintfirstColStyle}">
216
          Join Condition:</td>
217
          <td>
218
              <table class="{$tabledefaultStyle}">
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 class="{$constraintfirstColStyle}">
224
                             <xsl:text>Referenced Key:</xsl:text></td>
225
                          <td class="{$secondColStyle}">
226
                              <xsl:value-of select="."/></td>
227
                       </tr>
228
                   </xsl:for-each>
229
             </table>
230
          </td>
231
    </tr>
232
  </xsl:template>
233

    
234
  <xsl:template name="notNullConstraint">
235
    <xsl:param name="constraintfirstColStyle"/>
236
    <tr><td class="{$constraintfirstColStyle}">
237
          Not Null Constraint:</td>
238
          <td>
239
              <table class="{$tabledefaultStyle}">
240
                   <xsl:call-template name="constraintBaseGroup">
241
                       <xsl:with-param name="constraintfirstColStyle" select="$constraintfirstColStyle"/>
242
                   </xsl:call-template>
243
                   <xsl:for-each select="key/attributeReference">
244
                        <tr><td class="{$constraintfirstColStyle}">
245
                                 <xsl:text>Key:</xsl:text></td>
246
                            <td class="{$secondColStyle}">
247
                                 <xsl:value-of select="."/></td>
248
                        </tr>
249
                   </xsl:for-each>
250
              </table>
251
          </td>
252
     </tr>
253
   </xsl:template>
254

    
255
  <xsl:template name="constraintBaseGroup">
256
    <xsl:param name="constraintfirstColStyle"/>
257
     <tr><td class="{$constraintfirstColStyle}">
258
          <xsl:text>Name:</xsl:text></td>
259
          <td class="{$secondColStyle}">
260
         <xsl:value-of select="constraintName"/></td>
261
     </tr>
262
     <xsl:if test="constraintDescription and normalize-space(constraintDescription)!=''">
263
       <tr><td class="{$constraintfirstColStyle}">
264
          <xsl:text>Description:</xsl:text></td>
265
          <td class="{$secondColStyle}">
266
          <xsl:value-of select="constraintDescription"/></td>
267
      </tr>
268
     </xsl:if>
269
  </xsl:template>
270

    
271
</xsl:stylesheet>
(5-5/27)