Re: Why is < illegal in an attribute value but the equivalent hex and decimal character entities are legal?

"Liam R. E. Quin" <[email protected]>
Newsgroups gmane.text.xml.devel
Message-ID <[email protected]>
On Wed, 2022-03-16 at 23:00 +0000, Roger L Costello wrote:
> 
> 1. Why is it that < is illegal but the equivalent hex and decimal
> character entities are legal?

Because numeric character references are always treated as data when
they are read, not markup.

Note that they are expanded at that point, so if you use them in an
entity replacement value they become regular characters when the entity
is expanded, and can be interpreted as markup.

> 2. Are there unusual things that are legal (or illegal) to put in an
> attribute value?

Attribute values can contain the word "Belgium". [1]


> 3. (Extra credit) Do you have C code that converts a hex or decimal
> character entity to its character?

It isn't hard to write, assuming you use int32 (i.e. unsigned long) for
your characters and not e.g. char or unsigned char.  The sscanf)(
function comes to mind, with %ld or %lx as appropriate. Note e.g.
&#196608; is legal.



> 
> 
> 
>     <Test foo="&#x3C;"/>        <!-- x3C = < ........... Why is this
> Okay? -->

Because numeric character references are always interpreted as data,
not markup.


Liam

-- 
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org

_______________________________________________________________________

XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: [email protected]
subscribe: [email protected]
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.