source: rfc2629xslt/clean-for-DTD.xslt @ 2512

Last change on this file since 2512 was 2499, checked in by julian.reschke@…, 7 years ago

update to latest version of rfc2629.xslt

  • Property svn:eol-style set to native
File size: 24.1 KB
Line 
1<!--
2    Strip rfc2629.xslt extensions, generating XML input for MTR's xml2rfc
3
4    Copyright (c) 2006-2013, Julian Reschke (julian.reschke@greenbytes.de)
5    All rights reserved.
6
7    Redistribution and use in source and binary forms, with or without
8    modification, are permitted provided that the following conditions are met:
9
10    * Redistributions of source code must retain the above copyright notice,
11      this list of conditions and the following disclaimer.
12    * Redistributions in binary form must reproduce the above copyright notice,
13      this list of conditions and the following disclaimer in the documentation
14      and/or other materials provided with the distribution.
15    * Neither the name of Julian Reschke nor the names of its contributors
16      may be used to endorse or promote products derived from this software
17      without specific prior written permission.
18
19    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29    POSSIBILITY OF SUCH DAMAGE.
30-->
31
32<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
33                version="1.0"
34                xmlns:ed="http://greenbytes.de/2002/rfcedit"
35                xmlns:grddl="http://www.w3.org/2003/g/data-view#"
36                xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
37                xmlns:x="http://purl.org/net/xml2rfc/ext"
38                xmlns:xhtml="http://www.w3.org/1999/xhtml"
39                exclude-result-prefixes="ed grddl rdf x xhtml"
40>
41
42<!-- re-use some of the default RFC2629.xslt rules -->
43<xsl:import href="rfc2629.xslt"/>
44
45<!-- undo strip-space decls -->
46<xsl:preserve-space elements="*"/>
47
48<!-- generate DTD-valid output, override all values imported from rfc2629.xslt -->
49<xsl:output doctype-system="rfc2629.dtd" doctype-public="" method="xml" version="1.0" encoding="UTF-8" cdata-section-elements="artwork" />
50
51<!-- kick into cleanup mode -->
52<xsl:template match="/">
53  <xsl:text>&#10;</xsl:text>
54  <xsl:comment>
55    This XML document is the output of clean-for-DTD.xslt; a tool that strips
56    extensions to RFC2629(bis) from documents for processing with xml2rfc.
57</xsl:comment>
58  <xsl:apply-templates select="/" mode="cleanup"/>
59</xsl:template>
60
61<!-- rules for identity transformations -->
62
63<xsl:template match="processing-instruction()" mode="cleanup">
64  <xsl:text>&#10;</xsl:text>
65  <xsl:copy/>
66</xsl:template>
67
68<xsl:template match="comment()|@*" mode="cleanup"><xsl:copy/></xsl:template>
69
70<xsl:template match="text()" mode="cleanup"><xsl:copy/></xsl:template>
71
72<xsl:template match="/" mode="cleanup">
73        <xsl:copy><xsl:apply-templates select="node()" mode="cleanup" /></xsl:copy>
74</xsl:template>
75
76<xsl:template match="*" mode="cleanup">
77  <xsl:element name="{local-name()}">
78        <xsl:apply-templates select="node()|@*" mode="cleanup" />
79  </xsl:element>
80</xsl:template>
81
82
83<!-- remove PI extensions -->
84
85<xsl:template match="processing-instruction('rfc-ext')" mode="cleanup"/>
86<xsl:template match="processing-instruction('BEGININC')" mode="cleanup"/>
87<xsl:template match="processing-instruction('ENDINC')" mode="cleanup"/>
88
89<!-- add issues appendix -->
90
91<xsl:template match="back" mode="cleanup">
92  <back>
93    <xsl:apply-templates select="node()|@*" mode="cleanup" />
94    <xsl:if test="not(/*/@ed:suppress-issue-appendix='yes') and //ed:issue[@status='closed']">
95      <section title="Resolved issues (to be removed by RFC Editor before publication)">
96        <t>
97          Issues that were either rejected or resolved in this version of this
98          document.
99        </t>
100        <xsl:apply-templates select="//ed:issue[@status='closed']" mode="issues" />
101      </section>
102    </xsl:if>
103    <xsl:if test="not(/*/@ed:suppress-issue-appendix='yes') and //ed:issue[@status='open']">
104      <section title="Open issues (to be removed by RFC Editor prior to publication)">
105        <xsl:apply-templates select="//ed:issue[@status!='closed']" mode="issues" />
106      </section>
107    </xsl:if>
108  </back>
109</xsl:template>
110
111
112
113
114<!-- extensions -->
115
116<xsl:template match="x:abnf-char-sequence" mode="cleanup">
117  <xsl:choose>
118    <xsl:when test="substring(.,1,1) != '&quot;' or substring(.,string-length(.),1) != '&quot;'">
119      <xsl:call-template name="error">
120        <xsl:with-param name="msg" select="'contents of x:abnf-char-sequence needs to be quoted.'" />
121      </xsl:call-template>
122    </xsl:when>
123    <xsl:otherwise>
124      <xsl:text>%x</xsl:text>
125      <xsl:call-template name="to-abnf-char-sequence">
126        <xsl:with-param name="chars" select="substring(.,2,string-length(.)-2)"/>
127      </xsl:call-template>
128    </xsl:otherwise>
129  </xsl:choose>
130</xsl:template>
131
132<xsl:template match="x:anchor-alias" mode="cleanup"/>
133
134<xsl:template match="x:bcp14" mode="cleanup">
135  <xsl:apply-templates/>
136</xsl:template>
137
138<xsl:template match="x:assign-section-number" mode="cleanup"/> 
139<xsl:template match="x:link" mode="cleanup"/>
140<xsl:template match="x:source" mode="cleanup"/>
141<xsl:template match="x:feedback" mode="cleanup"/>
142
143<xsl:template match="x:parse-xml" mode="cleanup">
144  <xsl:apply-templates/>
145</xsl:template>
146
147<xsl:template match="x:prose" mode="cleanup">
148  <xsl:variable name="text" select="."/>
149  <xsl:comment>Converted from rfc2629.xslt x:prose extension</xsl:comment>
150  <xsl:choose>
151    <xsl:when test="contains($text,' ')">
152      <seriesInfo name="{substring-before($text,' ')}" value="{substring-after($text,' ')}"/>
153    </xsl:when>
154    <xsl:otherwise>
155      <seriesInfo name="" value="{$text}"/>
156    </xsl:otherwise>
157  </xsl:choose>
158</xsl:template>
159
160<xsl:template match="x:ref" mode="cleanup">
161  <xsl:variable name="val" select="normalize-space(.)"/>
162  <xsl:variable name="target" select="//*[@anchor and (@anchor=$val or x:anchor-alias/@value=$val)][not(ancestor::ed:del)] | //reference/x:source[x:defines=$val]"/>
163  <xsl:if test="count($target)>1">
164    <xsl:message terminate="yes">FATAL: multiple x:ref targets found for <xsl:value-of select="$val"/>.</xsl:message>
165  </xsl:if>
166  <xsl:choose>
167    <xsl:when test="$target/self::x:source">
168      <!-- drop it-->
169      <xsl:value-of select="."/>
170    </xsl:when>
171    <xsl:when test="$target">
172      <xsl:variable name="current" select="."/>
173      <xsl:for-each select="$target">
174        <!-- make it the context -->
175        <xsl:choose>
176          <xsl:when test="self::preamble">
177            <!-- it's not an element we can link to -->
178            <xsl:call-template name="warning">
179              <xsl:with-param name="inline" select="'no'"/>
180              <xsl:with-param name="msg">couldn't create the link as <xsl:value-of select="name()"/> does not support the anchor attribute.</xsl:with-param>
181            </xsl:call-template>
182            <xsl:value-of select="$current"/>
183          </xsl:when>
184          <xsl:otherwise>
185            <xref target="{$target/@anchor}" format="none"><xsl:value-of select="$current"/></xref>
186          </xsl:otherwise>
187        </xsl:choose>
188      </xsl:for-each>
189    </xsl:when>
190    <xsl:otherwise>
191      <xsl:call-template name="warning">
192        <xsl:with-param name="inline" select="'no'"/>
193        <xsl:with-param name="msg">internal link target for '<xsl:value-of select="$val"/>' does not exist.</xsl:with-param>
194      </xsl:call-template>
195      <xsl:value-of select="."/>
196    </xsl:otherwise>
197  </xsl:choose>
198</xsl:template>
199
200<xsl:template match="x:blockquote" mode="cleanup">
201  <t><list>
202    <xsl:apply-templates mode="cleanup" />
203  </list></t>
204</xsl:template>
205
206<xsl:template match="x:h" mode="cleanup">
207  <xsl:apply-templates mode="cleanup" />
208</xsl:template>
209
210<xsl:template match="x:highlight" mode="cleanup">
211  <xsl:apply-templates mode="cleanup" />
212</xsl:template>
213
214<xsl:template match="x:lt" mode="cleanup">
215  <t>
216    <xsl:apply-templates select="@hangText|@anchor" mode="cleanup"/>
217    <xsl:for-each select="t">
218      <xsl:apply-templates mode="cleanup"/>
219      <xsl:if test="position()!=last()">
220        <vspace blankLines="1"/>
221      </xsl:if>
222    </xsl:for-each>
223  </t>
224</xsl:template>
225
226<xsl:template match="x:note" mode="cleanup">
227  <t>
228    <list>
229      <xsl:apply-templates mode="cleanup"/>
230    </list>
231  </t>
232</xsl:template>
233
234<xsl:template match="x:q" mode="cleanup">
235  <xsl:text>"</xsl:text>
236  <xsl:apply-templates mode="cleanup"/>
237  <xsl:text>"</xsl:text>
238</xsl:template>
239
240<xsl:template match="x:dfn" mode="cleanup">
241  <!-- help xml2rfc to keep dfn and following text on the same page -->
242  <!-- removed for now because it broke httpbis-p2 (def of 200 OK in -25)
243  <xsl:if test="not(preceding-sibling::x:dfn) and count(following-sibling::list)=1 and normalize-space(../text()='')">
244    <xsl:processing-instruction name="rfc">needLines="4"</xsl:processing-instruction>
245  </xsl:if>-->
246  <xsl:apply-templates mode="cleanup"/>
247</xsl:template>
248
249<xsl:template match="x:sup" mode="cleanup">
250  <xsl:text>^</xsl:text>
251  <xsl:apply-templates mode="cleanup" />
252</xsl:template>
253
254<xsl:template match="x:span" mode="cleanup">
255  <xsl:apply-templates mode="cleanup" />
256</xsl:template>
257<xsl:template match="x:span/@anchor" mode="cleanup"/>
258
259<xsl:template match="author/@anchor" mode="cleanup"/>
260<xsl:template match="x:include-author" mode="cleanup">
261  <t>
262    <xsl:value-of select="/*/front/author[@anchor=current()/@target]"/>
263  </t>
264  <t>
265    (see Authors Section)
266  </t>
267</xsl:template>
268
269<!-- extended reference formatting -->
270
271<xsl:template match="xref[(@x:fmt or @x:sec or @x:rel) and not(node())]" mode="cleanup">
272  <xsl:call-template name="insert-iref-for-xref"/>
273  <xsl:variable name="node" select="$src//*[@anchor=current()/@target]" />
274
275  <xsl:variable name="sec">
276    <xsl:choose>
277      <xsl:when test="starts-with(@x:rel,'#') and not(@x:sec) and $node/x:source/@href">
278        <xsl:variable name="extdoc" select="document($node/x:source/@href)"/>
279        <xsl:for-each select="$extdoc//*[@anchor=substring-after(current()/@x:rel,'#')]">
280          <xsl:call-template name="get-section-number"/>
281        </xsl:for-each>
282      </xsl:when>
283      <xsl:otherwise>
284        <xsl:value-of select="@x:sec"/>
285      </xsl:otherwise>
286    </xsl:choose>
287  </xsl:variable>
288
289  <xsl:variable name="secterm">
290    <xsl:choose>
291      <!-- starts with letter? -->
292      <xsl:when test="translate(substring($sec,1,1),$ucase,'')=''">Appendix</xsl:when>
293      <xsl:otherwise>Section</xsl:otherwise>
294    </xsl:choose>
295  </xsl:variable>
296
297  <xsl:variable name="fmt">
298    <xsl:choose>
299      <xsl:when test="@x:fmt!=''"><xsl:value-of select="@x:fmt"/></xsl:when>
300      <xsl:when test="ancestor::artwork">,</xsl:when>
301      <xsl:otherwise>of</xsl:otherwise>
302    </xsl:choose>
303  </xsl:variable>
304
305  <xsl:choose>
306    <xsl:when test="$fmt=','">
307      <xref>
308        <xsl:apply-templates select="@target|@format|@pageno|text()|*" mode="cleanup"/>
309      </xref>
310      <xsl:text>, </xsl:text>
311      <xsl:value-of select="$secterm"/>
312      <xsl:text> </xsl:text>
313      <xsl:value-of select="$sec"/>
314    </xsl:when>
315    <xsl:when test="$fmt='sec'">
316      <xsl:value-of select="$secterm"/>
317      <xsl:text> </xsl:text>
318      <xsl:value-of select="$sec"/>
319    </xsl:when>
320    <xsl:when test="$fmt='number'">
321      <xsl:value-of select="$sec"/>
322    </xsl:when>
323    <xsl:when test="$fmt='()'">
324      <xref>
325        <xsl:apply-templates select="@target|@format|@pageno|text()|*" mode="cleanup"/>
326      </xref>
327      <xsl:text> (</xsl:text>
328      <xsl:value-of select="$secterm"/>
329      <xsl:text> </xsl:text>
330      <xsl:value-of select="$sec"/>
331      <xsl:text>)</xsl:text>
332    </xsl:when>
333    <xsl:when test="$fmt='of'">
334      <xsl:value-of select="$secterm"/>
335      <xsl:text> </xsl:text>
336      <xsl:value-of select="$sec"/>
337      <xsl:text> of </xsl:text>
338      <xref>
339        <xsl:apply-templates select="@target|@format|@pageno|text()|*" mode="cleanup"/>
340      </xref>
341    </xsl:when>
342    <xsl:when test="$fmt='anchor'">
343      <xsl:variable name="val">
344        <xsl:call-template name="referencename">
345          <xsl:with-param name="node" select="$node" />
346        </xsl:call-template>
347      </xsl:variable>
348      <!-- remove brackets -->
349      <xsl:value-of select="substring($val,2,string-length($val)-2)"/>
350    </xsl:when>
351    <xsl:otherwise>
352      <xsl:copy>
353        <xsl:apply-templates select="node()" mode="cleanup"/>
354      </xsl:copy>
355    </xsl:otherwise>
356  </xsl:choose>
357</xsl:template>
358
359<xsl:template match="xref[(@x:fmt or @x:sec or @x:rel) and node()]" mode="cleanup">
360  <xsl:call-template name="insert-iref-for-xref"/>
361  <xsl:choose>
362    <xsl:when test="@x:fmt='none'">
363      <xsl:apply-templates mode="cleanup"/>
364    </xsl:when>
365    <xsl:when test="not(@x:fmt)">
366      <xref>
367        <xsl:copy-of select="@target|@format"/>
368        <xsl:apply-templates mode="cleanup"/>
369      </xref>
370    </xsl:when>
371    <xsl:otherwise>
372      <xsl:message>Unsupported x:fmt attribute.</xsl:message>
373    </xsl:otherwise>
374  </xsl:choose>
375</xsl:template>
376
377<xsl:template match="xref[node() and (@target=//preamble/@anchor or @target=//spanx/@anchor)]" mode="cleanup">
378  <!-- remove the link -->
379  <xsl:apply-templates select="node()" mode="cleanup"/>
380</xsl:template>
381
382<xsl:template match="xref[not(node()) and (@target=//preamble/@anchor or @target=//spanx/@anchor)]" mode="cleanup">
383  <!-- fatal -->
384  <xsl:message terminate="yes">Broken xref <xsl:value-of select="@target"/> due to target being filtered out.</xsl:message>
385</xsl:template>
386
387<xsl:template match="xref" mode="cleanup" priority="0">
388  <xsl:call-template name="insert-iref-for-xref"/>
389  <xref>
390    <xsl:copy-of select="@target|@format"/>
391    <xsl:apply-templates mode="cleanup"/>
392  </xref>
393</xsl:template>
394
395<xsl:template name="insert-iref-for-xref">
396  <xsl:if test="$xml2rfc-ext-include-references-in-index='yesxxx' and $xml2rfc-ext-include-index='yes'">
397    <xsl:if test="@target=/rfc/back//reference/@anchor">
398      <iref item="{@target}"/>
399      <xsl:if test="@x:sec">
400        <xsl:choose>
401          <xsl:when test="translate(substring(@x:sec,1,1),$ucase,'')=''">
402            <iref item="{@target}" subitem="Appendix {@x:sec}"/>
403          </xsl:when>
404          <xsl:otherwise>
405            <iref item="{@target}" subitem="Section {@x:sec}"/>
406          </xsl:otherwise>
407        </xsl:choose>
408      </xsl:if>
409    </xsl:if>
410  </xsl:if>
411</xsl:template>
412
413<!-- drop index gen extension -->
414<xsl:template match="iref" mode="cleanup">
415  <xsl:if test="$xml2rfc-ext-include-index='yes'">
416    <iref>
417      <xsl:apply-templates select="@*|node()" mode="cleanup"/>
418    </iref>
419  </xsl:if>
420</xsl:template>
421
422
423<!-- issue tracking extensions -->
424
425<xsl:template match="@xml:lang" mode="cleanup"/>
426<xsl:template match="@xml:lang" />
427
428<xsl:template match="ed:*" mode="cleanup"/>
429<xsl:template match="ed:*" />
430
431<xsl:template match="@ed:*" mode="cleanup"/>
432<xsl:template match="@ed:*" />
433
434<xsl:template match="ed:annotation" mode="cleanup" />
435
436<xsl:template match="ed:replace" mode="cleanup">
437  <xsl:apply-templates mode="cleanup" />
438</xsl:template>
439
440<xsl:template match="ed:replace">
441  <xsl:apply-templates/>
442</xsl:template>
443
444<xsl:template match="ed:ins" mode="cleanup">
445  <xsl:apply-templates mode="cleanup"/>
446</xsl:template>
447
448<xsl:template match="ed:ins">
449  <xsl:apply-templates/>
450</xsl:template>
451
452<xsl:template match="ed:issue" mode="issues">
453  <section title="{@name}">
454    <xsl:variable name="sec">
455      <xsl:call-template name="get-section-number"/>
456    </xsl:variable>
457
458    <xsl:if test="$sec!=''">
459      <t>
460        In Section <xsl:value-of select="$sec"/>:
461      </t>
462    </xsl:if>
463   
464    <t>
465      Type: <xsl:value-of select="@type" />
466    </t>
467    <xsl:if test="@href">
468      <t>
469        <!-- temp. removed because of xml2rfc's handling of erefs when producing TXT-->
470        <!--<eref target="{@href}" /> -->
471        <xsl:text>&lt;</xsl:text>
472        <xsl:value-of select="@href"/>
473        <xsl:text>></xsl:text>
474        <xsl:if test="@alternate-href">
475          <xsl:text>, &lt;</xsl:text>
476          <xsl:value-of select="@alternate-href"/>
477          <xsl:text>></xsl:text>
478        </xsl:if>
479      </t>
480    </xsl:if>
481    <xsl:for-each select="ed:item">
482      <t>
483        <xsl:if test="@entered-by or @date">
484          <xsl:choose>
485            <xsl:when test="not(@entered-by)">
486              <xsl:value-of select="concat('(',@date,') ')" />
487            </xsl:when>
488            <xsl:when test="not(@date)">
489              <xsl:value-of select="concat(@entered-by,': ')" />
490            </xsl:when>
491            <xsl:otherwise>
492              <xsl:value-of select="concat(@entered-by,' (',@date,'): ')" />
493            </xsl:otherwise>
494          </xsl:choose>     
495        </xsl:if>
496        <xsl:if test="not(xhtml:p)">
497          <xsl:apply-templates select="node()" mode="issues"/>
498        </xsl:if>
499      </t>
500      <xsl:if test="xhtml:p|xhtml:pre">
501        <xsl:for-each select="node()">
502          <xsl:choose>
503            <xsl:when test="self::xhtml:p">
504              <t>
505                <xsl:apply-templates select="node()" mode="issues"/>
506              </t>
507            </xsl:when>
508            <xsl:when test="self::xhtml:pre">
509              <figure>
510                <artwork><xsl:apply-templates select="node()" mode="issues"/></artwork>
511              </figure>
512            </xsl:when>
513            <xsl:otherwise>
514              <t>
515                <xsl:apply-templates select="." mode="issues"/>
516              </t>
517            </xsl:otherwise>
518          </xsl:choose>
519        </xsl:for-each>
520      </xsl:if>
521    </xsl:for-each>
522    <xsl:if test="ed:resolution">
523      <t>
524        <xsl:text>Resolution</xsl:text>
525        <xsl:if test="ed:resolution/@datetime"> (<xsl:value-of select="ed:resolution/@datetime"/>)</xsl:if>
526        <xsl:text>: </xsl:text>
527        <xsl:value-of select="ed:resolution" />
528      </t>
529    </xsl:if>
530  </section>
531</xsl:template>
532
533<xsl:template match="ed:issueref" mode="cleanup">
534  <xsl:apply-templates mode="cleanup"/>
535</xsl:template>
536
537<xsl:template match="*" mode="issues">
538  <xsl:apply-templates mode="issues"/>
539</xsl:template>
540
541<xsl:template match="xhtml:q" mode="issues">
542  <list><t>
543    <xsl:text>"</xsl:text>
544    <xsl:apply-templates mode="issues"/>
545    <xsl:text>"</xsl:text>
546    <xsl:if test="@cite">
547      <xsl:text> -- </xsl:text>
548      <eref target="{@cite}"><xsl:value-of select="@cite"/></eref>
549    </xsl:if>
550  </t></list>
551</xsl:template>
552
553<xsl:template match="xhtml:br" mode="issues">
554  <vspace/>
555</xsl:template>
556
557<xsl:template match="xhtml:del" mode="issues">
558  <xsl:text>&lt;del></xsl:text>
559    <xsl:apply-templates mode="issues"/>
560  <xsl:text>&lt;/del></xsl:text>
561</xsl:template>
562
563<xsl:template match="xhtml:em" mode="issues">
564  <spanx style="emph">
565    <xsl:apply-templates mode="issues"/>
566  </spanx>
567</xsl:template>
568
569<xsl:template match="xhtml:ins" mode="issues">
570  <xsl:text>&lt;ins></xsl:text>
571    <xsl:apply-templates mode="issues"/>
572  <xsl:text>&lt;/ins></xsl:text>
573</xsl:template>
574
575<xsl:template match="xhtml:tt" mode="issues">
576  <xsl:apply-templates mode="issues"/>
577</xsl:template>
578
579<xsl:template match="ed:eref" mode="issues">
580  <xsl:text>&lt;</xsl:text>
581  <xsl:value-of select="."/>
582  <xsl:text>&gt;</xsl:text>
583</xsl:template>
584
585<xsl:template match="ed:issueref" mode="issues">
586  <xsl:apply-templates mode="issues"/>
587</xsl:template>
588
589<xsl:template match="text()" mode="issues">
590  <xsl:value-of select="." />
591</xsl:template>
592
593
594
595<!-- markup inside artwork element -->
596
597<xsl:template match="figure[.//artwork//iref | .//artwork//xref]" mode="cleanup">
598  <!-- move up iref elements -->
599  <xsl:for-each select=".//artwork//xref">
600    <xsl:if test="not(ancestor::ed:del)">
601      <xsl:call-template name="insert-iref-for-xref"/>
602    </xsl:if>
603  </xsl:for-each>
604  <figure>
605    <xsl:apply-templates select="@*" mode="cleanup" />
606    <xsl:apply-templates select=".//artwork//iref" mode="cleanup"/>
607    <xsl:apply-templates select="iref|preamble|artwork|postamble|ed:replace|ed:ins|ed:del" mode="cleanup" />
608  </figure>
609</xsl:template>
610
611<xsl:template name="insert-begin-code"/>
612<xsl:template name="insert-end-code"/>
613<xsl:template match="@x:is-code-component" mode="cleanup"/>
614
615<xsl:template match="artwork" mode="cleanup">
616  <xsl:variable name="content2"><xsl:apply-templates select="."/></xsl:variable>
617  <xsl:variable name="content" select="translate($content2,'&#160;&#x2500;&#x2502;&#x2508;&#x250c;&#x2510;&#x2514;&#x2518;&#x251c;&#x2524;',' -|+++++++')"/>
618  <artwork>
619    <xsl:apply-templates select="@*" mode="cleanup" />
620    <xsl:if test="@x:is-code-component='yes'">
621      <xsl:if test="starts-with(.,'&#10;')">
622        <xsl:text>&#10;</xsl:text>
623      </xsl:if>
624      <xsl:value-of select="@x:indent-with"/>
625      <xsl:text>&lt;CODE BEGINS&gt;&#10;</xsl:text>
626    </xsl:if>
627    <xsl:if test="starts-with(.,'&#10;')">
628      <xsl:text>&#10;</xsl:text>
629      <xsl:value-of select="@x:indent-with"/>
630    </xsl:if>
631    <xsl:choose>
632      <xsl:when test="@x:indent-with!=''">
633        <xsl:call-template name="indent">
634          <xsl:with-param name="content" select="$content"/>
635          <xsl:with-param name="with" select="@x:indent-with"/>
636        </xsl:call-template>
637      </xsl:when>
638      <xsl:otherwise>
639        <xsl:value-of select="$content"/>
640      </xsl:otherwise>
641    </xsl:choose>
642    <xsl:if test="@x:is-code-component='yes'">&#10;&lt;CODE ENDS&gt;&#10;</xsl:if>
643  </artwork> 
644</xsl:template>
645
646<xsl:template match="@x:indent-with" mode="cleanup"/>
647
648<xsl:template name="indent">
649  <xsl:param name="content"/>
650  <xsl:param name="with"/>
651
652  <xsl:value-of select="substring($content,1,1)"/>
653  <xsl:if test="substring($content,1,1)='&#10;'">
654    <xsl:value-of select="$with"/>
655  </xsl:if>
656 
657  <xsl:choose>
658    <xsl:when test="$content=''" />
659    <xsl:otherwise>
660      <xsl:call-template name="indent">
661        <xsl:with-param name="content" select="substring($content,2)"/>
662        <xsl:with-param name="with" select="$with"/>
663      </xsl:call-template>
664    </xsl:otherwise>
665  </xsl:choose>
666 
667</xsl:template>
668
669<!-- email repetitions -->
670<xsl:template match="email" mode="cleanup">
671  <!-- combine in a single element -->
672  <xsl:if test="not(preceding-sibling::email)">
673    <email>
674      <xsl:for-each select="../email">
675        <xsl:value-of select="."/>
676        <xsl:if test="position()!=last()">
677          <xsl:text>, </xsl:text>
678        </xsl:if>
679      </xsl:for-each>
680    </email>
681  </xsl:if>
682</xsl:template>
683
684<!-- markup inside cref -->
685<xsl:template match="cref//eref" mode="cleanup">
686  <xsl:text>&lt;</xsl:text>
687  <xsl:value-of select="@target"/>
688  <xsl:text>&gt;</xsl:text>
689</xsl:template>
690
691<xsl:template match="cref//xref" mode="cleanup" priority="9">
692  <xsl:variable name="text">
693    <xsl:apply-templates select="."/>
694  </xsl:variable>
695  <xsl:value-of select="$text"/>
696</xsl:template>
697
698<!-- annotations -->
699<xsl:template match="@x:annotation" mode="cleanup">
700  <xsl:comment>
701    <xsl:value-of select="."/>
702  </xsl:comment>
703  <xsl:call-template name="warning">
704    <xsl:with-param name="inline" select="'no'"/>
705    <xsl:with-param name="msg">Dropping annotation on <xsl:value-of select="local-name(..)"/> element.</xsl:with-param>
706  </xsl:call-template>
707</xsl:template>
708
709<!-- artwork extensions -->
710<xsl:template match="artwork/@x:extraction-note" mode="cleanup"/>
711
712<!-- list formatting -->
713<xsl:template match="list/@x:indent" mode="cleanup"/>
714
715<!-- referencing extensions -->
716<xsl:template match="iref/@x:for-anchor" mode="cleanup"/>
717
718<!-- table styles -->
719<xsl:template match="texttable/@style" mode="cleanup"/>
720
721<!-- section numbering -->
722<xsl:template match="section/@x:fixed-section-number" mode="cleanup"/>
723
724<!-- GRRDL info stripped -->
725<xsl:template match="@grddl:transformation" mode="cleanup"/>
726
727<!-- maturity level stripped -->
728<xsl:template match="@x:maturity-level" mode="cleanup"/>
729
730<!-- normativity stripped -->
731<xsl:template match="@x:nrm" mode="cleanup"/>
732
733<!-- title extensions -->
734<xsl:template match="title/@x:quotes" mode="cleanup"/>
735
736<!-- RDF info stripped -->
737<xsl:template match="rdf:*" mode="cleanup"/>
738
739<!-- cases where xml2rfc does not allow anchors -->
740<xsl:template match="c/@anchor" mode="cleanup"/>
741<xsl:template match="preamble/@anchor" mode="cleanup"/>
742<xsl:template match="spanx/@anchor" mode="cleanup"/>
743
744</xsl:transform>
Note: See TracBrowser for help on using the repository browser.