source: draft-ietf-httpbis/latest-roy/extract-method-defs.xslt @ 473

Last change on this file since 473 was 292, checked in by julian.reschke@…, 15 years ago

Fix checking of consistency of auto-generated tables (related to #72)

  • Property svn:executable set to *
File size: 2.9 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:template match="/">
11  <xsl:variable name="table">
12    <texttable align="left" suppress-title="true" anchor="iana.method.registration.table">
13      <ttcol>Method</ttcol>
14      <ttcol>Safe</ttcol>
15      <ttcol>Reference</ttcol>
16      <xsl:apply-templates select="//section[iref/@item='Methods']">
17        <xsl:sort select="iref[@item='Methods']/@subitem"/>
18      </xsl:apply-templates>
19    </texttable>
20    <xsl:text>&#10;</xsl:text>
21  </xsl:variable>
22
23  <xsl:comment>AUTOGENERATED FROM extract-method-defs.xslt, do not edit manually</xsl:comment>
24  <xsl:text>&#10;</xsl:text>
25  <xsl:copy-of select="$table"/>
26  <xsl:comment>(END)</xsl:comment>
27  <xsl:text>&#10;</xsl:text>
28 
29  <!-- check against current version -->
30  <xsl:variable name="oldtable" select="//texttable[@anchor='iana.method.registration.table']" />
31
32  <xsl:variable name="s">
33    <xsl:apply-templates select="$table//texttable" mode="tostring"/>
34  </xsl:variable>
35 
36  <xsl:variable name="s1">
37    <xsl:apply-templates select="$oldtable" mode="tostring"/>
38  </xsl:variable>
39
40  <xsl:if test="$s != $s1">
41    <xsl:message>WARNING: table contained inside source document needs to be updated</xsl:message>
42    <xsl:message><xsl:value-of select="$s"/></xsl:message>
43    <xsl:message><xsl:value-of select="$s1"/></xsl:message>
44  </xsl:if>
45 
46</xsl:template>
47
48<xsl:template match="*" mode="tostring">
49  <xsl:text>&lt;</xsl:text>
50  <xsl:value-of select="name()"/>
51  <xsl:for-each select="@*">
52    <xsl:sort select="name()"/>
53    <xsl:text> </xsl:text>
54    <xsl:value-of select="name()"/>
55    <xsl:text>=</xsl:text>
56    <xsl:value-of select="."/>
57  </xsl:for-each>
58  <xsl:text>&gt;</xsl:text>
59 
60  <xsl:apply-templates select="node()" mode="tostring"/>
61 
62  <xsl:text>&lt;/</xsl:text>
63  <xsl:value-of select="name()"/>
64  <xsl:text>&gt;</xsl:text>
65
66</xsl:template>
67
68<xsl:template match="text()" mode="tostring">
69  <xsl:value-of select="."/>
70</xsl:template>
71
72<xsl:template match="texttable/text()" mode="tostring"/>
73<xsl:template match="texttable/c[xref]/text()" mode="tostring"/>
74
75<xsl:template match="section">
76
77  <xsl:variable name="text" select="iref[@item='Methods']/@subitem"/>
78
79  <xsl:variable name="safe" xmlns:p2="urn:ietf:id:draft-ietf-httpbis-p2-semantics#">
80    <xsl:choose>
81      <xsl:when test="rdf:Description/p2:safe='yes'">yes</xsl:when>
82      <xsl:otherwise>no</xsl:otherwise>
83    </xsl:choose>
84  </xsl:variable>
85
86  <xsl:text>&#10;</xsl:text>
87  <c><xsl:value-of select="$text"/></c>
88  <c><xsl:value-of select="$safe"/></c>
89  <c><xref target="{@anchor}"/></c>
90</xsl:template>
91
92</xsl:transform>
Note: See TracBrowser for help on using the repository browser.