openva / va-decoded

The Virginia implementation of The State Decoded.
https://vacode.org/
Other
3 stars 4 forks source link

Only remove trailing periods from section heading identifiers #10

Closed waldoj closed 8 years ago

waldoj commented 8 years ago

This line is over-broad:

<xsl:value-of select="translate(heading/desig, '.', '')" />

It's stripping all periods from section headers, instead of just trailing periods.

waldoj commented 8 years ago

Looks like substring(string,start,len) is the way to do this. I'm thinking something like (barely-better-than-pseudocode follows):

<xsl:if test="substring(heading/desig,-1,1) = '.'">
   <xsl:attribute name="prefix">
      <xsl:variable name="prefix-length" select="string-length(heading/desig)"/>
      <xsl:value-of name="prefix-cropped" select="substring(heading/desig,prefix-length,prefix-length-1)"/>
   </xsl:attribute>
</xsl:if>
waldoj commented 8 years ago

I have no idea why that fix works. Trimming heading/desig to its string length should make no difference whatsoever. It should be the string length minus one. And yet.