Entity processing (was new msxml behaviour)

Tim Bray tbray at textuality.com
Wed Nov 5 08:35:32 GMT 1997


At 12:41 PM 05/11/97 +1300, Scott Cooper wrote:
>the new msxml contains this code ...
>	if (sb.length() > 0)
>       	sb.append(' ');
>notice the appending of a space. is this appropriate? 

Recent WG decisions require that parameter entity expansions (outside
of entitity values) should be forced to match an even number tokens
simply by appending & prepending spaces to their expansion; I 
hypothesize that this is what the msxml code is doing.

Of course, this can't be done when building the replacement text
of an internal text entity.  To aid in sorting this, out, I attach
a couple of my test files; credit is due to Henry Thomson, Michael
Sperberg-McQueen, and likely others for helping cook these up.

I *think* that the behavior of Lark 0.97 on these is per the spec.
But it's there's enough hair on this set of problems that there's
lots of ways I could be wrong. -Tim
-------------- next part --------------
<?XML version='1.0'?>
<!DOCTYPE test [
<!ELEMENT test (#PCDATA) >
<!ENTITY % xx '&#37;zz;'>
<!ENTITY % zz '&#60;!ENTITY tricky "error-prone" >' >
%xx;
<!ENTITY example "<p>An ampersand (&#38;#38;) may be escaped
 numerically (&#38;#38;#38;) or with a general entity
 (&amp;amp;).</p>" >
<!ENTITY % pub    "&#Xc9;ditions Gallimard" >
<!ENTITY   rights "All rights reserved" >
<!ENTITY   book   "La Peste: Albert Camus, &#Xa9; 1947 %pub;. &rights;" >
<!ENTITY   rights " - all rights reserved - ">
]>
<test>
<e1>This sample shows a &tricky; method.</e1>
<e2>&example;</e2>
<e3>&book;</e3>
</test>
-------------- next part --------------
<!DOCTYPE FOO
[
 <!ENTITY lt "&#60;">
 <!ENTITY  b "{Value of b}">
 <!ENTITY weird 'fo&#77;o&lt;bar'>
 <!ENTITY % d '{Value of d}'>
 <!ENTITY % defatt1 'DEF1 CDATA "{default 1}"'>
 <!ENTITY % bazatt '<!ATTLIST BAZ BIFF CDATA "QuidNunc" BAR CDATA "xyxy">'>
 <!ELEMENT FOO - - (#PCDATA|BAZ|BUM)*>
 <!ELEMENT BAZ - - (#PCDATA)>
 <!ELEMENT BUM - - (#PCDATA)>
 <!ATTLIST FOO BAR CDATA "A&b;C%d;E&#77;F">
         
 <!ATTLIST FOO BAR CDATA "Should not appear"> 
 %bazatt;
 <!ATTLIST BAZ %defatt1;> 
]>
<!--<FOO test='KL&#77;NO'>hi &lt;there-->
<FOO>
<BAZ BAR="A&b;C%d;E&#77;F"></BAZ>
<BUM>&weird;</BUM>
</FOO>



More information about the Xml-dev mailing list