source: draft-ietf-httpbis/latest/extract-warn-code-defs.xslt

Last change on this file was 2384, checked in by fielding@…, 6 years ago

Reduce the burden of processing warn-date to recipients that do something with Warning fields; use warn-code section titles to demonstrate syntax examples (and differentiate from status codes); clarify tortured wording around Age; demonstrate 4am mastery of xslt; addresses #486

  • Property svn:executable set to *
File size: 3.3 KB
Line 
1<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2               xmlns:x="http://purl.org/net/xml2rfc/ext"
3               xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
4               version="1.0"
5               exclude-result-prefixes="rdf x"
6>
7
8<xsl:output indent="yes" omit-xml-declaration="yes"/>
9
10<xsl:output indent="yes" omit-xml-declaration="yes"/>
11
12<xsl:template match="/">
13  <xsl:variable name="table">
14    <texttable align="left" suppress-title="true" anchor="iana.warn.code.registration.table">
15      <ttcol>Warn Code</ttcol>
16      <ttcol>Short Description</ttcol>
17      <ttcol>Reference</ttcol>
18      <xsl:apply-templates select="//section[iref[contains(@item,' (warn-code)') and @primary='true']]">
19        <xsl:sort select="iref[contains(@item,' (warn-code)') and @primary='true']/@item"/>
20      </xsl:apply-templates>
21    </texttable>
22    <xsl:text>&#10;</xsl:text>
23  </xsl:variable>
24
25  <xsl:comment>AUTOGENERATED FROM extract-warn-code-defs.xslt, do not edit manually</xsl:comment>
26  <xsl:text>&#10;</xsl:text>
27  <xsl:copy-of select="$table"/>
28  <xsl:comment>(END)</xsl:comment>
29  <xsl:text>&#10;</xsl:text>
30
31  <!-- check against current version -->
32  <xsl:variable name="oldtable" select="//texttable[@anchor='iana.warn.code.registration.table']" />
33
34  <xsl:variable name="s">
35    <xsl:apply-templates select="$table//texttable" mode="tostring"/>
36  </xsl:variable>
37 
38  <xsl:variable name="s1">
39    <xsl:apply-templates select="$oldtable" mode="tostring"/>
40  </xsl:variable>
41
42  <xsl:if test="$s != $s1">
43    <xsl:message>WARNING: table contained inside source document needs to be updated</xsl:message>
44    <xsl:message><xsl:value-of select="$s"/></xsl:message>
45    <xsl:message><xsl:value-of select="$s1"/></xsl:message>
46  </xsl:if>
47
48</xsl:template>
49
50<xsl:template match="*" mode="tostring">
51  <xsl:text>&lt;</xsl:text>
52  <xsl:value-of select="name()"/>
53  <xsl:for-each select="@*">
54    <xsl:sort select="name()"/>
55    <xsl:text> </xsl:text>
56    <xsl:value-of select="name()"/>
57    <xsl:text>=</xsl:text>
58    <xsl:value-of select="."/>
59  </xsl:for-each>
60  <xsl:text>&gt;</xsl:text>
61 
62  <xsl:apply-templates select="node()" mode="tostring"/>
63 
64  <xsl:text>&lt;/</xsl:text>
65  <xsl:value-of select="name()"/>
66  <xsl:text>&gt;</xsl:text>
67
68</xsl:template>
69
70<xsl:template match="text()" mode="tostring">
71  <xsl:value-of select="."/>
72</xsl:template>
73
74<xsl:template match="texttable/text()" mode="tostring"/>
75<xsl:template match="texttable/c[xref]/text()" mode="tostring"/>
76
77<xsl:template match="section">
78  <xsl:variable name="c" select="iref[contains(@item,'(warn-code)')]/@item"/>
79  <xsl:variable name="code" select="substring-before($c,' (warn-code)')"/>
80  <xsl:variable name="t" select="iref[contains(@item,'(warn-text)')]/@item"/>
81  <xsl:variable name="text" select="substring-before($t,' (warn-text)')"/>
82  <xsl:variable name="redirects-to-other-part" xmlns:p2="urn:ietf:id:draft-ietf-httpbis-p2-semantics#" select="rdf:Description/p2:redirects-to"/>
83
84  <xsl:if test="not($redirects-to-other-part)">
85    <xsl:text>&#10;</xsl:text>
86    <c><xsl:value-of select="$code"/></c>
87    <c><xsl:value-of select="$text"/></c>
88    <c><xref target="{@anchor}"/></c>
89  </xsl:if>
90</xsl:template>
91
92</xsl:transform>
Note: See TracBrowser for help on using the repository browser.