I'll get straight to the point:
Is there a better way to include a set of commonly used character entities in a DocBook document? Because having to type out —
rather than —
all the time is really rather annoying.
What I had:
<!DOCTYPE chapter [
<!ENTITY ndash "–">
<!ENTITY mdash "—">
<!ENTITY lsquo "‘">
<!ENTITY rsquo "’">
<!ENTITY hellip "…">
<!ENTITY sbquo "‚">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
]>
<chapter xmlns="http://docbook.org/ns/docbook" version="5.0"
xml:id="fancy-chapter">
...
</chapter>
This didn't seem very DRY to me, so I figured I'd try something else…
What I did:
<!DOCTYPE chapter [
<!ENTITY % type SYSTEM "type.xml">
%type;
]>
<chapter xmlns="http://docbook.org/ns/docbook" version="5.0"
xml:id="fancy-chapter">
...
</chapter>
type.xml:
<!ENTITY ndash "–">
<!ENTITY mdash "—">
<!ENTITY lsquo "‘">
<!ENTITY rsquo "’">
<!ENTITY hellip "…">
<!ENTITY sbquo "‚">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
Slight improvement, but isn't there a single line solution, or a processor instruction one could call to say "Hey, look at this file for all those fancy references you can't find"?
I suppose this could be done via some form of local superset of the DocBook schema somehow, no?
Even simpler would be not using entities at all. Instead, just write the characters as such. after all, XML is Unicode by default.
If you explicitly want to use entities, then your current approach is practically the same as the one recommended in the Docbook FAQ.