pa**********@orient.su.se wrote:
I'm doing markup of some original texts, and want
to be able too optionally keep the line breaks of
the original. But sometimes a word is hyphenated
at a line break. At TEI-L I found the proposition
to encode such cases as
<reg orig="hyphe|nated">hyphenated</reg>
This seems good because the word is availabe for
greping etc. My problem is, how do I write an xslt
template to deal with this?
What have you tried?
I want to be able to get both 'hyphe-<br/>nated'
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="reg">
<xsl:apply-templates select="@orig"/>
</xsl:template>
<xsl:template match="reg/@orig">
<xsl:call-template name="html-hyphens"/>
</xsl:template>
<xsl:template name="html-hyphens">
<xsl:param name="w" select="."/>
<xsl:variable name="car"
select="substring-before($w,'|')"/>
<xsl:variable name="cdr"
select="substring-after($w,'|')"/>
<xsl:choose>
<xsl:when test="$cdr">
<xsl:value-of select="concat($car,'-')"/>
<br/>
<xsl:call-template name="html-hyphens">
<xsl:with-param name="w" select="$cdr"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$w"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
and 'hyphenated' as output.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="reg">
<xsl:apply-templates select="node()"/>
</xsl:template>
</xsl:stylesheet>
--
Pavel Lepin