[
Lists Home |
Date Index |
Thread Index
]
- To: xml-dev@lists.xml.org
- Subject: Re: [xml-dev] Allowed PEReference usages
- From: Arjun Ray <aray@nyct.net>
- Date: Tue, 01 Jul 2003 22:32:40 +0000
- In-reply-to: <Law11-F113g1WTp6AVj00032e97@hotmail.com>
- References: <Law11-F113g1WTp6AVj00032e97@hotmail.com>
"Brett Kail" <junkaddr@hotmail.com> wrote:
| I've been reading the XML specs for some time now, and I am completely
| stumped attempting to understand the restrictions on PEReferences.
I don't blame you. Each time I read the spec, the treatment of PEs seems
less clear. I tend to view PEs as they are used in SGML; the XML spec is
supposed to place further restrictions - that is, I recall the discussions
while the spec was being developed.
In general, there are three rules to bear in mind:
1. Non-recursion: the replacement text of a PE can't have a reference
to the same PE, directly or indirectly.
2. Integral declarations: a declaration must begin and end in the same
entity - hence the replacement text of PEs can't cause declaration
boundaries to be crossed.
3. Integral tokens in declarations: a token (or "parameter" in SGML
jargon - whence the name "parameter entity") in a declaration can't
be "split" such that only part of it is an as yet unexpanded PEref.
Your examples all seem to deal with the third rule.
| Could someone please comment which pairs of definition/uses below are
| allowed? An explanation or pointer to the relevant portion of the
| spec as to *why* the usage is valid/invalid would be extremely
| helpful.
|
| <!ENTITY % pe "!ELEMENT e ANY">
| <%pe;>
No, because "<!ELEMENT" counts as one integral token. Note: This is not
*strictly* true, but it helps to think of the keyword following the MDO
("<!") as part of the same token.
| <!ENTITY % pe "ELEMENT e ANY">
| <!%pe;>
No, same problem.
| <!ENTITY % pe "ELEMENT">
| <!%pe; e ANY>
Ditto.
| <!ENEITY %pe " ">
| <!ELEMENT%pe;e ANY>
Permissible in SGML - maintains integral character of relevant parameters.
Probably okay in XML.
| <!ENTITY % pe "!ELEM">
| <%pe;ENT e ANY>
No, same problem
| <!ENTITY % pe "ELEM">
| <!%pe;ENT e ANY>
Ditto.
| <!ENTITY % pe "Y">
| <!ELEMENT e AN%pe;>
Same problem: "ANY" is one token.
| <!ENTITY % pe "ELEMENT e">
| <!%pe; ANY>
No - "<!ELEMENT" is being split up.
| <!ENTITY % pe "x 'value'">
| <!ENTITY % %pe;>
Permissible in SGML - should be okay for XML.
| <!ENTITY % pe "% x 'val">
| <!ENTITY %pe;ue'>
No. The replacement text between the single quotes counts as one token,
and is being split here.
Note that the integral token restriction doesn't apply when using PErefs
to paste together the content of replacement text in what is effectively a
single parameter in a PE declaration. (In fact, that is how you might
"construct" tokens if needed.)
| In addition, how does one declare a PE that contains a literal '%'?
Use a character reference in the replacement text.
| How about does one declare a PE that contains both a single and double
| quote?
Ditto.
| Assuming that it is possible to declare a PE named 'percent' with a
| literal '%', is the following allowed?
|
| <!ENTITY %percent; x "value">
Permissible in SGML - should be okay in XML.
Note also that there are further restrictions in XML on PE usage in an
internal subset.
|