Re: [xml-dev] How can the content of a leaf element be multiple text nodes?

From
Roger L Costello <>
To
"" <>
Date
2022-02-12T00:31:01Z
ID
<>
Thread
Re: [xml-dev] How can the content of a leaf element be multiple text nodes?
Thank you Michael, Ken, and Liam for your fantastic explanations!

I have one more question, please. 

But first, I would like to summarize what I learned:

Consider this leaf element, in which "abc" and "def" are separated by a space:

<Test>abc def</Test>

How many text nodes are within the <Test> element?

Answer: 1

The text is: "abc def"

Michael Kay said in an earlier post: An element cannot have two adjacent text nodes.

Next, suppose that "abc" and "def" are separated by a comment:

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

Now how many text nodes are within the <Test> element?

Answer: 2

text[1] = "abc" and text[2] = "def"

Suppose that "abc" and "def" are separated by a CDATA section:

<Test>abc<![CDATA[blah]]>def</Test>

Now how many text nodes are within the <Test> element?

Answer: 1

The CDATA section is removed by the parser, so there is just one text string: abcblahdef

Suppose that "abc" and "def" are separated by a PI:

<Test>abc<?foo test?>def</Test>

Now how many text nodes are within the <Test> element?

Answer: 2

The PI is similar to a comment - they both interrupt "abc" and "def"

Lastly, how many text nodes are within this <Test> element?

<Test>abc&amp;def</Test>

Answer: 1

Interesting!

So, what is the text? 

Is it this: abc&def (i.e., the entity is resolved)?

No! 

The text is this: abc&amp;def (the entity is *not* resolved)

Huh? 

Why isn't the entity resolved? 

Why isn't this the text: abc&def (i.e., the entity is resolved)?

/Roger