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

RE: Whitespace,xml:space,xsl:strip-space

Subject: RE: Whitespace,xml:space,xsl:strip-space
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Fri, 23 Jun 2000 17:42:24 +0100
strip whitespace xml
> Am I correct in saying that :-
> 
> 1. the default parser behaviour

Let's be clear here: we're talking about the XML parser, not the XSLT
processor, OK?

 (ie. when have not set the 
> parser NOT to include whitespace or overidden 
> ignorableWhitespace with a noop) is for all whitespace, ie. 
> leading and trailing whitespace, and also carriage returns 
> etc. to be passed to the application.

There are essentially three things an XML parser does with whitespace:
- it normalises line endings to a single #xa character
- it normalises whitespace in attribute values, depending on the attribute
type
- it distinguishes between whitespace in elements with element content and
whitespace in elements with pcdata or mixed content. However, an XSLT
processor ignores this distinction.

> The latter becoming whitespace-only text nodes.
This is now an XSLT (or XPath) concept rather than an XML concept. A
Whitespace-only text node arises (only) when all the text between two tags
is whitespace.
> 
> 2. the effect of xml:space on whitespace-only text nodes 
> produced by the parser is that when xml:space ="preserve" 
> then the IsIgnorableWhitespace() method of these 
> whitespace-only text nodes will return false indicating that 
> they should not be discarded by the application; and when 
> xml:space="default" then the method will return false 
> indicating that can be discarded by the aqpplication.

Which spec are we talking about now? Whitespace-only text nodes are an XSLT
concept, xml:space is an XML concept, and the IsIgnorableWhitespace() method
is heaven-only-knows what!

> 
> 3. the xml:space attribute has no effect on leading or 
> trailing whitespace, eg.
> <schedule>
> <scheduleNumber xml:space="default">    123456789</scheduleNumber>
> </schedule>

Correct.
> 
> 4. xsl:strip-space can be used to strip leading and trailing 
> whitespace in a text node, but will not affect the white 
> space ONLY text nodes.

Wrong. xsl:strip-space removes whitespace-only text nodes, it has no effect
on nodes that are not whitespace-only.
> 
> 5. Could someone please provide an example(s) of the above, 
> including where
> exactly to put the xsl:strip-space and xsl:preserve elements.
> 

XSLT Programmer's Reference by yours truly, pp 129-135 and 265-269.

Mike Kay


 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.