Project

General

Profile

Bug #2147 ยป eml-party.xsl

Will Tyburczy, 03/15/2007 09:59 AM

 
1
<?xml version="1.0"?>
2
<!--
3
  *  '$RCSfile: eml-party.xsl,v $'
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: jones $'
10
  *     '$Date: 2005/12/15 23:52:56 $'
11
  * '$Revision: 1.3 $'
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-variable.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

    
34
  <xsl:output method="html" encoding="iso-8859-1"
35
              doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
36
              doctype-system="http://www.w3.org/TR/html4/loose.dtd"
37
              indent="yes" />  
38

    
39
  <!-- This module is for party member and it is self contained-->
40

    
41
  <xsl:template name="party">
42
      <xsl:param name="partyfirstColStyle"/>
43
      <table xsl:use-attribute-sets="cellspacing" class="{$tabledefaultStyle}" width="100%">
44
        <xsl:choose>
45
         <xsl:when test="references!=''">
46
          <xsl:variable name="ref_id" select="references"/>
47
          <xsl:variable name="references" select="$ids[@id=$ref_id]" />
48
          <xsl:for-each select="$references">
49
            <xsl:apply-templates mode="party">
50
             <xsl:with-param name="partyfirstColStyle" select="$partyfirstColStyle"/>
51
            </xsl:apply-templates>
52
          </xsl:for-each>
53
        </xsl:when>
54
        <xsl:otherwise>
55
          <xsl:apply-templates mode="party">
56
            <xsl:with-param name="partyfirstColStyle" select="$partyfirstColStyle"/>
57
          </xsl:apply-templates>
58
        </xsl:otherwise>
59
      </xsl:choose>
60
      </table>
61
  </xsl:template>
62

    
63
  <!-- *********************************************************************** -->
64

    
65

    
66
  <xsl:template match="individualName" mode="party">
67
      <xsl:param name="partyfirstColStyle"/>
68
      <xsl:if test="normalize-space(.)!=''">
69
        <tr><td width="{$firstColWidth}" class="{$partyfirstColStyle}" >
70
            Individual:</td><td width="{$secondColWidth}" class="{$secondColStyle}" >
71
           <b><xsl:value-of select="./salutation"/><xsl:text> </xsl:text>
72
           <xsl:value-of select="./givenName"/><xsl:text> </xsl:text>
73
           <xsl:value-of select="./surName"/></b>
74
        </td></tr>
75
      </xsl:if>
76
  </xsl:template>
77

    
78

    
79
  <xsl:template match="organizationName" mode="party">
80
      <xsl:param name="partyfirstColStyle"/>
81
      <xsl:if test="normalize-space(.)!=''">
82
        <tr><td width="{$firstColWidth}" class="{$partyfirstColStyle}" >
83
        Organization:</td><td width="{$secondColWidth}" class="{$secondColStyle}">
84
		<xsl:choose>
85
			<xsl:when test="boolean(../individualName) or boolean(../positionName)">
86
				<xsl:value-of select="."/>
87
			</xsl:when>
88
			<xsl:otherwise>
89
				<b><xsl:value-of select="."/></b>
90
			</xsl:otherwise>
91
		</xsl:choose>
92
        </td></tr>
93
      </xsl:if>
94
  </xsl:template>
95

    
96

    
97
  <xsl:template match="positionName" mode="party">
98
      <xsl:param name="partyfirstColStyle"/>
99
      <xsl:if test="normalize-space(.)!=''">
100
      <tr><td width="{$firstColWidth}" class="{$partyfirstColStyle}">
101
        Position:</td><td width="{$secondColWidth}" class="{$secondColStyle}">
102
		<xsl:choose>
103
			<xsl:when test="boolean(../individualName)">
104
				<xsl:value-of select="."/>
105
			</xsl:when>
106
			<xsl:otherwise>
107
				<b><xsl:value-of select="."/></b>
108
			</xsl:otherwise>
109
		</xsl:choose>
110
		</td></tr>
111
      </xsl:if>
112
  </xsl:template>
113

    
114

    
115
  <xsl:template match="address" mode="party">
116
    <xsl:param name="partyfirstColStyle"/>
117
    <xsl:if test="normalize-space(.)!=''">
118
      <xsl:call-template name="addressCommon">
119
         <xsl:with-param name="partyfirstColStyle" select="$partyfirstColStyle"/>
120
      </xsl:call-template>
121
    </xsl:if>
122
    </xsl:template>
123

    
124
   <!-- This template will be call by other place-->
125
   <xsl:template name="address">
126
      <xsl:param name="partyfirstColStyle"/>
127
      <table xsl:use-attribute-sets="cellspacing" class="{$tablepartyStyle}" width="100%">
128
        <xsl:choose>
129
         <xsl:when test="references!=''">
130
          <xsl:variable name="ref_id" select="references"/>
131
          <xsl:variable name="references" select="$ids[@id=$ref_id]" />
132
          <xsl:for-each select="$references">
133
            <xsl:call-template name="addressCommon">
134
             <xsl:with-param name="partyfirstColStyle" select="$partyfirstColStyle"/>
135
            </xsl:call-template>
136
          </xsl:for-each>
137
        </xsl:when>
138
        <xsl:otherwise>
139
          <xsl:call-template name="addressCommon">
140
             <xsl:with-param name="partyfirstColStyle" select="$partyfirstColStyle"/>
141
          </xsl:call-template>
