-
Notifications
You must be signed in to change notification settings - Fork 7
/
xml2jekyll.xsl
309 lines (308 loc) · 16.7 KB
/
xml2jekyll.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
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<?xml version="1.0" encoding="UTF-8"?>
<!-- This XSLT transforms https://github.com/dret/HTML5-overview into a jekyll site. -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
<xsl:output name="markdown" method="text" encoding="UTF-8"/>
<xsl:output name="markup" method="xhtml" encoding="UTF-8" omit-xml-declaration="yes"/>
<xsl:variable name="post-dir" select="'_posts'"/>
<xsl:variable name="status-index" select="( 'PER' , 'REC' , 'SPSD' , 'PR' , 'CR' , 'WD' , 'NOTE' , 'other', 'abandoned' )"/>
<xsl:variable name="status-title" select="( 'Proposed Edited Recommendation' , 'Recommendation' , 'Superseded Recommendation' , 'Proposed Recommendation' , 'Candidate Recommendation' , 'Working Draft' , 'Note' , 'Other', 'Abandoned' )"/>
<!-- -->
<xsl:template match="/">
<xsl:result-document href="_includes/specs.html" format="markup">
<div class="specs">
<p>
<xsl:text>Currently this site tracks </xsl:text>
<xsl:value-of select="count(//specs/spec)"/>
<xsl:text> specifications, </xsl:text>
<xsl:value-of select="count(//specs/spec[@status = ('WD','CR','PER','PR','REC','other')])"/>
<xsl:text> of which are active, while the remaining </xsl:text>
<xsl:value-of select="count(//specs/spec[@status = ('SPSD', 'NOTE', 'abandoned')])"/>
<xsl:text> have been superseded or abandoned. </xsl:text>
<xsl:value-of select="count(//specs/spec[@status = ('WD','CR','PER','PR','REC','SPSD','NOTE')])"/>
<xsl:text> are W3C specifications, and the remaining </xsl:text>
<xsl:value-of select="count(//specs/spec[@status = ('other','abandoned')])"/>
<xsl:text> are published/developed elsewhere. Two separate lists are published here:</xsl:text>
<ul>
<li>
<a href="current">
<xsl:value-of select="count(//specs/spec[@status = ('WD','CR','PER','PR','REC','other')])"/>
<xsl:text> current specifications</xsl:text>
</a>
<xsl:text> (</xsl:text>
<xsl:value-of select="count(//specs/spec[@status = ('WD','CR','PER','PR','REC')])"/>
<xsl:text> W3C, </xsl:text>
<xsl:value-of select="count(//specs/spec[@status = ('other')])"/>
<xsl:text> other)</xsl:text>
</li>
<li>
<a href="abandoned">
<xsl:value-of select="count(//specs/spec[@status = ('SPSD','NOTE','abandoned')])"/>
<xsl:text> superseded or abandoned specifications</xsl:text>
</a>
<xsl:text> (</xsl:text>
<xsl:value-of select="count(//specs/spec[@status = ('SPSD','NOTE')])"/>
<xsl:text> W3C, </xsl:text>
<xsl:value-of select="count(//specs/spec[@status = ('abandoned')])"/>
<xsl:text> other)</xsl:text>
</li>
</ul>
</p>
</div>
</xsl:result-document>
<xsl:result-document href="current.md" format="markdown">
<xsl:text>---
</xsl:text>
<xsl:text>layout: page
</xsl:text>
<xsl:text>category: specs
</xsl:text>
<xsl:text>title: "Current HTML5 Specifications"
</xsl:text>
<xsl:text>short_title: "Current Specs"
</xsl:text>
<xsl:text>permalink: /current
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>---

</xsl:text>
<xsl:text>This is a list of all </xsl:text>
<xsl:value-of select="count(//specs/spec[@status = ('WD','CR','PER','PR','REC','other')])"/>
<xsl:text> current HTML5 specs, first [</xsl:text>
<xsl:value-of select="count(//specs/spec[@status = ('WD','CR','PER','PR','REC')])"/>
<xsl:text> W3C TR](#TR) (grouped by status), and then [</xsl:text>
<xsl:value-of select="count(//specs/spec[@status = ('other')])"/>
<xsl:text> others](#others):
## <a name="TR"/>W3C TR Specifications (</xsl:text>
<xsl:value-of select="count(//specs/spec[@status = ('WD','CR','PER','PR','REC')])"/>
<xsl:text> Specs)
</xsl:text>
<xsl:for-each-group select="//specs/spec" group-by="@status">
<xsl:sort select="index-of($status-index, current-grouping-key())"/>
<xsl:choose>
<xsl:when test="@status ne 'NOTE' and @status ne 'abandoned'">
<xsl:call-template name="generate-section"/>
</xsl:when>
<xsl:when test="@status eq 'NOTE'">
<xsl:result-document href="abandoned.md" format="markdown">
<xsl:text>---
</xsl:text>
<xsl:text>layout: page
</xsl:text>
<xsl:text>category: specs
</xsl:text>
<xsl:text>title: "Abandoned HTML5 Specifications"
</xsl:text>
<xsl:text>short_title: "Abandoned Specs"
</xsl:text>
<xsl:text>permalink: /abandoned
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>---

