Changeset 1711


Ignore:
Timestamp:
Jul 4, 2012, 2:15:15 AM (7 years ago)
Author:
julian.reschke@…
Message:

enhance diagnostics on ABNF mismatches

File:
1 edited

Legend:

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

    r581 r1711  
    7878  <xsl:if test="not(//section[@anchor='collected.abnf']) or normalize-space($src) != normalize-space($collected)">
    7979    <xsl:message>WARNING: appendix contained inside source document needs to be updated</xsl:message>
    80     <!--<xsl:message>A: <xsl:value-of select="//section[@anchor='collected.abnf']//artwork"/></xsl:message>
    81     <xsl:message>B: <xsl:value-of select="$collected"/></xsl:message>-->
     80    <xsl:call-template name="showdiff">
     81      <xsl:with-param name="actual" select="normalize-space($src)"/>
     82      <xsl:with-param name="expected" select="normalize-space($collected)"/>
     83    </xsl:call-template>
    8284  </xsl:if>
     85</xsl:template>
     86
     87<xsl:template name="showdiff">
     88  <xsl:param name="actual"/>
     89  <xsl:param name="expected"/>
     90  <xsl:param name="prev"/>
     91 
     92  <xsl:choose>
     93    <xsl:when test="$actual=''">
     94      <!-- done -->
     95    </xsl:when>
     96    <xsl:when test="substring($actual,1,1)=substring($expected,1,1)">
     97      <xsl:call-template name="showdiff">
     98        <xsl:with-param name="actual" select="substring($actual,2)"/>
     99        <xsl:with-param name="expected" select="substring($expected,2)"/>
     100        <xsl:with-param name="prev" select="concat($prev,substring($actual,1,1))"/>
     101      </xsl:call-template>
     102    </xsl:when>
     103    <xsl:otherwise>
     104      <xsl:message>WARNING: at position <xsl:value-of select="string-length($prev)"/></xsl:message>
     105      <xsl:message>WARNING: prefix <xsl:value-of select="$prev"/></xsl:message>
     106      <xsl:message>WARNING: actual text is: '<xsl:value-of select="substring($actual,1,20)"/>...' expected was: '<xsl:value-of select="substring($expected,1,20)"/>...'</xsl:message>
     107    </xsl:otherwise>
     108  </xsl:choose>
    83109</xsl:template>
    84110
Note: See TracChangeset for help on using the changeset viewer.