Attribute normalisation and character entities

Thomas B. Passin tpassin at idsonline.com
Tue Jan 25 20:48:27 GMT 2000


Richard Tobin wrote, following uo on a number of previous posts:

> Another strangeness: if my interpretation of section 3.3.3 is right,
> and character entities for tab, cr and lf are not normalised to spaces,
> then this is a valid NMTOKENS attribute:
>
>   "foo 	 bar"
>
> but is not normalised to have a space character between the two
> tokens, which is "obviously" intended.
>
> It seems to me that it would make sense for tab, cr and lf entities to
> get normalised to spaces (and then compressed to a single space) for
> non-CDATA attributes.
>

The XML rec says

"4.4.5 Included in Literal
When an entity reference appears in an attribute value, or a parameter
entity reference appears in a literal entity value, its replacement text is
processed in place of the reference itself as though it were part of the
document at the location the reference was recognized, except that a single
or double quote character in the replacement text is always treated as a
normal data character and will not terminate the literal. "

This says that the processor will replace the entity with its value when the
entity is used in the value of an attribute.  Seems clear enough.

The rec also says

"3.3.3 Attribute-Value Normalization
Before the value of an attribute is passed to the application or checked for
validity, the XML processor must normalize it as follows:

a character reference is processed by appending the referenced character to
the attribute value
an entity reference is processed by recursively processing the replacement
text of the entity
a whitespace character (#x20, #xD, #xA, #x9) is processed by appending #x20
to the normalized value, except that only a single #x20 is appended for a
"#xD#xA" sequence that is part of an external parsed entity or the literal
entity value of an internal parsed entity
other characters are processed by appending them to the normalized value
If the declared value is not CDATA, then the XML processor must further
process the normalized attribute value by discarding any leading and
trailing space (#x20) characters, and by replacing sequences of space (#x20)
characters by a single space (#x20) character.

All attributes for which no declaration has been read should be treated by a
non-validating parser as if declared CDATA. "

This clearly says that normalizing down to a single space IS part of the
processing when an entity is used in an attribute value.


Tom Passin









xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ or CD-ROM/ISBN 981-02-3594-1
Unsubscribe by posting to majordom at ic.ac.uk the message
unsubscribe xml-dev  (or)
unsubscribe xml-dev your-subscribed-email at your-subscribed-address

Please note: New list subscriptions now closed in preparation for transfer to OASIS.





More information about the Xml-dev mailing list