</xsl:text>
<xsl:text>This is a list of [W3C](http://www.w3.org/ "World Wide Web Consortium") HTML5 [NOTE documents](http://www.w3.org/2014/Process-20140801/#rec-advance "W3C Technical Reports"), which are documents that are no longer under development by the W3C, and other abandoned HTML5 specifications. Please keep in mind that [W3C NOTE documents have no official standing and often represent outdated or abandoned work](http://www.w3.org/2014/Process-20140801/#maturity-levels).

</xsl:text>
<xsl:call-template name="generate-section"/>
<xsl:for-each-group select="//specs/spec[@status eq 'abandoned']" group-by="@status">
<xsl:call-template name="generate-section"/>
</xsl:for-each-group>
</xsl:result-document>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
</xsl:result-document>
<xsl:for-each select="//spec[@status = ('WD','CR','PER','PR','REC','SPSD','NOTE')]">
<xsl:result-document href="spec/{@id}.html" format="markup">
<xsl:text>---
</xsl:text>
<xsl:text>layout: page
</xsl:text>
<xsl:text>category: spec
</xsl:text>
<xsl:text>title: "</xsl:text>
<xsl:value-of select="replace(title/text(), '"', '&#34;')"/>
<xsl:text>"
</xsl:text>
<xsl:text>---

</xsl:text>
<table cellpadding="5">
<tr>
<th valign="top" align="right"><em>Current Status:</em></th>
<td>
<xsl:value-of select="$status-title[index-of($status-index, current()/@status)]"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="@status"/>
<xsl:text>)</xsl:text>
</td>
</tr>
<tr>
<th valign="top" align="right"><em>Canonical URI:</em></th>
<td>
<code>
<a href="http://www.w3.org/TR/{@id}">
<xsl:text>http://www.w3.org/TR/</xsl:text>
<xsl:value-of select="@id"/>
</a>
</code>
</td>
</tr>
<tr>
<th valign="top" align="right"><em>Abstract:</em></th>
<td>
<xsl:value-of select="abstract/text()"/>
</td>
</tr>
</table>
<br/>
<hr/>
<br/>
<h3 id="history">
<q>
<xsl:value-of select="title/text()"/>
</q>
<xsl:text> Updates:</xsl:text>
</h3>
<ul>
<xsl:text>
{% for post in site.posts %}
</xsl:text>
<xsl:text>{% if post.tags contains "</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>" %}</xsl:text>
<li>
<a href="{{{{ post.url | prepend: site.baseurl }}}}">{{ post.date | date: "%b %-d, %Y" }}: {{ post.title }}</a>
</li>
<xsl:text>
{% endif %}
</xsl:text>
<xsl:text>{% endfor %}</xsl:text>
</ul>
</xsl:result-document>
</xsl:for-each>
<xsl:for-each select="//log/entry">
<xsl:variable name="date" select="format-date(@date, '[Y0001]-[M01]-[D01]')"/>
<xsl:result-document href="{$post-dir}/{$date}-update.md" format="markdown">
<xsl:text>---
</xsl:text>
<xsl:text>layout: post
</xsl:text>
<xsl:text>title: "</xsl:text>
<xsl:apply-templates select="node()" mode="md-title"/>
<xsl:text>"
</xsl:text>
<xsl:text>date: </xsl:text>
<xsl:value-of select="$date"/>
<xsl:text>
</xsl:text>
<xsl:text>tags: [ </xsl:text>
<xsl:for-each select=".//a[starts-with(@href, 'http://www.w3.org/TR/')]">
<xsl:value-of select="substring-before(substring-after(@href, 'http://www.w3.org/TR/'), '/')"/>
<xsl:if test="position() ne last()">
<xsl:text> , </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text> ]
</xsl:text>
<xsl:text>---

</xsl:text>
<xsl:apply-templates select="node()"/>
<xsl:text>

