Next in thread → Next in month →

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

From
G. Ken Holman <>
To
Roger L Costello <>, "" <>
Date
2022-02-12T13:47:57Z
ID
<>
Thread
Re: [xml-dev] How can the content of a leaf element be multiple text nodes?
Had you run:

   string-length(/Test)

... on:

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

... you would have received a value of 7. That would have confirmed 
the internal representation of the characters is not marked up.

I hope this is helpful.

. . . . Ken

At 2022-02-12 00:31 +0000, Roger L Costello wrote:
>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


--
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 |
Next in thread → Next in month →