Wave Two: Configuration and Action

Team-Fly    

 
XML, Web Services, and the Data Revolution
By Frank  P.  Coyle
Table of Contents
Chapter 3.   XML in Practice


XML may be used to treat instructions as data.

The first wave of XML gave us (and continues to provide) industry-specific vocabularies focusing on describing data for B2B interaction or defining data for permanent storage in order to create the possibility for B2B interplay . However that's not all that can be said or done with data, particularly if we step beyond the conventional sense of the word "data" as "data processing" and look at it more generally as a description of instructions to be carried out by some processing engine. This is data the way John von Neumann, one of the great pioneers in computing, formulated it in his 1940s design for computers that is still relevant after half a century. His idea, which spawned the computer industry as we know it today, was to treat programs as data, store them in memory, and feed them to the CPU for execution. This simple yet powerful concept turned out to be the turning point for an industry that for over 50 years (from the 1890 census through the rise of IBM in the 1920s) had been locked into designing business machines with hardwired instruction sets.

It is this use of data as instructions or code that has sparked what we call the second wave of XML applications that use XML to go beyond simple vocabularies for vertical industries and step into the world of XML as instruction. Figure 3.4 illustrates the second wave of XML, and in the following section we explore a few of these XML initiatives to illustrate XML's use as a configuration and action language.

Figure 3.4. The second wave of XML applications: using XML for declarative action and instruction.

graphics/03fig04.jpg

EJB and XML

EJB uses XML for software configuration.

EJB is component architecture for building distributed object-oriented business applications in Java. The basic idea behind EJB is to allow developers to build distributed applications by assembling components rather than to build monolithic applications from scratch. Component frameworks such as EJB free developers from having to write complex, low-level software to handle transactions, state management, multi-threading , and connection pooling that are notoriously difficult to get right. The philosophy behind EJB is that modular software units can be developed and deployed in different ways on different platforms depending on an XML descriptor file that specifies the details.

Figure 3.5 illustrates the assembly of EJB components being controlled by an XML document known as an EJB deployment descriptor. The XML-based deployment descriptor contains two kinds of information:

Figure 3.5. The EJB architecture showing an XML-based EJB deployment descriptor. The XML is used to indicate that the program code should be executed as part of a transaction.

graphics/03fig05.jpg

  • EJB structural information: EJB name , class, home and remote interfaces, bean type (session or entity), environment entries, resource factory references, EJB references, security role references, and other information based on the bean type

  • Application assembly information: EJB references, security roles, security role references, method permissions, and container transaction attributes. Assembly descriptor information is optional.

SVG

SVG uses XML to render complex 2D graphics.

Web designers have long struggled with getting graphics right on different browsers. Now they are challenged by a variety of new devices with a range of screen sizes and resolutions . What's needed is the ability to easily create rich graphics, responsive animation, and interactive behavior in a way that takes advantage of the growing XML infrastructure used in e-commerce, publishing, and business. SVG attempts to fill that bill.

SVG is a W3C Recommendation that defines an XML grammar for creating vector-based 2D graphics for the Web and other applications. SVG is an alternative to delivering GIF or JPEG images to browsers. Because SVG is defined as an XML grammar, SVG graphics can easily be generated dynamically on Web servers using standard XML tools and delivered with a style sheet to a browser for rendering. For example, a Web server can generate a high-quality graphic from historical stock market data that requires minimal bandwidth.

SVG has several advantages over graphic image formats such as GIF or JPEG:

  • Readability: SVG files can be read and modified by numerous tools. The files are typically much smaller and more compressible than comparable JPEG or GIF images.

  • Scalability: Unlike bitmapped graphics formats such as GIF and JPEG, SVG is vector-based, meaning SVG images can be printed with high quality at any resolution, eliminating the " staircase " effect that occurs when expanding bitmapped images.

  • Ability to zoom: You can magnify any portion of an SVG image without image degradation.

  • Searchable and selectable text: It's possible to search an image library for the occurrence of specific text strings, like names in a map.

  • Scripting and animation: SVG supports interactive graphics that allow complex animations.

As a W3C-sponsored XML vocabulary, SVG abides by the design requirement that it maintain compatibility with other W3C efforts. Table 3.2 illustrates the compatibility of SVG with other W3C initiatives.

Because the SVG Recommendation is fairly recent, it is expected that browser manufacturers will soon be releasing versions that support SVG. As of this writing several software packages can be used to display SVG images:

  • Adobe SVG Viewer: Adobe supports a browser plug-in for Netscape 4.5 to 4.77, Microsoft Internet Explorer (IE) 4 or greater, RealPlayer 8 or higher, and Opera 5.x. There is also an ActiveX control for SVG display in Microsoft Office and Visual Basic.

  • Apache Batik SVG browser: This open source browser uses XML technologies including an XML parser, an XSL Transformations (XSLT) engine, and a CSS parser to render SVG images.

  • CSIRO Pocket SVG Viewer: Targeted for handheld devices, the Pocket SVG Viewer runs on the PocketPC operating system and requires only 390K of memory.

