P
patrik.nyman
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">
<xslaram 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>
<xsltherwise>
<xsl:value-of select="$w"/>
</xsltherwise>
</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|nated">Hyphenated</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>Hyphe</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 <it> and <choose> elements
are not working. Can anyone help me out?
Thanks a lot
/Patrik Nyman
<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">
<xslaram 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>
<xsltherwise>
<xsl:value-of select="$w"/>
</xsltherwise>
</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|nated">Hyphenated</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>Hyphe</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 <it> and <choose> elements
are not working. Can anyone help me out?
Thanks a lot
/Patrik Nyman