[
Lists Home |
Date Index |
Thread Index
]
Sorry but this is FUD.
XPath 1.0 has no conformance requirement on what data model a parser
needs to generate.
Unless you have an explicit xml:space="preserve" set, the generation of
the datamodel as a consumer of the output of the XML parser (which
always preserves all the whitespace) can drop the boundary whitespace
text nodes.
Best regards
Michael
> -----Original Message-----
> From: G. Ken Holman [mailto:gkholman@CraneSoftwrights.com]
> Sent: Friday, July 25, 2003 10:54 AM
> To: xml-dev@lists.xml.org
> Subject: Re: [xml-dev] Xpath Question
>
> At 2003-07-25 10:42 -0700, Dare Obasanjo wrote:
> >One of our devs just made me question all that's right in the world
with
> >the question below. Given the following XML
> >
> ><pre>
> > <b>bold</b>
> > <i>italic</i>
> ></pre>
> >
> >what is the result of the following XPath expression
> >"count(/pre/child::node())" ?
> >
> >Is the answer 2 or 5?
>
> XPath says it is 5 because of the text nodes. See[1] the Saxon report
> below.
>
> A DTD might say the intervening white-space is ignorable, but XPath
> doesn't
> preserve the concept of ignorable white-space. All white-space in
XPath
> is
> significant, hence burdening a stylesheet writer with indicating which
> elements have ignorable white-space using <xsl:strip-space>.
>
> A big problem teaching XSLT to users of Microsoft products is that IE
> engages MSXML throwing away *all* whitespace, which doesn't conform to
> XPath 1.0. See[2] the IE6 report below.
>
> I hope this helps.
>
> .................... Ken
>
>
> [1] Using Saxon:
>
> T:\ftemp>type dare.xml
> <pre>
> <b>bold</b>
> <i>italic</i>
> </pre>
>
> T:\ftemp>showtree dare.xml
>
> T:\ftemp>type dare.xml.shw
> SHOWTREE Stylesheet - http://www.CraneSoftwrights.com/resources/
> Processor: SAXON 6.5.2 from Michael Kay
> 1 Element 'pre':
> 1.I Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
> 1.1 Text (pre): {
> }
> 1.2 Element 'b' (pre):
> 1.2.I Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
> 1.2.1 Text (pre,b): {bold}
> 1.3 Text (pre): {
> }
> 1.4 Element 'i' (pre):
> 1.4.I Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
> 1.4.1 Text (pre,i): {italic}
> 1.5 Text (pre): {
> }
> T:\ftemp>
>
> [2] Using MSXML through IE6 and copying the screen contents to the
> clipboard:
>
> T:\ftemp>type dare-ms.xml
> <?xml-stylesheet href="showtree.msxsl" type="text/xsl"?>
> <pre>
> <b>bold</b>
> <i>italic</i>
> </pre>
>
> T:\ftemp>copy con nul
> SHOWTREE Stylesheet
> file:///T:/ftemp/dare-ms.xml
> http://www.CraneSoftwrights.com/resources/
>
> Root:
> 1 Proc. Inst. 'xml-stylesheet' (): {href="showtree.msxsl"
type="text/xsl"}
> 2 Element 'pre' ():
> 2.1 Element 'b' (pre):
> 2.1.1 Text (pre,b): {bold}
> 2.2 Element 'i' (pre):
> 2.2.1 Text (pre,i): {italic}
>
> ^Z
> 1 file(s) copied.
>
> T:\ftemp>
>
>
> --
> Upcoming hands-on courses: in-house corporate training available;
> North America public: XSL-FO Aug 4,2003; XSLT/XPath Aug 12, 2003
>
> G. Ken Holman mailto:gkholman@CraneSoftwrights.com
> Crane Softwrights Ltd. http://www.CraneSoftwrights.com/x/
> Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
> ISBN 0-13-065196-6 Definitive XSLT and XPath
> ISBN 0-13-140374-5 Definitive XSL-FO
> ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
> ISBN 1-894049-11-X Practical Formatting Using XSL-FO
> Member of the XML Guild of Practitioners: http://XMLGuild.info
> Male Breast Cancer Awareness http://www.CraneSoftwrights.com/x/bc
>
>
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
|