[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Why is < illegal in an attribute value but theequivalent h

  • From: "Liam R. E. Quin" <liam@fromoldbooks.org>
  • To: Roger L Costello <costello@mitre.org>, "xml-dev@l..." <xml-dev@l...>
  • Date: Wed, 16 Mar 2022 23:21:26 -0400

Re:  Why is < illegal in an attribute value but theequivalent h
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


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.