Why external system entities are not working for me in Chrome, IE or Netscape?
Asked Answered
L

1

1

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

https://mcmap.net/q/67188/-can-we-import-xml-file-into-another-xml-file

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?

Lysine answered 27/3, 2013 at 0:37 Comment(2)
I have edited your title. Please see, "Should questions include “tags” in their titles?", where the consensus is "no, they should not".Mezcaline
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."Bustos
E
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.

Establishment answered 27/3, 2013 at 9:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.