Unshy.xslt

A stylesheet to read in TEI (or other XML files) and remove line-end soft hyphens. See header comment for details.





          false   <xsl:when test="$strip1st = 'true'"> <xsl:choose> <xsl:when test="contains(.,' ')"> <xsl:value-of select="substring-after(normalize-space(.),' ')"/> </xsl:when> <xsl:otherwise></xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise><xsl:value-of select="normalize-space(.)"/></xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="nextText"> <xsl:value-of select="normalize-space(following-sibling::text[1])"/> </xsl:variable> <xsl:choose> <xsl:when test="contains(substring-after($me,'&#xAD;'),'&#xAD;')"> <xsl:message>Oh dear. More than 1 &amp;shy; in this text sequence, I'm not going to get this one right.</xsl:message> </xsl:when> <xsl:when test="contains(substring-after($me,'&#xAD;'),'&#xAD;')"> <xsl:message>Oh dear. This &amp;shy; is not the last (non-whitespace) character of the text node. I'm probably going to mess this up.</xsl:message> </xsl:when> </xsl:choose> <xsl:value-of select="substring-before($me,'&#xAD;')"/> <xsl:choose> <xsl:when test="contains($nextText,' ')"> <xsl:value-of select="substring-before($nextText,' ')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$nextText"/> </xsl:otherwise> </xsl:choose> <xsl:text>&#x0A;</xsl:text> </xsl:template>

 <xsl:choose> <xsl:when test="contains(.,'&#x00AD;')"> <xsl:call-template name="hasShy"> <xsl:with-param name="strip1st">true</xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="substring-after(normalize-space(.),' ')"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> I make no claim that this is even a good, let alone the best, way to do this. It did work on my test files, though.