xsl-list
[Top] [All Lists]

RE: [xsl] Stripping Only Newlines from Mixed Content

2007-10-05 11:29:53
use translate($x, '
', '')

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Rudder, Doug Jr [mailto:Doug(_dot_)Rudder(_at_)wolterskluwer(_dot_)com] 
Sent: 05 October 2007 18:42
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Stripping Only Newlines from Mixed Content

Is it possible to strip only newlines from nodes containing 
mixed content in XSLT 1.0?

I have a situation where incoming XML files occasionally have 
newlines in the middle of text that need to be stripped, but 
the text may also contain mixed content elements. For example:

<p>test <tag>more text</tag> text (TXT)
and more text after newline.</p>

This should be output as:

<p>test <tag>more text</tag> text (TXT) and more text after 
newline.</p>

However, if I run the XML through an identity transform and 
use normalize-space on the text nodes, I get this:

<p>test<tag>more text</tag>text (TXT) and more text after newline.</p>

Note that the spaces around the nested <tag> element are gone.

The newline needs to be stripped out, but the spaces around 
the nested element need to be retained.

============================
Douglas Rudder
XML Architect
Wolters Kluwer Health, Clinical Solutions
77 West Port Plaza, Suite 450
St. Louis, MO 63146
Phone: 314-216-2227
email: Doug(_dot_)Rudder(_at_)wolterskluwer(_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>
--~--



--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>