2

I have an XML file, file1.xml, and I'm trying to include in it a snippet from file2.xml, like so:

file1.xml

<?xml version="1.0" encoding="utf-8" standalone="no"?>

<!DOCTYPE Context [
    <!ENTITY File2Contents SYSTEM "file2.xml">
]>

<Context>
    &File2Contents;
</Context>

file2.xml

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<Manager path=""/>

Problem

I keep getting odd parser complaints regarding "pseudo attributes" in my file2.xml, so my question is whether that XML declaration is supposed to be in file2.xml, or whether file2.xml is really a properly-formed XML document or more of a standalone snippet file...

0xbe5077ed
  • 4,565
  • 6
  • 35
  • 77

1 Answers1

1

The spec says, that the XML declaration is just fine, it even SHOULD be there:

External parsed entities SHOULD each begin with a text declaration.

Text Declaration
[77]      TextDecl       ::=      '<?xml' VersionInfo? EncodingDecl S? '?>'

The text declaration MUST be provided literally, not by reference to a parsed entity. The text declaration MUST NOT appear at any position other than the beginning of an external parsed entity. The text declaration in an external parsed entity is not considered part of its replacement text.

So it seems, the problem is with the parser.

Boldewyn
  • 81,211
  • 44
  • 156
  • 212
  • Definitely must be with the parser. Weird, too, because deleting the `` declaration in the "snippet" file fixed my problem completely. – 0xbe5077ed May 06 '15 at 20:05