-
Notifications
You must be signed in to change notification settings - Fork 0
/
xhtml2vcard-preflight.xsl
226 lines (199 loc) · 13.2 KB
/
xhtml2vcard-preflight.xsl
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl ="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:output
encoding="UTF-8"
indent="no"
media-type="text/x-vcard"
method="text"
/>
<!--
brian suda
http://suda.co.uk/
XHTML-2-vCard Preflight
Version 0.1
2005-08-01
Copyright 2005 Brian Suda
This work is licensed under the Creative Commons Attribution-ShareAlike License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-sa/1.0/
NOTES:
This will check against some of the more common problems in hCard
-->
<xsl:param name="Anchor" />
<!-- there is no root element in vCard -->
<xsl:template match="/">
<xsl:apply-templates select="//head[contains(concat(' ',normalize-space(@profile),' '),'foobar')]"/>
<!-- @@ The following line will be removed because the vcard template should only be called from within the profile template -->
<xsl:call-template name="vcard"/>
</xsl:template>
<!-- check for profile in head element -->
<xsl:template match="head[contains(concat(' ',normalize-space(@profile),' '),' http://foorbar ')]">
<!--
==================== CURRENTLY DISABLED ====================
This will call the vCard template,
Without the correct profile you cannot assume the class values are intended for the vCard microformat.
-->
<!-- <xsl:call-template name="vcard"/> -->
</xsl:template>
<!-- Each vCard is listed in succession -->
<xsl:template name="vcard">
<xsl:if test="not($Anchor) or @id = $Anchor">
<!-- Check for mandatory FN -->
<xsl:if test="count(.//*[contains(concat(' ',normalize-space(@class),' '),' fn ')]) = 0">
<xsl:text>No FN property was found<br/></xsl:text>
</xsl:if>
<!-- Check for Capitals in given-name -->
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Given-Name ')]">
<xsl:text><code>Given-Name</code> property should be represented as <code>given-name</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Given-name ')]">
<xsl:text><code>Given-name</code> property should be represented as <code>given-name</code><br/></xsl:text>
</xsl:if>
<!-- Check for Capitals in family-name -->
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Family-Name ')]">
<xsl:text><code>Family-Name</code> property should be represented as <code>family-name</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Family-name ')]">
<xsl:text><code>Family-name</code> property should be represented as <code>family-name</code><br/></xsl:text>
</xsl:if>
<!-- Check for Capitals in additional-names -->
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Additional-Names ')]">
<xsl:text><code>Additional-Names</code> property should be represented as <code>additional-names</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Additional-names ')]">
<xsl:text><code>Additional-names</code> property should be represented as <code>additional-names</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Additional-Name ')]">
<xsl:text><code>Additional-Name</code> property should be represented as <code>additional-names</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Additional-name ')]">
<xsl:text><code>Additional-name</code> property should be represented as <code>additional-names</code><br/></xsl:text>
</xsl:if>
<!-- Check for Capitals in honorific-prefixes -->
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Honorific-Prefixes ')]">
<xsl:text><code>Honorific-Prefixes</code> property should be represented as <code>honorific-prefixes</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Honorific-prefixes ')]">
<xsl:text><code>Honorific-prefixes</code> property should be represented as <code>honorific-prefixes</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Honorific-Prefix ')]">
<xsl:text><code>Honorific-Prefix</code> property should be represented as <code>honorific-prefixes</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Honorific-prefix ')]">
<xsl:text><code>Honorific-prefix</code> property should be represented as <code>honorific-prefixes</code><br/></xsl:text>
</xsl:if>
<!-- Check for Capitals in honorific-suffixes -->
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Honorific-Suffixes ')]">
<xsl:text><code>Honorific-Suffixes</code> property should be represented as <code>honorific-suffixes</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Honorific-suffixes ')]">
<xsl:text><code>Honorific-suffixes</code> property should be represented as <code>honorific-suffixes</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Honorific-Suffix ')]">
<xsl:text><code>Honorific-Suffix</code> property should be represented as <code>honorific-suffixes</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Honorific-suffix ')]">
<xsl:text><code>Honorific-suffix</code> property should be represented as <code>honorific-suffixes</code><br/></xsl:text>
</xsl:if>
<!-- Check for Capitals in post-office-box -->
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Post-Office-Box ')]">
<xsl:text><code>Post-Office-Box</code> property should be represented as <code>post-office-box</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Post-office-box ')]">
<xsl:text><code>Post-office-box</code> property should be represented as <code>post-office-box</code><br/></xsl:text>
</xsl:if>
<!-- Check for Capitals in extended-address -->
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Extended-Address ')]">
<xsl:text><code>Extended-Address</code> property should be represented as <code>extended-address</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Extended-address ')]">
<xsl:text><code>Extended-address</code> property should be represented as <code>extended-address</code><br/></xsl:text>
</xsl:if>
<!-- Check for Capitals in street-address -->
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Street-Address ')]">
<xsl:text><code>Street-Address</code> property should be represented as <code>street-address</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Street-address ')]">
<xsl:text><code>Street-address</code> property should be represented as <code>street-address</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Address ')]">
<xsl:text><code>Address</code> property should be represented as <code>street-address</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' address ')]">
<xsl:text><code>address</code> property should be represented as <code>street-address</code><br/></xsl:text>
</xsl:if>
<!-- Check for Capitals in locality -->
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Locality ')]">
<xsl:text><code>Locality</code> property should be represented as <code>locality</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' LOCALITY ')]">
<xsl:text><code>LOCALITY</code> property should be represented as <code>locality</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' City ')]">
<xsl:text><code>City</code> property should be represented as <code>locality</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' city ')]">
<xsl:text><code>city</code> property should be represented as <code>locality</code><br/></xsl:text>
</xsl:if>
<!-- Check for Capitals in region -->
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Region ')]">
<xsl:text><code>Region</code> property should be represented as <code>region</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' REGION ')]">
<xsl:text><code>REGION</code> property should be represented as <code>region</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' State ')]">
<xsl:text><code>State</code> property should be represented as <code>region</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' state ')]">
<xsl:text><code>state</code> property should be represented as <code>region</code><br/></xsl:text>
</xsl:if>
<!-- Check for Capitals in postal-code -->
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Postal-Code ')]">
<xsl:text><code>Postal-Code</code> property should be represented as <code>postal-code</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Postal-code ')]">
<xsl:text><code>Postal-code</code> property should be represented as <code>postal-code</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Zip-Code ')]">
<xsl:text><code>Zip-Code</code> property should be represented as <code>postal-code</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Zip-code ')]">
<xsl:text><code>Zip-code</code> property should be represented as <code>postal-code</code><br/></xsl:text>
</xsl:if>
<!-- correct problems with Country-Name -->
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' country ')]">
<xsl:text><code>country</code> property should be represented as <code>country-name</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Country ')]">
<xsl:text><code>Country</code> property should be represented as <code>country-name</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Country-name ')]">
<xsl:text><code>Country-name</code> property should be represented as <code>country-name</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Country-Name ')]">
<xsl:text><code>Country-Name</code> property should be represented as <code>country-name</code><br/></xsl:text>
</xsl:if>
<!-- Check for Capitals in organization-name -->
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Organization-Name ')]">
<xsl:text><code>Organization-Name</code> property should be represented as <code>organization-name</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Organization-name ')]">
<xsl:text><code>Organization-name</code> property should be represented as <code>organization-name</code><br/></xsl:text>
</xsl:if>
<!-- Check for Capitals in organization-unit -->
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Organization-Unit ')]">
<xsl:text><code>Organization-Unit</code> property should be represented as <code>organization-unit</code><br/></xsl:text>
</xsl:if>
<xsl:if test=".//*[contains(concat(' ',normalize-space(@class),' '),' Organization-unit ')]">
<xsl:text><code>Organization-unit</code> property should be represented as <code>organization-unit</code><br/></xsl:text>
</xsl:if>
</xsl:if>
</xsl:template>
<!-- don't pass text thru -->
<xsl:template match="text()"></xsl:template>
</xsl:stylesheet>