Ignore:
Timestamp:
Nov 22, 2008, 10:21:16 AM (11 years ago)
Author:
julian.reschke@…
Message:

ABNF appendix: group by first letter, add internal links to definitions (related to #36)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • draft-ietf-httpbis/latest/abnf2xml2rfc.xslt

    r425 r427  
    11<xsl:transform
    22  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    3   version="2.0">
     3  xmlns:xs="http://www.w3.org/2001/XMLSchema"
     4  xmlns:x="http://purl.org/net/xml2rfc/ext"
     5  version="2.0"
     6  exclude-result-prefixes="xs">
    47
    5 <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
    6  
     8<xsl:output method="xml" omit-xml-declaration="yes" indent="no"/>
     9
    710<xsl:param name="abnf"/> 
    811 
    912<xsl:template match="/">
     13  <xsl:variable name="src" select="."/>
    1014  <xsl:variable name="collected" select="unparsed-text($abnf)"/>
    1115
    12   <section title="Collected ABNF" anchor="collected.abnf"> 
    13 <figure>
    14   <artwork type="abnf" name="{$abnf}">
     16  <xsl:variable name="lines" as="xs:string*" select="tokenize($collected, '\r?\n')"/>
     17 
     18  <section title="Collected ABNF" anchor="collected.abnf">
    1519    <xsl:text>&#10;</xsl:text>
    16     <xsl:value-of select="translate($collected,'&#13;','')"/>
    17   </artwork>
    18 </figure> 
     20    <figure>
     21      <xsl:text>&#10;</xsl:text>
     22      <artwork type="abnf" name="{$abnf}">
     23        <xsl:for-each select="$lines">
     24          <xsl:variable name="lineno" select="position()"/>
     25          <xsl:variable name="sc1" select="substring(.,1,1)"/>
     26          <xsl:variable name="sc0" select="substring($lines[$lineno - 1],1,1)"/>
     27          <xsl:if test="$sc1!=' ' and $sc0!=' ' and $sc1!=$sc0">
     28            <xsl:text>&#10;</xsl:text>
     29          </xsl:if>
     30          <xsl:analyze-string select="." regex='^([A-Za-z0-9\-]+) = ' flags="sm">
     31            <xsl:matching-substring>
     32              <xsl:variable name="term" select="regex-group(1)"/>
     33              <xsl:choose>
     34                <xsl:when test="$src//*[@anchor=$term] or $src//x:anchor-alias[@value=$term]">
     35                  <x:ref><xsl:value-of select="$term"/></x:ref>
     36                </xsl:when>
     37                <xsl:otherwise>
     38                  <xsl:value-of select="$term"/>
     39                </xsl:otherwise>
     40              </xsl:choose>
     41              <xsl:text> = </xsl:text>
     42            </xsl:matching-substring>
     43            <xsl:non-matching-substring>
     44              <xsl:value-of select="."/>
     45            </xsl:non-matching-substring>
     46          </xsl:analyze-string>
     47          <xsl:text>&#10;</xsl:text>
     48        </xsl:for-each>
     49      </artwork>
     50      <xsl:text>&#10;</xsl:text>
     51    </figure> 
     52    <xsl:text>&#10;</xsl:text>
    1953  </section>
    2054
Note: See TracChangeset for help on using the changeset viewer.