xsl-list
[Top] [All Lists]

Re: Result still indented despite indent="no"

2005-02-20 06:26:32
Hello David,
  I am not favouring any particular processor. Please
help me have the understanding of section "3.4
Whitespace Stripping" right in XSLT 1.0 spec..

You rightly said, rules for white space stripping are
different for source XML and for stylesheet.. 

I have 2 points to make..
1)
For removing white spaces *from stylesheets*, the 1.0
spec says - "For stylesheets, the set of
whitespace-preserving element names consists of just
xsl:text" . This is the only rule I can find for
stripping whitespaces in stylesheets.

Rest of the rules defined are for *source XML*..

2) I am again quoting following lines from spec(I have
placed * to emphasize my point)..

"A text node is preserved *if any of the following*
apply:

- The element name of the parent of the text node is
in the set of whitespace-preserving element names.

- The text node contains at least one non-whitespace
character. As in XML, a whitespace character is #x20,
#x9, #xD or #xA.

- An ancestor element of the text node has an
xml:space attribute with a value of preserve, and no
closer ancestor element has xml:space with a value of
default.

*Otherwise, the text node is stripped* ".

This definition is quite unambiguous..

In this XML -
<pre> n1
 <b>bold</b> n2
 <i>italic</i> n3
</pre>

Therefore, *whitespace only text nodes* (I have shown
them as n1, n2, and n3) will be stripped, if there is
no xsl:strip-space or/and xsl:preserve-space
instructions.

So after stripping *whitespace only text nodes*(n1, n2
& n3), there will be only 2 child nodes of <pre> (<b>
and <i>) - and MSXML is giving result 2(which I feel
is right), for XPath expression
count(/pre/child::node()) . But Saxon and Xalan are
giving result 5(they are counting n1, n2 & n3 also).

If the above definition from spec(the above quote I
have specified) to strip white spaces is final, then
my reasoning should be right!

As Dimitre said, the spec in the next paragraph has
said..
"Initially, the set of whitespace-preserving element
names contains all element names".

But it seems to me, this sentence of part of paragraph
which describes an algorithm to implement
xsl:strip-space and xsl:preserve-space instructions.. 

If Dimitre is right, then the above sentence should
have been written something like..
Initially, the set of whitespace-preserving elements
contains all the element. In this sentence, the spec
is saying 'element names' and not 'elements'. 

Even if Dimitre is right, I feel, this is not the
right place to define rule for stripping text nodes..
The rule has already been defined unambiguously in the
previous paragraph i.e.
"A text node is preserved if any of the following
apply:
..

Otherwise, the text node is stripped"

Regards,
Mukul

--- David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:


It seems to me, MSXML4 is compliant in this regard.
I
fear, Saxon and Xalan are not compliant..

No this is a well known non compliance on the part
of msxml.
To get compliant white space behaviour from msxml
you need to set the
preserveWhitesSpace property to true before parsing
the file.

You appear to be confuxing the description of which
nodes are stripped
from the stylesheet and which from the source. The
rules are different.

David



                
__________________________________ 
Do you Yahoo!? 
All your favorites on one personal page ? Try My Yahoo!
http://my.yahoo.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>
--~--