Subject: Re: Entities in XHTML

From: "A. Pagaltzis" <[email-masked]>
Date: Wed, 20 Jun 2007 01:58:19 +0200

* Joe Cheng <[email-masked]> [2007-06-19 21:35]:
> * James M Snell <[email-masked]> [2007-06-19 21:30]:
> > * Joe Cheng <[email-masked]> [2007-06-19 21:05]:
> > > How should implementers deal with entities in XHTML
> > > payloads? I'm sure this is a generic XML question that many
> > > on this list have dealt with before and was wondering if
> > > there is some consensus as to the best practice.
> > > 
> > > As I understand it, you can't just slap in a &copy; into an
> > > XML document and expect it to be interpreted as the
> > > copyright symbol. You need to declare the entity
> > > explicitly, or bring in a DTD, or use the &#nnn; form. Is
> > > that right?
> > 
> > Folks should be using the numeric character references rather
> > than the entities.
> 
> Thanks, I'm glad I asked--that would not have been my guess.
> 
> Is that a fairly uncontroversial stance these days? I have been
> surprised at how much some users are concerned about the
> aesthetics of their (X)HTML (although I admit I have not heard
> anything specifically about the use of named vs. numeric
> entities).

If you’re including unescaped well-formed XHTML with
type="xhtml", then you *can’t* include named entities, because
there’s no DTD on the document to declare them, so using them
would just render the document malformed. If the document is in
some national encoding like US-ASCII or Latin-1, then you don’t
*have* any other choice than using numeric char refs.

If the document is in UTF-8 or another Unicode encoding, I
wouldn’t bother with NCRs at all and would just include the
literal characters.

If you’re putting escaped tagsoup in type="html" content, then
of course you can just include double-escaped named entities.

(This is really an issue for atom-syntax, btw, not atom-protocol;
re-routing there.)

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

---

From: Elliotte Harold <[email-masked]>
Date: Thu, 21 Jun 2007 07:37:32 -0400

>>> Folks should be using the numeric character references rather

How 20th century.

Aside from reserved characters like < and &, folks should not be using 
entity references or numeric character references at all.

THEY SHOULD BE TYPING THE CHARACTER!

Is it all that hard to write a © or an é or pretty much any other 
character you need regularly? No, it isn't. And locally rare characters 
can be inserted with any of various Unicode input palettes shipped with 
modern OSs and text editors.

An actual character like © is far prettier than either &#xA4; or &copy;.

Any software that still doesn't support such basic functionality in 2007 
should be tossed on the recycle bin.

Of course, it still annoys me that much software that can support UTF-8 
such as Eclipse still ships with broken, non-interoperable default 
encodings. We need to fix that. Please report that bug wherever you find 
it, and vote for it in bug trackers everywhere.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=108668
https://bugzilla.mozilla.org/show_bug.cgi?id=333859

Also see

http://www-128.ibm.com/developerworks/xml/library/x-utf8/

-- 
Elliotte Rusty Harold  [email-masked]
Java I/O 2nd Edition Just Published!
http://www.cafeaulait.org/books/javaio2/
http://www.amazon.com/exec/obidos/ISBN=0596527500/ref=nosim/cafeaulaitA/

---

From: Martin Duerst <[email-masked]>
Date: Fri, 22 Jun 2007 17:05:35 +0900

At 20:37 07/06/21, Elliotte Harold wrote:
>Aside from reserved characters like < and &, folks should not be using entity references or numeric character references at all.

I fully agree.

Another exception occasionally are things such as &nbsp;, where
one might prefer explicitness over direct visibility.

Regards,    Martin.

#-#-#  Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University
#-#-#  http://www.sw.it.aoyama.ac.jp       mailto:[email-masked]

---

From: "A. Pagaltzis" <[email-masked]>
Date: Fri, 22 Jun 2007 11:56:14 +0200

> one might prefer explicitness over direct visibility.

You mean &#160;.

:-)

Regards,