OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

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

[ 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:54:19 +1000



----------
> From: Jonathan Robie <jwrobie@mindspring.com>
> To: ricko@allette.com.au
 
> At 05:02 AM 9/30/97 +1000, Rick Jelliffe wrote:
>  
> >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.
>  
> Please!
 
Here is a version which allows multiple inheritance.
(Some parenthesis problems fixed too.)
I have put in even empty attribute values, to make
the pattern uniform in every case, so please do not
confuse this simplicity for elaborateness!

To extract the inheritance tree, collect all attributes
with "-inherit" suffix.  I think the only novel thing
is that people are not used to wildcard searches on 
attribute names, but this is only prejudice.

Also, I think because some tools require precompiled
DTDs, there is a general view in some circles that
DTDs are always compiled, and always made prior
to the generation of the instance. But that is
not intrinsic to SGML.

The PATTERN
-----------

This pattern reserves the suffixes:
	-content	 for a parameter entity with the 
                       element type's contents
	-attributes  for a parameter entity with the 
                       element type's attributes
	-inherit     for a fixed attribute with the 
                       element type's immediate inheritance

The pattern is
	<!ENTITY % {GI}-content
		" {CONTENT-MODEL} ">
	<!ENTITY % {GI}-attribute
		" {ATTRIBUTE-DECLARATIONS} 
		{GI}-inherit CDATA #FIXED '' ">
	<!ELEMENT {GI}
		( %{GI}-content;,  {INHERITED-CONTENT-MODELS} ) >
	<!ATTLIST {GI}
		%{GI}-attributes;
		{INHERITED-ATTRIBUTE-DECLARATIONS}
		>
Where the delimiters {} indicate parameters of the template
which you or your application edit in.  

The EXAMPLE
-----------

<!DOCTYPE animal-friends
[
<!-- Handle animal friends ================================= -->
<!ENTITY % animal-friends-content 
	" ( pet | cat | dog )* "
<!ENTITY % animal-friends-attributes
	"  animal-friends-inherit CDATA #FIXED '' ">
<!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 
	pet-inherit CDATA #FIXED '' "
	 >   
<!ELEMENT pet
	%pet-content;  >
<!ATTLIST pet
	%pet-attributes;
	>

<!-- Handle cats =========================================== -->
<!ENTITY % cat-contents
	" (kittens)? " 
<!ENTITY % cat-attributes
	" lives NMTOKEN #IMPLIED 
	cat-inherit CDATA #FIXED 'pet' ">
<!ELEMENT cat
	( %pet-content;, %cat-contents; )
 <!ATTLIST cat
	%pet-attributes;
	%cat-attributes;
	>

<!-- Handle dogs =========================================== -->
<!ENTITY % dog-contents
	" (puppies)? " 
<!ENTITY % dog-attributes
	" breed CDATA #IMPLIED
       dog-inherit CDATA #FIXED 'pet' ">
<!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>


Please note that I am not saying that this form is always
preferable to using AFs or XML-data.  But it can be done
in XML as it stands now, keeping valid SGML declarations.
And, as has been mentioned, there should be interconversion
possible between the three forms, since they give the
same information.  If XML-data requires the use of specialist
tools to mapulate, since it is so verbose, then this pattern
cannot either be regarded as excessively verbose either, 
since the same kind of tools can be constructed to simplify
creating new objects.


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)





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS