Subject: Re: [xsl] Result still indented despite indent="no"|
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Sun, 20 Feb 2005 18:12:43 +1100
On Sat, 19 Feb 2005 22:55:03 -0800 (PST), Mukul Gandhi <mukul_gandhi@xxxxxxxxx> wrote: > 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 It's better not only to "feel", but also to read well. The spec also says just a few lines further: "Initially , the set of whitespace-preserving element names contains all element names." This, combined with rule 1) means that your conclusion is contrary to the rules established by the XSLT 1.0 spec. BTW, the exact link to the discussed rules is: http://www.w3.org/TR/1999/REC-xslt-19991116#strip Cheers, Dimitre Novatchev.