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

  • From: David Carlisle <d.p.carlisle@g...>
  • To: Roger L Costello <costello@m...>
  • Date: Tue, 3 May 2022 15:29:46 +0100



On Tue, 3 May 2022 at 13:28, Roger L Costello <costello@m...> wrote:

After XML parsing is complete, every occurrence of &amp; will have been replaced by &

 

  1. True
  2. False

 

Scroll down to see the answer ……………

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

False! If the &amp; is within a CDATA section or within a comment, then it will be unchanged. Otherwise, it will be changed.

 

Lesson Learned: An XML lexer/parser must perform conditional processing:

 

IF (&amp; is within a CDATA section or comment) THEN

    OUTPUT(“&amp;”)

ELSE

    OUTPUT(“&”)


That's a strange way to describe the condition (and I doubt it corresponds to real code)
It's not that you scoop up `&amp;` then decide what to do with it, rather it is

if & is within a CDATA section or comment or PI ....
   &
else
 start scanning for an entity or character reference


Your description would need separate tests for &amp;  and &rightarrow; and &eacute; ....

David



  • References:
    • XML Quiz
      • From: Roger L Costello <costello@m...>

[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