[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
RE: Highly Declarative Designs
- From: "Costello, Roger L." <costello@mitre.org>
- To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
- Date: Tue, 8 Feb 2011 08:01:32 -0500
Hi Folks,
Thank you John, Frank, and Kurt for your comments. I am still contemplating them.
Today I found an example [1] from HTML5 which illustrates the difference between a design that is highly declarative versus one that is not.
HTML5 has an <audio> element. You can specify multiple file formats using the <source> element. E.g.,
<audio>
<source src="witchitalineman.ogg">
<source src="witchitalineman.mp3">
</audio>
A browser that can play back Ogg Vorbis files will look no further than the first <source> element. A browser that can play MP3 files but not Ogg Vorbis files will skip over the first <source> element and play the file in the second <source> element.
You can help the browsers by providing the mime types for each source file:
<audio>
<source src="witchitalineman.ogg" type="audio/ogg">
<source src="witchitalineman.mp3" type="audio/mpeg">
</audio>
I assert that the second form is highly declarative with respect to mime type information.
Consider this question:
What is the mime type of the audio files?
With the second form the question is readily answered simply by navigating to the type attribute. Using XPath this is accomplished as follows:
audio/source[1]/@type
audio/source[2]/@type
With the first form the question is not so readily answered. It requires an application (e.g., browser) to parse "witchitalineman.ogg" and infer the mime type from the file name suffix.
My recommendation is to use the highly declarative design. In the above example, that means use the second form.
Comments?
/Roger
[1] The example comes from the book, "HTML5 for Web Designers" by Jeremy Keith.
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]