File: tld1_2-tld2_0.xsl

package info (click to toggle)
libnb-platform18-java 12.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 729,800 kB
  • sloc: java: 5,059,097; xml: 574,432; php: 78,788; javascript: 29,039; ansic: 10,278; sh: 6,386; cpp: 4,612; jsp: 3,643; sql: 1,097; makefile: 540; objc: 288; perl: 277; haskell: 93
file content (290 lines) | stat: -rw-r--r-- 10,510 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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<?xml version="1.0" encoding="UTF-8" ?>

<!--
  - <license>
  - Copyright (c) 2010, Oracle.
  - All rights reserved.
  -
  - Redistribution and use in source and binary forms, with or without
  - modification, are permitted provided that the following conditions are met:
  -
  -     * Redistributions of source code must retain the above copyright
  -       notice, this list of conditions and the following disclaimer.
  -     * 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.
  -     * Neither the name of Oracle nor the names of its
  -       contributors may be used to endorse or promote products derived from
  -       this software without specific prior written permission.
  -
  - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER OR
  - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
  - ROCUREMENT 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.
  - </license>
  -->

<!--

  Translates a JSP 1.2 TLD into a JSP 2.0 TLD, using the following 
  conversion rules:

  1. Change the <taglib> element to read as follows:
     <taglib xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
         http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd">
  2. Remove all id attributes from all elements.
  3. Remove <jsp-version> element and add an attribute to <taglib>
     called 'version' with the value "2.0".
  4. Under <taglib>, if a <description> element exists, move it to
     the top.
  5. Under <taglib>, if a <display-name> element exists, move it
     to the top, after the <description> element.
  6. Under <taglib>, if a <small-icon> and/or <large-icon> element
     exists, wrap them in an <icon> element and move it to the
     top, after the <display-name> element.
  7. For each taglib/validator element, if a <description> element
     exists, move it to the top, under <validator>.
  8. For each taglib/validator/init-param element, if a
     <description> element exists, move it to the top, under
     <init-param>.
  9. For each taglib/tag element, if a <description> element
     exists, move it to the top, under <tag>.
 10. For each taglib/tag element, if a <display-name> element
     exists, move it to the top, after the <description> element,
     under <tag>.
 11. For each taglib/tag element, if a <small-icon> and/or
     <large-icon> element exists, wrap them in an <icon> element
     and move it to the top, after the <display-name> element,
     under <tag>.
 12. For each taglib/tag element, if no <body-content> element 
     exists, supply a default value of "JSP"
 13. For each taglib/tag/variable element, if a <description>
     element exists, move it to the top, under <variable>.
 14. For each taglib/tag/attribute element, if a <description>
     element exists, move it to the top, under <attribute>.

  Author: Mark Roth

-->

<xsl:stylesheet version="1.0"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="/taglib">
    <xsl:element name="taglib" namespace="http://java.sun.com/xml/ns/j2ee">
      <xsl:attribute name="xsi:schemaLocation" namespace="http://www.w3.org/2001/XMLSchema-instance">http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd</xsl:attribute>
      <xsl:attribute name="version">2.0</xsl:attribute>
      <xsl:apply-templates select="description"/>
      <xsl:apply-templates select="display-name"/>
      <xsl:if test="small-icon|large-icon">
        <icon xmlns="http://java.sun.com/xml/ns/j2ee">
	  <xsl:apply-templates select="small-icon"/>
	  <xsl:apply-templates select="large-icon"/>
        </icon>
      </xsl:if>
      <xsl:apply-templates select="tlib-version"/>
      <xsl:apply-templates select="short-name"/>
      <xsl:apply-templates select="uri"/>
      <xsl:apply-templates select="validator"/>
      <xsl:apply-templates select="listener"/>
      <xsl:apply-templates select="tag"/>
    </xsl:element>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="description">
    <description xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </description>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="display-name">
    <display-name xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </display-name>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="tlib-version">
    <tlib-version xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </tlib-version>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="short-name">
    <short-name xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </short-name>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="uri">
    <uri xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </uri>
  </xsl:template>

  <xsl:template match="validator">
    <validator xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates select="description"/>
      <xsl:apply-templates select="validator-class"/>
      <xsl:apply-templates select="init-param"/>
    </validator>
  </xsl:template>

  <xsl:template match="init-param">
    <init-param xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates select="description"/>
      <xsl:apply-templates select="param-name"/>
      <xsl:apply-templates select="param-value"/>
    </init-param>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="param-name">
    <param-name xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </param-name>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="param-value">
    <param-value xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </param-value>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="listener">
    <listener xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates select="listener-class"/>
    </listener>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="listener-class">
    <listener-class xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </listener-class>
  </xsl:template>

  <xsl:template match="tag">
    <tag xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates select="description"/>
      <xsl:apply-templates select="display-name"/>
      <xsl:if test="small-icon|large-icon">
        <icon xmlns="http://java.sun.com/xml/ns/j2ee">
	  <xsl:apply-templates select="small-icon"/>
	  <xsl:apply-templates select="large-icon"/>
        </icon>
      </xsl:if>
      <xsl:apply-templates select="name"/>
      <xsl:apply-templates select="tag-class"/>
      <xsl:apply-templates select="tei-class"/>
      <xsl:choose>
	<xsl:when test="body-content">
          <xsl:apply-templates select="body-content"/>
	</xsl:when>
	<xsl:otherwise>
	  <!-- 
	    - Explicitly Insert the default body-content since this is 
	    - now a required element
	    -->
	  <body-content xmlns="http://java.sun.com/xml/ns/j2ee">JSP</body-content>
	</xsl:otherwise>
      </xsl:choose>
      <xsl:apply-templates select="variable"/>
      <xsl:apply-templates select="attribute"/>
      <xsl:apply-templates select="example"/>
    </tag>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="name">
    <name xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </name>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="tag-class">
    <tag-class xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </tag-class>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="tei-class">
    <tei-class xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </tei-class>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="body-content">
    <body-content xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </body-content>
  </xsl:template>

  <xsl:template match="variable">
    <variable xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates select="description"/>
      <xsl:apply-templates select="name-given"/>
      <xsl:apply-templates select="name-from-attribute"/>
      <xsl:apply-templates select="variable-class"/>
      <xsl:apply-templates select="declare"/>
      <xsl:apply-templates select="scope"/>
    </variable>
  </xsl:template>

  <xsl:template match="attribute">
    <attribute xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates select="description"/>
      <xsl:apply-templates select="name"/>
      <xsl:apply-templates select="required"/>
      <xsl:apply-templates select="rtexprvalue"/>
      <xsl:apply-templates select="type"/>
    </attribute>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="required">
    <required xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </required>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="rtexprvalue">
    <rtexprvalue xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </rtexprvalue>
  </xsl:template>

  <!-- Strip the id attribute: -->
  <xsl:template match="example">
    <example xmlns="http://java.sun.com/xml/ns/j2ee">
      <xsl:apply-templates/>
    </example>
  </xsl:template>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>