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

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

RE: Highly Declarative Designs
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]


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.