Prototype OO was Re: Inheritance/defaulting of attributes

John Gossman JohnGo at asymetrix.com
Fri Oct 10 20:11:00 BST 1997


	I guess an example is in order:

	<typedef id="button">
		<x type="int" value="0"/>
		<y type="int" value="0"/>
		<x2 type="int" value="1"/>
		<y2 type="int" value="1"/>
		<caption type="string" value="button"/>
	</typedef>

	later we can define an instance of button:

	<button id="button1">
		<x2 value="100"/>
		<y2 value="200"/>
		<caption value="Click Here!"/>
	</button>

	The button instance picks up default values and types from the typedef
(the prototype), and overrides the others.

	Furthermore, you can derive a new class:

	<typedef id="button-with-graphic" parent-class="button">
		<graphic type="string" value=""/>
	</typedef>

	and a new-instance:

	<button-with-graphic id="button2">
		<caption value="Click on the picture"/>
		<graphic value="folder1.gif"/>
	<button-with-graphic/>

	-JG


	

>----------
>From: 	John Gossman
>Sent: 	Friday, October 10, 1997 10:38 AM
>To: 	'xml-dev at ic.ac.uk'; 'Meltsner, Kenneth J'
>Subject: 	RE: Prototype OO was Re: Inheritance/defaulting of attributes
>
>	This is an excellent idea.  For declarative languages especially,
>prototype is a very good model for  inheritance because it provides
>default values for data fields and layouts of schemas, which is
>primarily what you need (there is no behavior to inherit).  I have used
>this as the basis for my XML based OXF (Open Exchange Format).  It seems
>to be easier to understand for those who are not fluent in OO technique.
>
>

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list