[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Animal-friends implemented as a pattern (Re: XML-Data:advantages ove
---------- > From: Jonathan Robie <jwrobie@m...> > To: ricko@a... > 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@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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|