And you do not even need architectural forms. Here is a very
simple pattern for doing everything your example does using
a single DTD and standard SGML! (The suffixes "-content"
and "-attributes" are reserved for use in patterns. The
attribute "is-a" is reserved to allow inheritence labelling.)
<!DOCTYPE animal-friends
[
<!-- Handle animal friends ================================= -->
<!ENTITY % animal-friends-content
" ( pet | cat | dog )+")
<!ENTITY % animal-friends-attributes
" ">
<!ELEMENT animal-friends
( %animal-friends-content; )>
<!ATTLIST animal-friends
%animal-friends-attributes;
>
<!-- Handle pets =========================================== -->
<!ENTITY % pet-content
"ANY" >
<!ENTITY % pet-attributes
" name ID #IMPLIED
owner ID #IMPLIED
is-a CDATA #FIXED 'pet' " > <!-- does not handle multiple inheritance! -->
<!ELEMENT pet
( %pet-content; ) >
<!ATTLIST pet
%pet-attributes;
>
<!-- Handle cats =========================================== -->
<!ENTITY % cat-contents
( " (kittens)? " )
<!ENTITY % cat-attributes
" lives NMTOKEN #IMPLIED ">
<!ELEMENT cat
( %pet-content;, %cat-contents; )
<!ATTLIST cat
%pet-attributes;
%cat-attributes;
>
<!-- Handle dogs =========================================== -->
<!ENTITY % dog-contents
( " (puppies)? " )
<!ENTITY % dog-attributes
" breed CDATA #IMPLIED ">
<!ELEMENT dog
( %pet-content;, %dog-contents; )
<!ATTLIST dog
%pet-attributes;
%dog-attributes;
>
]>
<animalFriends>
<cat name="Fluffy" lives='9'/>
<pet name="Diego"/>
<dog name="Gromit" owner='Wallace' breed='mutt'/>
</animalFriends>
If you want multiple inhereitance, then you can just
define a different suffix, and search through attributes
based on that to collect the inheritance tree. I can
provide an example if anyone is interested.
Anyone who is aware of the pattern can see this and implement
it just as easily as they could using XML-data's syntax,
but without breaking SGML compatibility, which generating
new element types outside declarations does.
Rick Jelliffe