[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] How can the content of a leaf element be multiple textnodes?
- From: Roger L Costello <costello@mitre.org>
- To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
- Date: Sat, 12 Feb 2022 00:31:01 +0000
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&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&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
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]