Hi Ken,
I tested white space handling by Saxon 8.1.1(in XSLT
1.0 mode) , Xalan-J 2.6.0 & MSXML4. I took the XML
example provided by Dare Obasanjo in xml-dev post, and
the XPath expression he posted..
The XML is -
<pre>
<b>bold</b>
<i>italic</i>
</pre>
The XPath expression is -
count(/pre/child::node())
Saxon gives result - 5
MSXML4 gives result - 2
Xalan-J 2.6.0 gives result - 5
The XSLT 1.0 spec(URL -
http://www.w3.org/TR/1999/REC-xslt-19991116) says
(section 3.4 Whitespace Stripping)
"After the tree for a source document or stylesheet
document has been constructed, but before it is
otherwise processed by XSLT, some text nodes *are*
stripped.
A text node *is preserved if any of the following
apply*:
1) The element name of the parent of the text node is
in the set of whitespace-preserving element names.
2) The text node contains at least one non-whitespace
character. As in XML, a whitespace character is #x20,
#x9, #xD or #xA.
3) 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. "
There seems no ambiguity, that in this example
(provided by Dare Obasanjo) - white spaces *must* be
stripped (as none of the above 3 conditions in spec
are holding true).
It seems to me, MSXML4 is compliant in this regard. I
fear, Saxon and Xalan are not compliant..
Also, I feel what the spec recommends in this
regard(white space stripping) is correct..
Unless the user explicitly gives instruction to
preserve white spaces, they should be stripped. *White
space only, text nodes* are of no use for application.
Regards,
Mukul
--- "G. Ken Holman" <gkholman(_at_)CraneSoftwrights(_dot_)com>
wrote:
At 2005-02-19 19:02 -0800, Sebastien Boisvert wrote:
I'm getting a result after applying a stylesheet
where
some nodes get indented for some reason, even if I
set
indent="no" and even the source document is not
indented.
It seems that calling a certain template when
processing the root node somehow sets the indent
mode
to 'yes' but only for that one template, as running
the default template (ie <xsl:apply-templates />)
does
not produce this problem...
Good sleuthing there... well done ... that points to
interpretation of the
stylesheet into a node tree.
I've tried this on another processor with the exact
same stylesheet and source code and it works as
expected (indents do not happen).
Ahhh .. that points to a bug ... unless of course
you used the MSXSL
processor for your alternate test in which it isn't
at all definitive
because the Microsoft processor throws away
whitespace-only text nodes
contrary to the explicit specification rules[1]. If
you used a processor
conformant in the area of whitespace handling, then
the test is more
meaningful.
Is there something/someway that I might be calling
the
template that would cause it to produce indents in
libxslt?
Do you have xml:space="preserve" used anywhere?
That overrides the rules
regarding ignoring whitespace-only text nodes from
the stylesheet node tree
when building the result tree and would make any
such annotated nodes visible.
I hope this helps.
...................... Ken
[1] - excerpts from an online debate regarding this
issue of handling
whitespace-only text nodes, July 2003:
Microsoft's question:
http://lists.xml.org/archives/xml-dev/200307/msg00868.html
Microsoft's answer (by another employee):
http://lists.xml.org/archives/xml-dev/200307/msg00872.html
My claim where I observe Microsoft's non-compliance:
http://lists.xml.org/archives/xml-dev/200307/msg00870.html
Microsoft's counter-claim:
http://lists.xml.org/archives/xml-dev/200307/msg00873.html
My response:
http://lists.xml.org/archives/xml-dev/200307/msg00880.html
Microsoft's position at the end of the debate:
http://lists.xml.org/archives/xml-dev/200307/msg00885.html
I haven't heard anything official since, but as far
as I know, this
whitespace-handling behaviour has not changed.
--
World-wide on-site corporate, govt. & user group
XML/XSL training.
G. Ken Holman
mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.
http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0
+1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness
http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:
http://www.CraneSoftwrights.com/legal
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail
--~------------------------------------------------------------------
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>
--~--