0xbe5077ed
0xbe5077ed

Reputation: 4765

Should an XML file included via <!ENTITY ... SYSTEM ...> have an <?xml?> declaration?

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...

Upvotes: 2

Views: 108

Answers (1)

Boldewyn
Boldewyn

Reputation: 82804

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.

Upvotes: 1

Related Questions