I have this templates to mark up hyphenation over line breaks:
<xsl:template match="reg[@type='hyp']">
<xsl:apply-templates select="@orig"/>
</xsl:template>
<xsl:template match="reg[@type='hyp']/@orig">
<xsl:call-template name="html-hyphens"/>
</xsl:template>
<xsl:template name="html-hyphens">
<xsl:param name="w" select="."/>
<xsl:variable name="car"
select="substri ng-before($w,'|')"/>
<xsl:variable name="cdr"
select="substri ng-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:otherwis e>
<xsl:value-of select="$w"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
I also have this simple template for italic text:
<xsl:template match ="it">
<i><xsl:apply-templates/></i>
</xsl:template>
This works fine if I write something like:
<it><reg type="hyp" orig="Hyphe|nat ed">Hyphenate d</reg></it>
Now I can choose if I want to preserve linebreaks or not.
But as it happens, in some of the texts I'm working on,
sometimes ony part of the word is in italics (or formatted
some other way), like <it>Hyphe</it>nated, and since I
can't do
<reg type="hyp" orig="<it>Hyphe </it>|nated"><it> Hyphe</it>nated</
reg>
I must write something like:
<choice type="hyp">
<orig><it>Hyphe </it>|nated</orig>
<reg><it>Hyph e</it>nated</reg>
</choice>
So for this I added the following templates:
<xsl:template match="choice[@type='hyp']">
<xsl:apply-templates select="./orig"/>
</xsl:template>
<xsl:template match="choice[@type='hyp']/orig">
<xsl:call-template name="html-hyphens"/>
</xsl:template>
But the combination of the <itand <chooseelemen ts
are not working. Can anyone help me out?
Thanks a lot
/Patrik Nyman