Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > line break and hyphenation

Reply
Thread Tools

line break and hyphenation

 
 
patrik.nyman@orient.su.se
Guest
Posts: n/a
 
      12-22-2006
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

 
Reply With Quote
 
 
 
 
p.lepin@ctncorp.com
Guest
Posts: n/a
 
      12-22-2006

http://www.velocityreviews.com/forums/(E-Mail Removed) 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"
xmlnssl="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">
<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>
</xsl:stylesheet>

> and 'hyphenated' as output.


<xsl:stylesheet version="1.0"
xmlnssl="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

 
Reply With Quote
 
 
 
 
patrik.nyman@orient.su.se
Guest
Posts: n/a
 
      12-22-2006
Hello again, Pavel!

(E-Mail Removed) 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

 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyphenation: PyHyphen 0.4.1 and textwrap2-0.1.1 released Dr. leo Python 0 03-02-2008 02:46 PM
Hyphenation module PyHyphen-0.3 released Dr. leo Python 5 02-25-2008 11:59 PM
PyHyphen-0.2.1a - OpenOffice-like hyphenation Dr. leo Python 0 02-13-2008 07:53 PM
Hyphenation in string causes newline =?Utf-8?B?QmFobWFu?= ASP .Net 0 08-30-2006 10:03 PM
About hyphenation, Please do help sapanparikh18@gmail.com HTML 16 04-15-2006 09:43 PM



Advertisments