text: Q:
  
  Parameter entities in internal DTD
  
  I have the following simple.dtd:
  <!ENTITY % placeholder "my, element, list">
  <!ELEMENT root (%placeholder;)>
  <!ELEMENT my (#PCDATA)>
  <!ELEMENT element (#PCDATA)>
  <!ELEMENT list (#PCDATA)>
  
  and the simple.xml:
  <?xml version="1.0" encoding="UTF-8" ?>
  <!DOCTYPE root SYSTEM "simple.dtd">
  
  <root>
      <my />
      <element />
      <list />
  </root>
  
  This works and is valid.
  But the exact same DTD inline:
  <?xml version="1.0" encoding="UTF-8" ?>
  <!DOCTYPE root [
          <!ENTITY % placeholder "my, element, list">
          <!ELEMENT root (%placeholder;)>
          <!ELEMENT my (#PCDATA)>
          <!ELEMENT element (#PCDATA)>
          <!ELEMENT list (#PCDATA)>
  ]>
  
  <root>
      <my />
      <element />
      <list />
  </root>
  
  fails with the error:
  $ xmllint --valid simple.xml
  simple.xml:4: parser error : ContentDecl : Name or '(' expected
          <!ELEMENT root (%placeholder;)>
                          ^
  simple.xml:4: parser error : expected '>'
          <!ELEMENT root (%placeholder;)>
                          ^
  Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
  
   %placeholder; 
                ^
  Entity: line 1: 
  my, element, list
  ^
  Entity: line 1: parser error : DOCTYPE improperly terminated
   %placeholder; 
                ^
  Entity: line 1: 
  my, element, list
  ^
  Entity: line 1: parser error : Start tag expected, '<' not found
   %placeholder; 
                ^
  Entity: line 1: 
  my, element, list
  ^
  
  Why is this the case?
  
  A:
  
  In the internal subset of DTD, references to parameter entities are not allowed  within markup declarations. You have to use an external DTD, i.e. the separate file. This is documented as a well-formedness constraint in the XML specification here.
  
  A:
  
  The spec states:
  
  In the internal DTD subset, parameter-entity references must not occur
    within markup declarations; they may occur where markup declarations
    can occur. (This does not apply to references that occur in external
    parameter entities or to the external subset.)
  
  So in the internal subset, you can't reference the parameter entity from within a markup declaration. 
  You can reference it from the same level as a markup declaration though.
  That means you'd have to declare/reference the parameter entity like this:
  <!DOCTYPE root [
      <!ENTITY % placeholder "<!ELEMENT root (my, element, list)>">
      %placeholder;
      <!ELEMENT my (#PCDATA)>
      <!ELEMENT element (#PCDATA)>
      <!ELEMENT list (#PCDATA)>
  ]>
  <root>
      <my />
      <element />
      <list />
  </root>
  
  