[
Lists Home |
Date Index |
Thread Index
]
- From: "Rick Jelliffe" <ricko@allette.com.au>
- To: "Jonathan Robie" <jwrobie@mindspring.com>
- Date: Tue, 30 Sep 1997 05:02:31 +1000
> From: Jonathan Robie <jwrobie@mindspring.com>
> <xml:schema>
> <elementType id="animalFriends">
> <elt href="#pet" occurs="PLUS"/>
> </elementType>
>
> <elementType id="pet">
> <any/>
> <attribute id='name'/>
> <attribute id='owner'/>
> </elementType>
>
> <elementType id="cat" extends="#pet"/>
> <elt href='#kittens'/>
> <attribute id='lives' type='NMTOKEN'/>
> </elementType>
>
> <elementType id="dog" extends="#pet"/>
> <elt href='#puppies'/>
> <attribute id='breed'/>
> </elementType>
> <xml:schema>
>
> Now I can use this type declaration to create an animalFriends element,
> which is a list of pets:
>
> <animalFriends>
> <cat name="Fluffy" lives='9'/>
> <pet name="Diego"/>
> <dog name="Gromit" owner='Wallace' breed='mutt'/>
> </animalFriends>
>
> So the pet hrefs can point to pets, cats, or dogs.
>
> How would I create this schema using architectural forms?
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
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)
|