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] Weird XML rules



On Sat, 19 Mar 2022 at 13:45, Roger L Costello <costello@mitre.org> wrote:
On Thursday, Liam Quin wrote:

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

If the word "numeric" is removed from that sentence does the sentence still hold true? That is, _all_ character references are treated as data, not markup. True?

there are no non numeric character references, just decimal or hex numeric.
 
For example, just as the numeric character reference &#x3C; is always treated as data, so too the XML character reference &lt; is always treated as data. What that means is:

&lt;  isn't a "character reference"  it's an entity reference to an internal entity which in that case is defined as

<!ENTITY lt     "&#38;#60;">

so the entity value is the character reference &#60;

Internal entities in general expand to markup, if you have

<!ENTITY foo "<b>bar</b>">

then &foo; will eventually parse as the element b with content foo. So &lt; is not interpreted as markup not because it is an entity reference but because its replacement text is a character reference.





<Test foo="&#x3C;"/>
<Test foo="&lt;"/>

are both legal.

To an XML-aware tool, the following all denote the same character. More precisely, they all denote the same code point.

<
&lt;
&#x3C;
&#x3c;
&#x60;

And yet, they are treated differently:

< is illegal in an attribute value because < is treated as markup. But the entity versions are legal in an attribute value because they are treated as data.

< is illegal in an element value because < is treated as markup. But the entity versions are legal in an element value because they are treated as data.

Is this correct?

So, the same character is treated differently purely because of the way the character is lexically represented.

Isn't that weird?

No. Isn't that expected and similar to any other markup or programming language, all of which have ways to access the characters used as syntax just as normal characters in strings?

 

Is there ever a case where an entity version is not treated as data; rather, it is treated as markup?

the replacement text of entity references  are always parsed as markup. In the case of lt the markup is &#60; so produces the character <



/Roger


David
 
_______________________________________________________________________

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



[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