[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Stripping Only Newlines from Mixed Content

Subject: RE: Stripping Only Newlines from Mixed Content
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 5 Oct 2007 19:29:25 +0100
RE:  Stripping Only Newlines from Mixed Content
use translate($x, '&#xa;', '')

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

> -----Original Message-----
> From: Rudder, Doug Jr [mailto:Doug.Rudder@xxxxxxxxxxxxxxxxx] 
> Sent: 05 October 2007 18:42
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  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.Rudder@xxxxxxxxxxxxxxxxx
> ============================

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.