Table 3.2. How W3C Initiatives Integrate with SVG
Initiative How Integrated with SVG
XML 1.0 SVG defined using XML 1.0
XLink SVG uses XLink for URI referencing
XPointer SVG is compatible with a subset of XPointer's ID referencing syntax
Cascading style sheets (CSS, CSS2) and Extensible Stylesheet Language (XSL) SVG content can be styled by either CSS, CSS2, or XSL
Document Object Model (DOM) level 1 SVG includes a complete DOM and conforms to the DOM1 Recommendation
DOM level 2 SVG supports and incorporates many of the facilities described in DOM2, including the CSS object model and event handling
SMIL SVG is designed to allow future versions of SMIL to use animated or static SVG content as media components; incorporates some features and approaches that are part of the SMIL 1.0 specification, including the switch element and the systemLanguage attribute
HTML/XHTML SVG attempts to achieve maximum compatibility with both HTML 4 and XHTML 1.0
Web Accessibility SVG is compatible with W3C work on WAI Initiative (WAI)

VoiceXML

The VoiceXML standard provides a platform for voice applications.

VoiceXML is an example of using XML to encode instructions, in this case for software called a voice browser. Because VoiceXML is essentially a text document, it can be moved across the Internet just like any Web page, except that when VoiceXML text reaches a voice browser, that browser has the support of hardware to synthesize speech and do speech recognition. The goal is to leverage existing Web-based development and content delivery tools to build interactive voice applications.

VoiceXML documents describe conversations.

As Figure 3.6 shows, a VoiceXML document may be delivered to a server that converts text to voice and communicates over a telephone exchange, or it may be delivered directly to a device capable of performing speech processing. As the processing power of cell phones increases , it will be possible to perform VoiceXML conversions directly rather than relying on server-based transformations

Figure 3.6. VoiceXML is an example of using XML to control action. Conditions can be checked and branches can be followed to appropriate actions.

graphics/03fig06.jpg

Forms and Menus

VoiceXML supports forms and menus.

VoiceXML is centered around two kinds of conversational dialogs: forms and menus. Forms provide voice control for completing the equivalent of a Web form and contain sets of items to be completed during the dialog. Control items govern the gathering of the form's fields. Event handlers, which are blocks of procedural logic, are triggered when certain combinations of field items occur. For example, some fields may be specified as optional or required, and some responses may trigger the loading and execution of new forms.

Menus present users with a choice of options and have the ability to transfer control to other menu dialogs based on user response. A menu is a kind of form that gets information from a user and branches to different dialogs based on user response.

Figure 3-6 shows how VoiceXML may be used to collect credit card information from a VoiceXML form. The form element contains field elements that drive the dialog. When speech is not understood , prompt elements provide sequential alternatives. If keypads are available, input can revert to keypad data entry.

SMIL

SMIL uses XML to build multimedia presentations.

SMIL is a broad-based effort to use XML to define instructions for the creation of Web-based interactive multimedia presentations. SMIL provides an XML alternative to technologies such as Flash or JavaScript that are widely used to control animation in browsers. SMIL allows an author to describe the temporal behavior of a multimedia presentation, associate hyperlinks with media objects, and describe the layout of a screen presentation. SMIL components may be used to integrate timing into XHTML and SVG. Like VoiceXML, SMIL is more action-oriented than purely data descriptive.

SMIL 2.0 was approved as a W3C standard Recommendation in 2001. The advantages of SMIL include:

  • Faster and easier development than with JavaScript or Dynamic HTML (DHTML) for programming animation and mouse events

  • Web standard support in IE 5.5, RealPlayer, Windows Media Player, and Adobe's SVG plug-in

  • No requirement that users enable JavaScript in their browsers

  • Support for more complex actions than are possible with JavaScript or DHTML

  • Animations faster than Flash for certain situations

SMIL Elements

XML elements are used to specify animation.

SMIL includes elements that describe not only how to draw graphics but also how to coordinate them over time. In SMIL, timing elements are used to specify animation. Fundamental to SMIL is the concept of a timeline. A timeline represents the amount of time that an element takes to run, from beginning to end. Timelines are used to map complex events, such as objects moving along an oval path or zigzag . SMIL timelines also support audio or video synchronization with an animation. Sound clips, QuickTime videos , or JPEG slide shows may be scheduled to run at different times during an animation.

There are three flavors of timeline elements:

  • seq for animations that run in sequence, or one after another

  • par for animations which run in parallel, or all the same time

  • excl for exclusive elements, or animations which pause all other timelines when they run

SMIL Modularization

SMIL modules address the problem of integration.

One of the problems confronted by SMIL designers was how to design the language to handle the widest range of animation possibilities. Rather than create a long list of elements and attributes in a DTD, the designers opted to break SMIL into modules, each of which addresses different aspects of animation. Modules contain semantically related XML elements, attributes, and attribute values. Through an approach known as profiling, designers can then combine modules to provide the functionality required by a specific application. Modularization enables language designers to specify dedicated markup intended for integration with other existing XML languages, such as MathML and XForms.

The use of modules in SMIL is based on work done with XHTML modularization (see Chapter 2). A "module" is a collection of semantically-related XML elements, attributes, and attribute values that represents a unit of functionality. Modules are defined incoherent sets in which all elements are associated with the same namespace.

A "language profile" is a combination of modules. Modules are "atomic," which means they cannot be partitioned when included in a language profile. Furthermore, a module specification may include a set of integration requirements, to which language profiles that include the module must comply .

From Action to Combination

XML's second wave of applications was the result of using XML to define elements that encode actions to be performed by some appropriately configured software engine. This treatment of instructions as data opened up possibilities for applying XML to a broad range of new problems centered on configuration and action.


Team-Fly    
Top


XML, Web Services, and the Data Revolution
XML, Web Services, and the Data Revolution
ISBN: 0201776413
EAN: 2147483647
Year: 2002
Pages: 106
Authors: Frank Coyle

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net