Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
597 views
in Technique[技术] by (71.8m points)

xslt - How to declare escape character as DTD Entities in external file and import in XML files

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 "&#8226;">
   <!ENTITY copy "&#169;">
   ... 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 "&#8226;">
<!ENTITY copy "&#169;">

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...