xsl-list
[Top] [All Lists]

Re: [xsl] Removing line breaks without normalize-space()

2006-09-19 11:05:20
I believe something like this will work

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:variable name="cr"><xsl:text>
</xsl:text></xsl:variable>
<xsl:template match="/">
        <xsl:apply-templates/>
</xsl:template>

<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match="text()">
<xsl:value-of select="translate(., $cr, '')"/>
</xsl:template>

</xsl:stylesheet>

On 9/19/06, Mark Peters <flickrmeister(_at_)gmail(_dot_)com> wrote:
Hi,

Is there any way to remove line breaks without deleting the whitespace
in-between elements? For example, suppose you started with the
following XML:

<paragraph>
        <sentence>Some words are <i>italicized</i> and some words are in
<b>bold</b>.</sentence>
        <sentence>Some words are <u>underlined</u>.</sentence>
</paragraph>


I'd like to remove the line breaks, but otherwise retain any existing
whitespace between elements, resulting in the following XML:

<paragraph><sentence>Some words are <i>italicized</i> and some words
are in <b>bold</b>.</sentence><sentence>Some words are
<u>underlined</u>.</sentence></paragraph>

I'm trying to avoid sentences whose contents run together when I
process the text.

Thanks!

Mark

--

Mark Peters
Senior Technical Writer
Saba Software

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--