</xsl:text>
</xsl:result-document>
</xsl:for-each>
<xsl:for-each select="//log/rename">
<xsl:variable name="date" select="format-date(@date, '[Y0001]-[M01]-[D01]')"/>
<xsl:result-document href="{$post-dir}/{$date}-update.md" format="markdown">
<xsl:text>---
</xsl:text>
<xsl:text>layout: post
</xsl:text>
<xsl:text>title: "renamed \"</xsl:text>
<xsl:value-of select="old/@title"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="old/@id"/>
<xsl:text>)\" to \"</xsl:text>
<xsl:value-of select="new/@title"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="new/@id"/>
<xsl:text>)\""
</xsl:text>
<xsl:text>date: </xsl:text>
<xsl:value-of select="$date"/>
<xsl:text>
</xsl:text>
<xsl:text>tags: [ </xsl:text>
<xsl:value-of select="old/@id"/>
<xsl:text> , </xsl:text>
<xsl:value-of select="new/@id"/>
<xsl:text> ]
</xsl:text>
<xsl:text>---

</xsl:text>
<xsl:text>renamed "[</xsl:text>
<xsl:value-of select="old/@title"/>
<xsl:text> (`</xsl:text>
<xsl:value-of select="old/@id"/>
<xsl:text>`)](/spec/</xsl:text>
<xsl:value-of select="old/@id"/>
<xsl:text>)" to "[</xsl:text>
<xsl:value-of select="new/@title"/>
<xsl:text> (`</xsl:text>
<xsl:value-of select="new/@id"/>
<xsl:text>`)](/spec/</xsl:text>
<xsl:value-of select="new/@id"/>
<xsl:text>)"

</xsl:text>
</xsl:result-document>
<xsl:if test="new/@id ne old/@id">
<xsl:result-document href="spec/{old/@id}.html" format="markup">
<xsl:text>---
</xsl:text>
<xsl:text>layout: page
</xsl:text>
<xsl:text>category: spec
</xsl:text>
<xsl:text>title: "</xsl:text>
<xsl:value-of select="old/@title"/>
<xsl:text>"
</xsl:text>
<xsl:text>---

</xsl:text>
<p>Old name/id for <a href="{new/@id}"><xsl:value-of select="new/@title"/> (<code><xsl:value-of select="new/@id"/></code>)</a>.</p>
<br/>
<hr/>
<br/>
<h3 id="history">
<q>
<xsl:value-of select="old/@title"/>
</q>
<xsl:text> Updates:</xsl:text>
</h3>
<ul>
<xsl:text>
{% for post in site.posts %}
</xsl:text>
<xsl:text>{% if post.tags contains "</xsl:text>
<xsl:value-of select="old/@id"/>
<xsl:text>" %}</xsl:text>
<li>
<a href="{{{{ post.url | prepend: site.baseurl }}}}">{{ post.date | date: "%b %-d, %Y" }}: {{ post.title }}</a>
</li>
<xsl:text>
{% endif %}
</xsl:text>
<xsl:text>{% endfor %}</xsl:text>
</ul>
</xsl:result-document>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="a">
<xsl:text>"[</xsl:text>
<xsl:value-of select=".//text()"/>
<xsl:text>](</xsl:text>
<xsl:choose>
<xsl:when test="starts-with(@href, 'http://www.w3.org/TR/')">
<xsl:text>/spec/</xsl:text>
<xsl:value-of select="substring-before(substring-after(@href, 'http://www.w3.org/TR/'), '/')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@href"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>)"</xsl:text>
</xsl:template>
<xsl:template match="a" mode="md-title">
<xsl:text>\"</xsl:text>
<xsl:variable name="apos" select='"'"'/>
<xsl:value-of select="replace(string-join(.//text()), '"', $apos)"/>
<xsl:text>\"</xsl:text>
</xsl:template>
<xsl:template name="generate-section">
<xsl:choose>
<xsl:when test="current-grouping-key() eq 'other'">
<xsl:text>
## <a name="others"/>Non-W3C Specifications (</xsl:text>
</xsl:when>
<xsl:when test="current-grouping-key() eq 'abandoned'">
<xsl:text>
### Abandoned Specifications (</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>
### <a name="</xsl:text>
<xsl:value-of select="current-grouping-key()"/>
<xsl:text>"/></xsl:text>
<xsl:value-of select="$status-title[index-of($status-index, current-grouping-key())]"/>
<xsl:text>s (</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="count(current-group())"/>
<xsl:text> Specs)

</xsl:text>
<xsl:for-each select="current-group()">
<xsl:sort select="title/text()"/>
<xsl:text>* [</xsl:text>
<xsl:value-of select="title/text()"/>
<xsl:text>](</xsl:text>
<xsl:if test="current-grouping-key() ne 'other'">
<xsl:text>spec/</xsl:text>
</xsl:if>
<xsl:value-of select="@id"/>
<xsl:text>)</xsl:text>
<xsl:if test="exists(@ed)">
<xsl:text> ([ED](</xsl:text>
<xsl:value-of select="@ed"/>
<xsl:text> "Editor's Draft"))</xsl:text>
</xsl:if>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>