source: draft-ietf-httpbis/latest/extract-header-defs.xslt @ 2644

Last change on this file since 2644 was 2644, checked in by julian.reschke@…, 6 years ago

header field sorting (#553)

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 3.0 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<!-- character translation tables -->
11<xsl:variable name="lcase" select="'abcdefghijklmnopqrstuvwxyz'" />
12<xsl:variable name="ucase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
13
14<xsl:template match="/">
15  <xsl:variable name="table">
16    <texttable align="left" suppress-title="true" anchor="iana.header.registration.table">
17      <ttcol>Header Field Name</ttcol>
18      <ttcol>Protocol</ttcol>
19      <ttcol>Status</ttcol>
20      <ttcol>Reference</ttcol>
21      <xsl:text>&#10;</xsl:text>
22      <xsl:apply-templates select="//section[iref[contains(@item,' header field') and @primary='true']]">
23        <xsl:sort select="translate(iref[contains(@item,' header field') and @primary='true']/@item,$ucase,$lcase)"/>
24      </xsl:apply-templates>
25    </texttable>
26    <xsl:text>&#10;</xsl:text>
27  </xsl:variable>
28
29  <xsl:comment>AUTOGENERATED FROM extract-header-defs.xslt, do not edit manually</xsl:comment>
30  <xsl:text>&#10;</xsl:text>
31  <xsl:copy-of select="$table"/>
32  <xsl:comment>(END)</xsl:comment>
33  <xsl:text>&#10;</xsl:text>
34 
35  <!-- check against current version -->
36  <xsl:variable name="oldtable" select="//texttable[@anchor='iana.header.registration.table']" />
37
38  <xsl:variable name="s">
39    <xsl:apply-templates select="$table//texttable" mode="tostring"/>
40  </xsl:variable>
41 
42  <xsl:variable name="s1">
43    <xsl:apply-templates select="$oldtable" mode="tostring"/>
44  </xsl:variable>
45
46  <xsl:if test="$s != $s1">
47    <xsl:message>WARNING: table contained inside source document needs to be updated</xsl:message>
48    <xsl:message><xsl:value-of select="$s"/></xsl:message>
49    <xsl:message><xsl:value-of select="$s1"/></xsl:message>
50  </xsl:if>
51
52</xsl:template>
53
54<xsl:template match="*" mode="tostring">
55  <xsl:text>&lt;</xsl:text>
56  <xsl:value-of select="name()"/>
57  <xsl:for-each select="@*">
58    <xsl:sort select="name()"/>
59    <xsl:text> </xsl:text>
60    <xsl:value-of select="name()"/>
61    <xsl:text>=</xsl:text>
62    <xsl:value-of select="."/>
63  </xsl:for-each>
64  <xsl:text>&gt;</xsl:text>
65 
66  <xsl:apply-templates select="node()" mode="tostring"/>
67 
68  <xsl:text>&lt;/</xsl:text>
69  <xsl:value-of select="name()"/>
70  <xsl:text>&gt;</xsl:text>
71
72</xsl:template>
73
74<xsl:template match="text()" mode="tostring">
75  <xsl:value-of select="."/>
76</xsl:template>
77
78<xsl:template match="texttable/text()" mode="tostring"/>
79<xsl:template match="texttable/c[xref]/text()" mode="tostring"/>
80
81<xsl:template match="section">
82  <xsl:variable name="t" select="iref[contains(@item,'header field')]/@item"/>
83  <xsl:text>&#10;</xsl:text>
84  <c><xsl:value-of select="substring-before($t,' header field')"/></c>
85  <c>http</c>
86  <c>standard</c>
87  <c><xref target="{@anchor}"/></c>
88</xsl:template>
89
90</xsl:transform>
Note: See TracBrowser for help on using the repository browser.