1

I am attempting to replicate the example given in this answer:

https://stackoverflow.com/a/5127928/356011

that illustrates using external entities to include a fragment of XML file in another XML file.

doc.xml:

<?xml version="1.0" standalone="no" ?>
<!DOCTYPE doc [
        <!ENTITY otherFile SYSTEM "otherFile.xml">
        ]>
<doc>
    <foo>
        <bar>&otherFile;</bar>
    </foo>
</doc>

otherFile.xml:

<baz>this is my content</baz>

When I attempt to test this by opening doc.xml in any browser, I just get:

 <doc>
   <foo>
      <bar/>
    </foo>
 </doc>

rendered.

Shouldn't it be rendering the included file, as well?

deadfish
  • 11,996
  • 12
  • 87
  • 136
marathon
  • 7,881
  • 17
  • 74
  • 137
  • 1
    I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Mar 27 '13 at 00:41
  • 1
    I don't think you're doing anything wrong. I think browsers deliberately don't support this. I don't fully understand the reasoning but there's a line the HTML5 spec discussing XHTML parsing that mentions "a desire for user agents to all handle entities in an interoperable fashion without requiring any network access for handling external subsets." – Alohci Mar 27 '13 at 01:30

1 Answers1

5

The reason it isn't working is that browsers don't fully support XML. They only support it with restrictions, such as "no external entities". I don't know why.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164