line break and hyphenation

Discussion in 'XML' started by patrik.nyman@orient.su.se, Dec 22, 2006.

  1. Guest

    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? I want to be able to
    get both 'hyphe-<br/>nated' and 'hyphenated' as
    output. Is there someone who can help me?

    /Patrik Nyman
    , Dec 22, 2006
    #1
    1. Advertising

  2. Guest

    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:eek:therwise>
    <xsl:value-of select="$w"/>
    </xsl:eek:therwise>
    </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
    , Dec 22, 2006
    #2
    1. Advertising

  3. Guest

    Hello again, Pavel!

    wrote:

    > What have you tried?


    It was too lame to show in public...

    Your code works brilliantly (of course). Thanks a lot
    for helping me out again, I really appreciate it.

    Merry Christmas,
    /Patrik Nyman
    , Dec 22, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    16
    Views:
    696
    Jukka K. Korpela
    Apr 15, 2006
  2. =?Utf-8?B?QmFobWFu?=

    Hyphenation in string causes newline

    =?Utf-8?B?QmFobWFu?=, Aug 30, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    327
    =?Utf-8?B?QmFobWFu?=
    Aug 30, 2006
  3. Dr. leo
    Replies:
    0
    Views:
    269
    Dr. leo
    Feb 13, 2008
  4. Dr. leo
    Replies:
    5
    Views:
    302
    thebjorn
    Feb 25, 2008
  5. Dr. leo
    Replies:
    0
    Views:
    252
    Dr. leo
    Mar 2, 2008
Loading...

Share This Page