Re: [xsl] Problems matching end-of-line character

Subject: Re: [xsl] Problems matching end-of-line character
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 10 Aug 2005 23:59:38 +0100
>  Specifically whats the difference
> between a character reference, and an entity reference?

semantically one references an entity (something that os declared with an
<!ENTITY declaration (like EOL in your case) and the other refernces a
character by unicode number, these aren't declared anywhere, they are
just core syntax.

syntactically an entity reference is & followed by a name folowed by a
semi colon, a character reference is & followed by a # follwed be either
a decimal or hex number followed by ;.

The important thing here is when the references get replaced by the
objects they reference.
If you go
<!ENTITY foo "&bar;">
then the replacement text of foo is &bar; (that is, 5 characters).
when &foo; is used it is replaced by those characters and parsing
restarts from the start of the replacement text, so at that point
&bar; is parsed as an entity reference and replaced by its definition.
(s it's not an error to refer to an undefined entity in an entity
definition if that entity is never referenced. If bar is not defined
that is not an error unless &foo; is used.

Conversely

<!ENTITY foo "&#10;">

character references are expanded inline, the replacement text of foo is
the single character with number 10.

in the case of white space normalisation in attributes, character
references play a special role to quote the white space, but entity
references play no role at all they are expanded before the
normalisation starts.

more involved examples of the interplay of this timing difference in
http://www.w3.org/TR/REC-xml/#sec-entexpand

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread