Ken, That’s a good observation, and I like your example as a “my head hurts” case. :-) However, I’m not sure I understand your point about the escaping of the %’s driving this bit of the architecture. As I see it, this doesn’t drive the necessity for the double escaping. If the double escaping didn’t exist, I wouldn’t be blocked from keeping the string from being expanded into an entity reference, since I could just use a single escape. To make sure we’re on the same page, though, I offer this little example: example.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE foo SYSTEM "example.dtd"> <foo> &refEntity; &refEnityWithCharRef; &refEntityWithEscapedCharRef; </foo> example.dtd <!-- Define the parameter entry that will be referenced in embedded uses --> <!ENTITY % anEntity "value"> <!-- do an ordinary parameter entity reference of the same --> <!ENTITY % refEntityPE "<!ENTITY refEntity '%anEntity;'>"> %refEntityPE; <!-- use a character reference to escape the % --> <!ENTITY % refEnityWithCharRefPE "<!ENTITY refEnityWithCharRef '%anEntity;'>"> %refEnityWithCharRefPE; <!-- use an escaped character reference to escape the % --> <!ENTITY % refEntityWithEscapedCharRefPE "<!ENTITY refEntityWithEscapedCharRef '&#37;anEntity;'>"> %refEntityWithEscapedCharRefPE; The output is: ~/> xmllint --noent --loaddtd example.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE foo SYSTEM "example.dtd"> <foo> value value %anEntity; </foo> Is this what you are thinking? If so, it seems to me that if the double escaping didn’t exist, then refEnityWithCharRefPE would be sufficient to get the string “%anEntity;”. I do see the double escaping allows things like this <!ENTITY % refEntityWithEmbeddedCharRefPE "<!ENTITY refEntityWithEmbeddedCharRef '%anEntity;'>"> that is, being able to construct an entity name using other entities and char refs. But even without the double escaping that’s still doable, it just requires another entity. Thank you for contributing to the discussion of this puzzling bit of the standard and helping me think through weird cases more. david
|