473,513 Members | 2,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Dec 22 '06 #1
2 3212

pa**********@orient.su.se 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:otherwise>
<xsl:value-of select="$w"/>
</xsl:otherwise>
</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 '06 #2
Hello again, Pavel!

p.*****@ctncorp.com 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 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
22404
by: Roland Dalmulder | last post by:
Hello all, In my PHP script I put a text file into a string. Part of that string is read, changed and removed. The while loop continuest to extract the next part of the string. This goes all...
19
10523
by: les_ander | last post by:
Hi, suppose I am reading lines from a file or stdin. I want to just "peek" in to the next line, and if it starts with a special character I want to break out of a for loop, other wise I want to...
6
62958
by: Jonathan | last post by:
I want to save textarea contents to a mysql database with the paragraph breaks intact without having to type paragraph or break tags in HTML. How can I do that. So far, although it occurs naturally...
18
20504
by: Gustaf Liljegren | last post by:
IE does, and I can't remember this used to be a problem in Netscape. I guess someone in the Mozilla team just came up with a Smart Idea about the True Semantics of the Hyphen Minus character. :-(...
0
925
by: ksf | last post by:
Publisher: Tools selected, but language and hyphenation are grayed-out. Why? -- ksf
9
5189
by: Adi | last post by:
Hello eveyone, I wanna ask a very simple question here (as it was quite disturbing me for a long time.) My problem is to read a file line by line. I've tried following implementations but still...
10
7197
by: Itaichuk | last post by:
Hi I read in several CSS tutorials that block-level elements, such as <div& <pare rendered with an implicit line break before and after. I set to test this out using the following HTML: I...
16
4415
by: lovecreatesbea... | last post by:
It takes mu so time to finish this C source code line count function. What do you think about it? / ******************************************************************************* * Function ...
7
4191
by: jeddiki | last post by:
Hi, I am using a function called htmlwrap() which states that it does NOT add a "<br>" to the 70 character line so that it forces a line wrap. ( the script safely wraps long words without...
0
7380
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7523
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5683
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.