Hi all,
I have one DTD fragment, base.dtd, that contains a bunch of useful
element definitions (say an element named "base"), and two DTD
fragments, a.dtd and b.dtd, that each build on base.dtd and defines a
few more elements. I use an entity to include base.dtd in a.dtd and
b.dtd. For example, in a.dtd:
<!ENTITY % include.base SYSTEM "base.dtd">
%include.base
<!ELEMENT a (base+)>
In b.dtd:
<!ENTITY % include.base SYSTEM "base.dtd">
%include.base
<!ELEMENT b (#PCDATA|base)* >
In my XML documents, if I just want to use element a (or b), I simply
need to entity-include a.dtd, and that will automatically include
base.dtd, which is nice.
However, the trouble comes in when I entity-include both a.dtd and
b.dtd. The problem is that the element "base" will be included twice
(once via a.dtd->base.dtd and another time via b.dtd->base.dtd). Note
that multiple definitions of the "include.ba se" entity is fine (as per
XML standard), but multiple definitions of any element is disallowed.
I explored a few workarounds but couldn't find any clean solution (for
example, something that resembles C/C++'s #ifndef and #define). Any
suggestions will be appreciated!
--- Jun Y.
I have one DTD fragment, base.dtd, that contains a bunch of useful
element definitions (say an element named "base"), and two DTD
fragments, a.dtd and b.dtd, that each build on base.dtd and defines a
few more elements. I use an entity to include base.dtd in a.dtd and
b.dtd. For example, in a.dtd:
<!ENTITY % include.base SYSTEM "base.dtd">
%include.base
<!ELEMENT a (base+)>
In b.dtd:
<!ENTITY % include.base SYSTEM "base.dtd">
%include.base
<!ELEMENT b (#PCDATA|base)* >
In my XML documents, if I just want to use element a (or b), I simply
need to entity-include a.dtd, and that will automatically include
base.dtd, which is nice.
However, the trouble comes in when I entity-include both a.dtd and
b.dtd. The problem is that the element "base" will be included twice
(once via a.dtd->base.dtd and another time via b.dtd->base.dtd). Note
that multiple definitions of the "include.ba se" entity is fine (as per
XML standard), but multiple definitions of any element is disallowed.
I explored a few workarounds but couldn't find any clean solution (for
example, something that resembles C/C++'s #ifndef and #define). Any
suggestions will be appreciated!
--- Jun Y.
Comment