In a web project, I have a lot of XML files with non-escaped characters. I declare these characters as DTD Entities and include the list of declaration internally in each XML file, like so:
!DOCTYPE article SYSTEM "../../pubmedref/archivearticle.dtd" [
<!ENTITY bull "•">
<!ENTITY copy "©">
... a long list ...
]>
Is there any way I can have these declarations in an external file and import it in the XML files? The XML files are rendered to the browser using XSLT.
FWIW, I've tried referencing a .ent
file but it does not work on any of the browsers.
Normally you would use a parameter entity...
XML File
<!DOCTYPE article SYSTEM "../../pubmedref/archivearticle.dtd" [
<!ENTITY % ents SYSTEM "../../pubmedref/entities.ent">
%ents;
]>
<article>...</article>
Entity File (you could have multiple files)
<!ENTITY bull "•">
<!ENTITY copy "©">
However, most browsers will not resolve an external entity reference so you're stuck with having the entity declarations directly in the internal subset (between [
and ]
in your doctype declaration).
来源:https://stackoverflow.com/questions/31343797/how-to-declare-escape-character-as-dtd-entities-in-external-file-and-import-in-x