142
        </xsl:otherwise>
143
      </xsl:choose>
144
      </table>
145
  </xsl:template>
146

    
147
   <xsl:template name="addressCommon">
148
    <xsl:param name="partyfirstColStyle"/>
149
    <xsl:if test="normalize-space(.)!=''">
150
    <tr><td width="{$firstColWidth}" valign="top" class="{$partyfirstColStyle}">
151
        Address:</td><td width="{$secondColWidth}" >
152
    <table xsl:use-attribute-sets="cellspacing" class="{$tablepartyStyle}" width="100%">
153
    <xsl:for-each select="deliveryPoint">
154
    <tr><td class="{$secondColStyle}"><xsl:value-of select="."/><xsl:text>, </xsl:text></td></tr>
155
    </xsl:for-each>
156
    <!-- only include comma if city exists... -->
157
    <tr><td class="{$secondColStyle}" >
158
    <xsl:if test="normalize-space(city)!=''">
159
        <xsl:value-of select="city"/><xsl:text>, </xsl:text>
160
    </xsl:if>
161
    <xsl:if test="normalize-space(administrativeArea)!='' or normalize-space(postalCode)!=''">
162
        <xsl:value-of select="administrativeArea"/><xsl:text> </xsl:text><xsl:value-of select="postalCode"/><xsl:text> </xsl:text>
163
    </xsl:if>
164
    <xsl:if test="normalize-space(country)!=''">
165
      <xsl:value-of select="country"/>
166
    </xsl:if></td></tr>
167
    </table></td></tr>
168
    </xsl:if>
169
   </xsl:template>
170

    
171
  <xsl:template match="phone" mode="party">
172
      <xsl:param name="partyfirstColStyle"/>
173
      <tr><td width="{$firstColWidth}" class="{$partyfirstColStyle}" >
174
             Phone:
175
          </td>
176
          <td width="{$secondColWidth}">
177
            <table xsl:use-attribute-sets="cellspacing" class="{$tablepartyStyle}" width="100%">
178
              <tr><td width="100%" class="{$secondColStyle}">
179
                     <xsl:value-of select="."/>
180
                     <xsl:if test="normalize-space(./@phonetype)!=''">
181
                       <xsl:text> (</xsl:text><xsl:value-of select="./@phonetype"/><xsl:text>)</xsl:text>
182
                     </xsl:if>
183
                   </td>
184
               </tr>
185
             </table>
186
          </td>
187
      </tr>
188
  </xsl:template>
189

    
190

    
191
  <xsl:template match="electronicMailAddress" mode="party">
192
      <xsl:param name="partyfirstColStyle"/>
193
      <xsl:if test="normalize-space(.)!=''">
194
       <tr><td width="{$firstColWidth}" class="{$partyfirstColStyle}" >
195
            Email Address:
196
          </td>
197
          <td width="{$secondColWidth}">
198
            <table xsl:use-attribute-sets="cellspacing" class="{$tablepartyStyle}" width="100%">
199
              <tr><td width="100%" class="{$secondColStyle}">
200
                 <xsl:if test="$withHTMLLinks='1'">
201
                   <a><xsl:attribute name="href">mailto:<xsl:value-of select="."/></xsl:attribute><xsl:value-of select="./entityName"/>
202
                    <xsl:value-of select="."/></a>
203
                  </xsl:if>
204
                  <xsl:if test="$withHTMLLinks='0'">
205
                    <xsl:value-of select="."/>
206
                  </xsl:if>
207
                </td>
208
              </tr>
209
            </table>
210
          </td>
211
        </tr>
212
      </xsl:if>
213
  </xsl:template>
214

    
215

    
216
  <xsl:template match="onlineUrl" mode="party">
217
      <xsl:param name="partyfirstColStyle"/>
218
      <xsl:if test="normalize-space(.)!=''">
219
      <tr><td width="{$firstColWidth}" class="{$partyfirstColStyle}" >
220
            Web Address:
221
          </td>
222
          <td width="{$secondColWidth}">
223
             <table xsl:use-attribute-sets="cellspacing" class="{$tablepartyStyle}" width="100%">
224
               <tr><td width="100%" class="{$secondColStyle}">
225
                 <xsl:if test="$withHTMLLinks='1'">
226
                   <a><xsl:attribute name="href"><xsl:if test="not(contains(.,':/'))">http://</xsl:if><xsl:value-of select="."/></xsl:attribute><xsl:value-of select="./entityName"/>
227
                   <xsl:value-of select="."/></a>
228
                 </xsl:if>
229
                 <xsl:if test="$withHTMLLinks='0'">
230
                   <xsl:value-of select="."/>
231
                 </xsl:if>
232
                 </td>
233
               </tr>
234
             </table>
235
           </td>
236
        </tr>
237
      </xsl:if>
238
  </xsl:template>
239

    
240

    
241
  <xsl:template match="userId" mode="party">
242
      <xsl:param name="partyfirstColStyle"/>
243
      <xsl:if test="normalize-space(.)!=''">
244
      <tr><td width="{$firstColWidth}" class="{$partyfirstColStyle}" >
245
        Id:</td><td width="{$secondColWidth}" class="{$secondColStyle}">
246
        <xsl:value-of select="."/></td></tr>
247
      </xsl:if>
248
  </xsl:template>
249
  <xsl:template match="text()" mode="party" />
250
</xsl:stylesheet>
    (1-1/1)