• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Handling entity references by XML parsers

 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good Day,

My beloved book "XML in a nutshell" of O'Reilly says (on page #18) that XML defines five entity references -

- the less-than sign
- the ampersand
- the greater-than sign
- the straight, double quotation marks
- the apostrophe, or single quote

It says that these entity references & a m p ; and & l t ; are considered markup and when an application parses an XML document, it replaces this particular markup with the actual characters the entity reference refers to. It also says that in addition to these five predefined entity references, you can define others in the document type definition.

So my question is - does it mean that all other entity references in the XML document are left intact by the parsers?

Regards,
Dan
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. If a parser encounters an undeclared entity reference it will throw an exception.
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Paul.

Right, but what about all the "standard" HTML Escape Sequences, such é - & eacute ; , ö - & ouml ; , ò - & ograve ; , ñ - & ntilde ; , etc. ?

Regards,
Dan
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul,

I guess you are absolutely right! I put one of these entities in a valid XML file and tried to open it with Firefox and IE. Both didn't do it. Firefox even said -

XML Parsing Error: undefined entity



Regards,
Dan
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup. HTML is not an XML dialect. (Although XHTML is... you will notice that an XHTML document contains a DTD reference at the top.)
 
Hoo hoo hoo! Looks like we got a live one! Here, wave this tiny ad at it:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic