Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
600 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 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...