With all of the other hidden features questions on SO, how can we forget XML?
What are the hidden features of XML, DTD and XML Schema?
With all of the other hidden features questions on SO, how can we forget XML?
What are the hidden features of XML, DTD and XML Schema?
Entities can be used to centralize content and make maintenance easier.
One cool trick that I learned from G. Ken Holman was that entity references can also be used for easier namespace management.
An easy and robust method of maintaining URI strings is through XML general entities.
Consider the following namespaces.ent entity file declaring both an input namespace URI and a stylesheet maintenance URI:
<!--maintenance vocabularies-->
<!ENTITY ns-xyz "urn:x-crane:xyz">
<!--end of file-->
These strings can be brought into a stylesheet through a DOCTYPE declaration at the start of the stylesheet:
<!DOCTYPE xsl:stylesheet SYSTEM "namespaces.ent">
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:abc="&ns-abc;"
xmlns:xyz="&ns-xyz;"
exclude-result-prefixes="xyz"
version="1.0">
...
<xsl:element name="def" namespace="&ns-abc;">
...
By externalizing the namespace values(and other common values) to a shared file and managed as general entities, multiple XML files can share the declared entity values. Then all of the namespace declarations in all of the XML files referencing those entities can be updated with a single update to the one file, rather than find/replace the namespace string value in each and every XML file.
This can make maintenance operations faster, easier, and more reliable for large libraries of XML and XSL files.