XML entity question

I'm starting to agree with those that said we should 
never have allowed entities in XML.  Once again, I'm 
stumped by a question from a colleague.

What happens if someone has the following in their DTD:

<!ENTITY DTDVersion 'v2.0N'>
<!ELEMENT Module (#PCDATA)*>
<!ATTLIST Module
  DTDVersion CDATA #FIXED "&DTDVersion;"
> 

Then exactly what (non-null) value should be assigned to
the DTDVersion attribute on the Module element in an 
instance for the instance to be valid?

The table in "4.4 XML Processor Treatment of Entities and 
References" <http://www.w3.org/TR/REC-xml/#entproc> has
one row for "Reference in DTD" and another for "Reference
in Attribute Value".  Since the "Reference in DTD" 
row says an internal general entity is forbidden, and
it's clear that such are allowed within attribute values
within the DTD, I'm assuming that the "Reference in 
Attribute Value" row is the relevant one.

That would imply that a general entity reference within
an attribute decl within a DTD is governed by "4.4.5 
Included in Literal" <http://www.w3.org/TR/REC-xml/#inliteral>
which says "When an entity reference appears in an attribute 
value...its replacement text MUST be processed in place of 
the reference itself as though it were part of the document 
at the location the reference was recognized...."  But the
phrase "part of the document" confuses me since we are talking
about a DTD.  When does the entity reference get replaced?

Now, suppose instead the DTD reads:

<!ENTITY % DTDVersion 'v2.0N'>
<!ELEMENT Module (#PCDATA)*>
<!ATTLIST Module
  DTDVersion CDATA #FIXED "%DTDVersion;"
> 

Back to the table, do I now use the "Reference in DTD" or 
"Reference in Attribute Value" row?

If the latter, I have the same questions as before.  

If the former, then I'm looking at "4.4.8 Included as PE" 
<http://www.w3.org/TR/REC-xml/#as-PE> which says "When a 
parameter-entity reference is recognized in the DTD and 
included, its replacement text MUST be enlarged by the 
attachment of one leading and one following space (#x20) 
character...."  But that doesn't seem to make sense in
this case.  Spaces aren't really going to be added here,
are they?

paul

Received on Thursday, 30 August 2007 14:12:38 UTC