Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 22nd, 2006, 08:05 AM
patrik.nyman@orient.su.se
Guest
 
Posts: n/a
Default line break and hyphenation

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

  #2  
Old December 22nd, 2006, 09:45 AM
p.lepin@ctncorp.com
Guest
 
Posts: n/a
Default Re: line break and hyphenation


patrik.nyman@orient.su.se wrote:
Quote:
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?
Quote:
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>
Quote:
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

  #3  
Old December 22nd, 2006, 10:55 AM
patrik.nyman@orient.su.se
Guest
 
Posts: n/a
Default Re: line break and hyphenation

Hello again, Pavel!

p.lepin@ctncorp.com wrote:
Quote:
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

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles