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

Re: Newline problems

Subject: Re: Newline problems
From: "Vishwajit Pantvaidya" <pantvaidya@xxxxxxxxxxx>
Date: Thu, 01 May 2003 16:41:27 -0700
newline in xml string
Thanks Mike for your help.

Since I have no way of knowing which elements in the source xml would have newlines, would it mean that I will need to have the normalize-space function all over my xsl sheet?


- Vishwajit.





From: Mike Brown <mike@xxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Newline problems
Date: Thu, 1 May 2003 16:13:40 -0600 (MDT)

Vishwajit Pantvaidya wrote:
> I am using xalan for xml to xml transformation. Input xml string
> has some DOS carriage return and/or line feeds introduced by the source
> application.

XML parsers normalize CR+LF to LF, except in attribute values containing
a CR written as a numeric character reference like
. So in XSLT you
get only LFs (
) 99.999% of the time.

> The source xml string that I was trying to transform is like > (exactly as is, including newlines) > > <!DOCTYPE ABC [ > ... > ]><ABC> > ... > <attr> > value</attr> > ... > </ABC> >

To better understand what is going on, you should use something that helps you
create a more tangible representation of the XPath/XSLT node tree.


XPath tree visualization stylesheets you can apply to the above XML:
  http://skew.org/xml/stylesheets/treeview/ascii/
  http://skew.org/xml/stylesheets/treeview/html/
  http://www.cranesoftwrights.com/resources/showtree/

Software providing XPath tree visualization:
  http://www.topxml.com/xpathvisualizer/
  http://www.logilab.org/xpathvis/
  and various XML editors like XML SPY.

In the case of the element named 'attr', its child text node will
encapsulate the text (linefeed character) + 'value' no matter what
you do, because it is considered signficant in the XPath data model.

If you don't wish to use this text verbatim, you may find that applying the
XPath function normalize-space() to the node or string will give you the
string you wanted. The normalize-space function takes the "string-value" of
its argument, strips leading and trailing whitespace, and collapses
intermediate runs of whitespace to a single space character, returning an
XPath string object.

XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



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.