File: address.xsl

package info (click to toggle)
xml-resume-library 1.5.1-9
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,516 kB
  • ctags: 424
  • sloc: xml: 867; makefile: 126; sh: 47
file content (133 lines) | stat: -rw-r--r-- 4,874 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?xml version="1.0" encoding="UTF-8"?>

<!--
address.xsl
Defines some common templates for address processing that are 
shared by all the stylesheets. 

Copyright (c) 2000-2001 Sean Kelly, Bruce Christensen
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the
   distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

$Id: address.xsl,v 1.1 2002/05/26 03:45:51 bruckie Exp $
-->

<xsl:stylesheet version="1.0"
  xmlns:r="http://xmlresume.sourceforge.net/resume/0.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <!-- It would be nice if XSLT allowed variable reference in mode --> 
  <!-- selection; then instead of the ugly template below, we'd have -->
  <!-- '<xsl:apply-templates select="r:address" mode="$address.format"/>'-->
  <!-- But it doesn't, so we need this. -->
  <xsl:template match="r:address">

    <!-- Determine formatting method from format attr of this element if -->
    <!-- it exists, otherwise use $address.format parameter. -->
    <xsl:variable name="format">
      <xsl:choose>
        <xsl:when test="@format">
          <xsl:value-of select="@format"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$address.format"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <xsl:choose>
      <!-- If the first child is a text node, assume that we -->
      <!-- have a preformatted address and bypass the address -->
      <!-- formatting below. -->
      <xsl:when test="node()[1][not(self::*)]">
        <xsl:apply-templates select="." mode="free-form"/>
      </xsl:when>
      <xsl:otherwise>

        <xsl:choose>
          <xsl:when test="$format = 'standard'">
            <xsl:apply-templates select="." mode="standard"/>
          </xsl:when>
          <xsl:when test="$format = 'european'">
            <xsl:apply-templates select="." mode="european"/>
          </xsl:when>
          <xsl:when test="$format = 'italian'">
            <xsl:apply-templates select="." mode="italian"/>
          </xsl:when>
        </xsl:choose>

      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


  <!-- template to determine the AdminDivision for use in addresses. -->
  <!-- AdminDivision is a pseudo-field for the principal administrative -->
  <!-- division of the country: state in the US, province in Canada, -->
  <!-- county in Ireland, for example. -->
  <xsl:template name="AdminDivision">

    <xsl:choose>
      <xsl:when test="r:state">
        <xsl:value-of select="normalize-space(r:state)"/>
      </xsl:when>
      <xsl:when test="r:province">
        <xsl:value-of select="normalize-space(r:province)"/>
      </xsl:when>
      <xsl:when test="r:county">
        <xsl:value-of select="normalize-space(r:county)"/>
      </xsl:when>
      <!-- Otherwise, leave blank -->
    </xsl:choose>
  </xsl:template>

  <!-- template to determine the CityDivision for use in addresses. -->
  <!-- "Suburb" is used in New Zealand; "Ward" in Brazil and Japan. -->
  <xsl:template name="CityDivision">
    <xsl:choose>
      <xsl:when test="r:suburb">
        <xsl:value-of select="normalize-space(r:suburb)"/>
      </xsl:when>
      <xsl:when test="r:ward">
        <xsl:value-of select="normalize-space(r:ward)"/>
      </xsl:when>
      <!-- Otherwise, leave blank -->
    </xsl:choose>
  </xsl:template>

  <!-- template to determine the code to be used in addresses. -->
  <xsl:template name="PostCode">
    <xsl:choose>
      <xsl:when test="r:zip">
        <xsl:value-of select="normalize-space(r:zip)"/>
      </xsl:when>
      <xsl:when test="r:postalCode">
        <xsl:value-of select="normalize-space(r:postalCode)"/>
      </xsl:when>
      <!-- Otherwise, leave blank -->
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>