[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Animal-friends implemented as a pattern (Re: XML-Data: advantages over D

  • From: "Rick Jelliffe" <ricko@a...>
  • To: "Jonathan Robie" <jwrobie@m...>
  • Date: Tue, 30 Sep 1997 05:02:31 +1000

gromit pattern

 
> From: Jonathan Robie <jwrobie@m...>
 
> <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@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.