I am wondering whether there is a standard way to extend a DTD or whether the only way to validate a document is to add all the necessary extensions in the XML file.
I have a system of plugins that are generally organized like packages in a Linux installation (i.e. plugins can depend on one or more plugins, loops are not allowed):
+----------------------+
+-->| Editor |<--+
| +----------------------+ |
| |
+-----------------+ +-----------------+
| Locale | | Image |
+-----------------+ +-----------------+
^ ^
| |
| +----------------------+ |
+---| GeoMap |---+
+----------------------+
So, what I have is a DTD in the Editor plugin with, for example, a widget tag that has an attribute named auto-save like this:
<!ELEMENT widget (value|preset|default|state)*>
<!ATTLIST widget id ID #REQUIRED
type NMTOKEN #REQUIRED
auto-save (double | html | int8
| date-us | no | string) "string">
The fact is that when I add the locale, I now want the auto-save attribute to also support a type such as locale-date which is not specific to the US.
Similarly, the Image plugin may want to add an image type and the GeoMap plugin could use geo-location.
So in the end, the ATTLIST auto-save should look like this (obviously, the order does not matter):
auto-save (double | html | int8 | date-us | no
| string | locale-date | image | geo-location) "string"
Even when defining multiple DTDs in an XML file (xmlns=... attributes in the root tag), I do not think you can do that, can we?
Right now I can add the types in the editor.dtd, but that's obviously wrong to define the locale, image, and geomap types when those plugins may not be available in your graph...
The one other solution I can think of would be to use XSD, but even with that format, how do I go by to add sub-additions of attributes and tags?
DTDs are not extensible. But at the same time, XML schemas can be used which are extensible.