XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Why is < illegal in an attribute value but theequivalent hex and decimal character entities are legal?

> 3. (Extra credit) Do you have C code that converts a hex or decimal character entity to its character? E.g., &#x41 --> C code --> 'A'

Just cast to char:

(char)0x41

(char)65



image.png

Thanks,
Dimitre

On Wed, Mar 16, 2022 at 4:00 PM Roger L Costello <costello@mitre.org> wrote:
Hi Folks,

For the parser that I am building I need to be sure that I know exactly what can (and can't) go within an attribute value. For example, can an attribute value contain &amp;? (Yes) Can an attribute value contain the greater-than symbol? (Yes)

I created tests to see what characters are legal and what are illegal in an attribute value. See below.

Questions:
1. Why is it that < is illegal but the equivalent hex and decimal character entities are legal?
2. Are there unusual things that are legal (or illegal) to put in an attribute value? For instance, you can't put a CDATA section or a PI in an attribute value, right?
3. (Extra credit) Do you have C code that converts a hex or decimal character entity to its character? E.g., &#x41 --> C code --> 'A'

<Tests>
    <Test foo="&amp;"/>         <!-- Okay -->
    <Test foo="&lt;"/>                  <!-- Okay -->
    <Test foo="&gt;"/>          <!-- Okay -->
    <Test foo="&quot;"/>        <!-- Okay -->
    <Test foo="&apos;"/>        <!-- Okay -->
    <Test foo="'"/>                     <!-- Okay --> 
    <Test foo="""/>                      <!-- Error -->
    <Test foo="<"/>                     <!-- Error -->
    <Test foo="&#x3C;"/>        <!-- x3C = < ........... Why is this Okay? -->
    <Test foo="&#60;"/>         <!-- 60  = < ........... Why is this Okay? -->
    <Test foo=">"/>                     <!-- Okay -->
    <Test foo="&#x0;"/>         <!-- x0 = NUL ........... Error -->
    <Test foo="&#x1;"/>         <!-- x1 = SOH ........... Error -->
    <Test foo="&#x2;"/>         <!-- x2 = STX ........... Error -->
    <Test foo="&#x3;"/>         <!-- x3 = ETX ........... Error -->
    <Test foo="&#x4;"/>         <!-- x4 = EOT ........... Error -->
    <Test foo="&#x5;"/>         <!-- x5 = ENQ ........... Error -->
    <Test foo="&#x6;"/>         <!-- x6 = ACK ........... Error -->
    <Test foo="&#x7;"/>         <!-- x7 = BEL ........... Error -->
    <Test foo="&#x8;"/>         <!-- x8 = BS ........... Error -->
    <Test foo="&#x9;"/>         <!-- x9 = TAB ........... Okay -->
    <Test foo="&#xA;"/>         <!-- xA = LF ........... Okay -->
    <Test foo="&#xB;"/>         <!-- xB = VT ........... Error -->
    <Test foo="&#xC;"/>         <!-- xC = FF ........... Error -->
    <Test foo="&#xD;"/>         <!-- xD = CR ........... Okay -->
    <Test foo="&#xE;"/>         <!-- xE = SO ........... Error -->
    <Test foo="&#xF;"/>         <!-- xF = SI ........... Error -->
    <Test foo="&#x10;"/>        <!-- x10 = DLE ........... Error -->
    <Test foo="&#x11;"/>        <!-- x11 = DC1 ........... Error -->
    <Test foo="&#x12;"/>        <!-- x12 = DC2 ........... Error -->
    <Test foo="&#x13;"/>        <!-- x13 = DC3 ........... Error -->
    <Test foo="&#x14;"/>        <!-- x14 = DC4 ........... Error -->
    <Test foo="&#x15;"/>        <!-- x15 = NAK ........... Error -->
    <Test foo="&#x16;"/>        <!-- x16 = SYN ........... Error -->
    <Test foo="&#x17;"/>        <!-- x17 = ETB ........... Error -->
    <Test foo="&#x18;"/>        <!-- x18 = CAN ........... Error -->
    <Test foo="&#x19;"/>        <!-- x19 = EM ........... Error -->
    <Test foo="&#x1A;"/>        <!-- x1A = SUB ........... Error -->
    <Test foo="&#x1B;"/>        <!-- x1B = ESC ........... Error -->
    <Test foo="&#x1C;"/>        <!-- x1C = FS ........... Error -->
    <Test foo="&#x1D;"/>        <!-- x1D = GS ........... Error -->
    <Test foo="&#x1E;"/>        <!-- x1E = RS ........... Error -->
    <Test foo="&#x1F;"/>        <!-- x1F = US ........... Error -->
    <Test foo="&#x20;"/>        <!-- x20 = Space ........... Okay -->
</Tests>

_______________________________________________________________________

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: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they write all patents, too? :)
-------------------------------------
Sanity is madness put to good use.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.
 


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


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS