[Home] [By Thread] [By Date] [Recent Entries]

  • From: "G. Ken Holman" <gkholman@C...>
  • To: Roger L Costello <costello@m...>,"xml-dev@l..." <xml-dev@l...>
  • Date: Fri, 11 Feb 2022 10:31:28 -0500

Well, there is no need to confuse everyone else.

The specification is quite clear. When you ask for the value of a sequence of text nodes, they are concatenated without marking any original boundaries. When you ask for the value of a sequence of strings, they are joined separated by a single space, and there are no marks of any original boundaries. The spec is clear that text nodes are treated differently than strings.

What is confusing about that?

As for how many text nodes there are, a "leaf element" is not equivalent to a "leaf node". The element can be made up of text, comments, and processing instructions as children, depending on the syntax you use to mark up that element.

What is confusing about that?

In all of your exclamations, you haven't stated how what you see is in any way contrary to what the specifications or training material tell you to expect.

Why muddy the waters?

. . . . . Ken

At 2022-02-11 15:12 +0000, Roger L Costello wrote:
Hi Folks,

Okay, I'm confused.

I thought that a leaf element can have either zero or one text node.

Apparently a leaf element can have 0, 1, 2, 3, 4, 5, 6, ... text nodes!

For example, how many text nodes does this leaf element have?

<Test>abc<!-- blah -->def</Test>

Answer: It has two text nodes:

text()[1] and text()[2]

How do I know this? Well, I executed this XPath:

Test/text()[1]

which resulted in this output:

abc

and this XPath:

Test/text()[2]

resulted in this output:

def

To confirm that there are indeed two text nodes within the <Test> element, I used XPath to count the number of text nodes:

count(Test/text())

That produced this output:

2

In fact, the text node containing "def" *follows* the text node containing "abc", as this XPath shows:

Test/text()[1]/following::text()

That gave this output:

def

Interesting!

But the really interesting thing is that if I create an XPath to answer this question: What is the text in the <Test> element?

Test/text()

Shockingly, I get this output:

abcdef

Huh???

The previous tests determined that there are two separate text nodes, so how can there now be only one text node?

I am confused.

/Roger




_______________________________________________________________________

XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@l...
subscribe: xml-dev-subscribe@l...
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php

--
Contact info, blog, articles, etc. http://www.CraneSoftwrights.com/x/ |
Check our site for free XML, XSLT, XSL-FO and UBL developer resources |
Streaming hands-on XSLT/XPath 2 training class @US$125 (5 hours free) |
Essays (UBL, XML, etc.) http://www.linkedin.com/today/author/gkholman |



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member