| 11/10/1998 | 299 Promenade Street, Providence, Rhode Island 02908 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Platform Independent UI Objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bringing "XSL Beans" to the world. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Gavin Thomas Nicol | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Chief Scientist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eBusiness Technologies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Architectural Requirements and Assumptions
The Structural/Visual Component
Java Beans, Visual Basic, CORBA and COM
Serialization and Object Instantiation
XSL Beans - a new approach to an old problem
Object System/Media independence
Deployment Strategies for XSL Beans
Providing a Development Environment
XSL Beans are a unique technology for developing UI's that exploits XML and XSL, and that provides a number of benefits, chief of which are:
XML Beans could play a significant role in many areas, and could revolutionize the document-centric application arena.
This paper describes the thoughts leading to the XSL Bean concept, and the XSL Bean concept in detail. The primary purpose of this document is to provide a background to development groups that might be producing cross-platform UI's (in particular, WWW-based UI's) or UI builder applications that could benefit from XSL Bean technology.
The paper explains the XSL Bean concept at a fairly high level. There is a companion paper discussing development environments using XSL Beans, which also discusses some parts of XSL Beans in more detail.
| . . . . |
| Platform Independent UI Objects |
| Bringing XSL Beans to the World |
It is widely felt that having a comprehensive, state of the art UI is critical for the success of applications. Application UI's have many components, some of which are:
It is also widely felt that many UI's need to be available through both desktop and WWW interfaces. [1]
This paper outlines a platform independent UI technology based on XML and related standards[2]. The technology described is suitable for developing an application development environment that supports concurrent development of desktop and WWW-based applications, and also for deploying UI's developed in such an environment.
The key requirements and assumptions leading to the espoused architecture are outlined below.
The question of what exactly comprises a UI is central to the approach outlined in this paper. For the remainder of this paper, the following subjective definition is used.
A UI is that which controls the human interaction with a computer, including, but not limited to, the layout of the screen, and the behavior enforced by the application.
Again, this is highly subjective, but the intent is to emphasize that a UI is far more than just a GUI, and includes desired patterns of activity and processing.
The key phrases in the above definition are '...the layout of the screen' and '...the behavior'. These phrases provide a basis for dividing a UI into two major components:
Both of these are described in more detail below.
Perhaps the most obvious component of a UI is the way the UI is presented to the end user. For most applications, it includes menubars, toolbars, icons, and other such things, and is referred to as a GUI. On most windowing systems, there are guidelines to the overall GUI structure (often called look and feel guidelines).
The important thing to note about GUI's, is that they are intrinsically hierarchical, because there is an obvious containment relationship that can be reflected as a tree. In most modern GUI's, the windowing system supports the hierarchy directly, with windows that can be nested within one another[5].
Take the following example:
Example of a GUI
This GUI is made up of a number of display regions (windows) nested inside one another. Ignoring the physical implementation of the GUI, one can come up with a logical description:
There is a top-level window that contains a menubar, followed by a toolbar, followed by two windows, side by side. One is a TOC window, and the other, a text window. Those two windows are separated by a bar used for changing the amount of space each takes up, and each has a scrollbar. A search sliver follows these two windows.
The fact that a succinct description of the GUI can be made so easily, and that the description uses purely declarative statements, is important to note, as this opens up a realm of possibilities.
A very important part of UI's is how components interact with one another and with other parts of a system. This is often referred to as the behavior of the application.
At first, it would appear that there is no way of defining behavior other than by writing code, but there are four observations that can be made:
These observations lead to the conclusion that it is indeed possible to define application behavior in a purely declarative manner. This conclusion is certainly not intuitive for most programmers[7], which is why there are few environments that attempt to exploit this.
What is less intuitive is that any declarative statement can also be represented in XML.
It is reasonably well known that declarative programming is much faster, more reliable, and maintainable than procedural programs, so any environment that exploits the ability to declaratively define application behavior, is likely to reap significant benefits from it (or more correctly, people using the tool will reap the benefits). However, environments that provide such benefits by exploiting declarative behavioral definitions are scarce.
The WWW, where scripting prominence is rising at the same rate as site maintenance costs, represents a perfect opportunity for exploiting the above, especially if XML is used to represent the declarative definitions.
Most modern RAD (rapid application development) environments are really GUI development environments, because they do little to help develop the application logic itself, and instead focus on GUI building and project management. Such evelopment environments generally provide the following capabilities:
A typical example (the Visual Basic Editor from MS Word) is shown in the following figure.
Visual Basic for Applications Development Environment
Most basic GUI-builder interactions with the components take place via property editing. Programmed blocks of code that respond to events (one can look at these blocks of code as properties of the object as well) handle behavior (such as calling out to ODBC to get the value for a property) that cannot be described by properties alone.
This paradigm is widely accepted by developers as being powerful and easy to use. The most important aspect of this paradigm that there is a predefined set of components that each consists of a look and feel and a set of properties.
JavaBeans, one of the new and wildly successful Java technologies from Sun, is based on a convention for object interfaces. Like Visual Basic objects in the above example, a JavaBean is a component with a set of properties that can be manipulated. JavaBean technology standardizes how an application can get information about the properties (using introspection and special interfaces), and how properties can be manipulated (through get/set method pairs and property-specific editors). Programmed behavior is added either through action handlers, or in the implementation of the get/set methods.
JavaBeans were originally widely used for GUI objects, but recently, Enterprise Beans have gained wide acceptance. An Enterprise Bean is simply a JavaBean that wraps up some part of a business in a bean interface (for example, a legacy database might be exposed as an Enterprise Bean). Enterprise Java beans aim at tackling many of the problems CORBA and DCOM are aimed at.
CORBA and COM are two object technologies that allow programmers to specify the interfaces[8] of a component, and provide a cross-language framework for manipulating objects via the defined interfaces[9]. They allow one to define both attributes (properties), and methods, using an Interface Definition Language, or IDL. These technologies only specify the interface of a component, not how it is implemented. They can be seen to complement JavaBeans, in that JavaBeans basically conform to a 'bean interface specification', which could be defined in either CORBA or COM. A JavaBean is more than just interfaces however: it is an object, and as such has code implementing the interfaces.
Under Windows, COM objects are used for much the same purposes as JavaBeans: COM provides a basic interface that objects must conform to, and provides a way of asking objects what other interfaces they support. This is put to good effect in many of Microsoft's object technologies such as ActiveX and OCX controls, where the normal way of interacting with the objects is through a GUI development tool. Such tools can use COM to discover the methods and attributes of an object at runtime, and hence can be written independent of the set of objects they will deal with (Bean editors provide the same capabilities for Java).
CORBA offers a superset of COM functionality in a platform and language independent environment.
All these technologies were (and are being) developed with the express purpose of providing a simple, flexible way of defining objects and their properties, and a way of manipulating the properties of instantiated objects[10]. All also provide some way of adding programmed behavior to objects.
The properties of an object represent its state. By retrieving the values of all properties, and creating a serial representation of them, an object is said to be serialized, and its state is saved. An object can be serialized to a file for persistant storage, to a network connection for object migration or communication, or to any other media desired.
An object can be deserialized, meaning that a new object is created (instantiated), and the serialized properties are used to set the values of the properties in the newly instantiated object. The newly created object is a clone of the original, and in some cases, both the original and the clone can coexist.
Note that this is explicitly different from object migration, where an object is serialized, but once deserialized, takes on the identity of the old object (the old object is destroyed). With object migration, it is an error for both the original and deserialized objects to exist in the same application scope, though with pure serialization and deserialization, this is not necessarily an error (in general it is, but in some cases, such as cut buffers, it is not).
Serialization and deserialization are depicted in the following figure.
Object Serialization and Deserialization
Note that only the properties of the object are being serialized, not the objects' code (though in a pure OOP system, the code would be a property of the object itself, allowing for true object migration).
The single most difficult thing about object serialization is that many objects have other objects as a property, so the entire object hierarchy needs to be serialized, and some ordering maintained so that deserialization can be performed in a stream-like manner. In some cases, the objects do not even form a hierarchy, and instead form a graph, further complicating serialization algorithms.
Serialization can be used for individual objects, or for an application, whereby the entire state of an application can be saved and restored at some point in the future. [11] This is an important point that has far-reaching ramifications.
An obvious application of XML in the above is as a replacement for the IDL (Interface Definition Language) used by CORBA and COM. This leads to an interesting form of literate programming for interface definitions, and has been put to good use in the W3C DOM, where the HTML documentation, CORBA IDL, and JAVA and ECMAscript bindings are generated from the XML source[12]. A number of efforts are underway, some within the OMG (the group managing CORBA development), to standardize an XML mapping for IDL, and for using XML in interface repositories.
A less immediately obvious[13] use of XML is as the serialization format used for data interchange between applications. RPC and various other data interchange efforts all have an "on the wire" format which is used for communication, with objects being serialized into and deserialized from it (usually this is called marshalling in this context). XML can be used for as the standard "on the wire" format (which is what WebMethods tools do).
For example, the logical description of a UI given earlier could very easily be rephrased (serialized) using XML, as the following example shows.
<UI>
<MENUBAR>
<MENU>
<ITEM>Open</ITEM>
. . .
</MENU>
. . .
</MENUBAR>
<SPLITPANE GEOM="30%,70%">
<TOCVIEW/>
<TEXTVIEW/>
</SPLITPANE>
<TEXTFIELD/>
</UI>
Logical UI Description In XML
One could just as easily serialize any object into XML: XML is rapidly gaining a foothold as part of a middleware layer between legacy enterprise information repositories (such as mainframe databases) and the WWW, which is the first step in this direction.
Toolkits for object serialization to XML are also beginning to appear (Coins and Koala being two). In such situations, the serialization picture changes slightly to become:
Serialization/deserialization using XML as the data format
This is obviously not a massive departure from existing practice (just a simple change in serialized data format), and so object serialization into XML should become commonplace over the next few years. This is especially true given the capabilities of JAVA, CORBA, and COM for introspection, which allows generic serialization engines to be developed.
However, when using XML simplistically as a serialization format, one of the following difficulties is likely to occur:
These all basically reflect the fragility of simplistic serialization: small changes can break many parts of the system, and it can be very hard to recover from the mistakes, or to repair such serialized instances.
For example, a simple serialized EDI message might look like the following XML fragment.
<code-list> <desc> <date>Apr 09,1998</date> <time>08:00</time> <source>ISO 4217</source> <title>3 Character Country Codes</title> <usage>ASC X12 D.E. 100 - Currency Code</usage> <author>FORESIGHT Corp.</author> </desc> <codes> <code><name>ADP</name><defn>Andorran Peseta</defn></code> . . . . . . . . . . <code><name>AOK</name><defn>Angolan Kwanza</defn></code> . . . . . . . . . . <code><name>ZWD</name><defn>Zimbabwe Dollar</defn></code> </codes> </code-list>
As most people could point out, this is fine for certain cases, but is certainly not the most flexible because much of the information is left implicitly defined. Indeed, there are a number of ISO, and ad hoc working groups, whose sole purpose is to provide an XML syntax for EDI messages that is easy to process by humans and machines.
To get around the problems above, a degree of extensibility and intelligence can be introduced into the deserialization engine, in effect creating a data-driven deserialization engine.
Serialization and Data-driven Deserialization
By adding the extra level of intelligence (the data-driven deserialization engine and deserialization specification) the following benefits, among others, can be accrued:
These benefits to object instantiation are basically the same as those that generic markup brings to the world of documents.
The processing model for DSSSL, and for XSL, bears a striking resemblance to the data-driven deserialization model discussed above. In DSSSL/XSL, a document instance is combined with a stylesheet inside a DSSSL/XSL processor, producing a tree of flow objects (commonly called a flow object tree, or FOT). The flow object tree represents a tree of logical objects to be rendered that are independent of the actual rendered page. This is depicted in the following diagram:
DSSSL/XSL Processing Model
Each flow object is nothing more than a logical specification of an object instance, and it is the responsibility of the FOT processor to actually instantiate the corresponding objects. Different FOT processors can be used to achieve a degree of media independence: for example, James Clark's JADE, an implementation of a DSSSL subset, has FOT processors that produce HTML, RTF, TeX and MIF. Others have developed PDF and Postscript FOT processors for Jade.
A key insight with regards to XSL and the ideas espoused in this paper is that a flow object is really nothing more than a named object that can have children, and a set of properties. As such, any object that conforms to such an interface can be considered a flow object, meaning that almost any object can be a flow object, or instantiated as one[14]. For example, any JavaBean could be instantiated as a flow object, allowing a Swing UI to be instantiated as a flow object tree.
The main difference between the preceding diagram and that of a data-driven deserialization engine, is the intermediary FOT processor. If the objects output by the FOT processor, and the objects in the FOT are the same (i.e. if the FOT processor is an identity transform), then the FOT processor and its output are superfluous, and can be removed as an optimization (though the conceptual model remains).[15]
After removing the FOT processor the models are almost identical, and it becomes possible to instantiate arbitrary object hierarchies directly from within the XSL processor, rather than from the FOT generated by it (i.e. the FOT and the object hierarchy are one and the same). For example, a Java UI can be directly instantiated from an XML instance, an XSL stylesheet, and a generic XSL processor, as noted above. This optimization is possible, and desirable in two cases:
To summarize the main points made this far:
Taking these all together, it is apparent that XML and XSL can represent the object instance data and deserialization specification respectively. These together are labeled an XSL Bean.
There is one important distinction between XSL Beans and other serialization and deserialization mechanisms (such as Java serialization): XSL Bean instance data does not necessarily have to be XML data generated from a serialized object, but can be any XML document instance. Indeed, it is the author's contention that in many cases, the instance data will be authored directly by a human, especially as common DTD's and corresponding deserialization specifications are developed.
As stated earlier, there are two parts to an XSL Bean: the XML document representing the instance data, and the XSL stylesheet specifying how the instance data is to be mapped onto a flow object tree (instantiated). Creating an XSL Bean involves (minimally) creating these two things:
As discussed earlier, the process of instantiating an XSL bean is effectively that of a data-driven deserialization engine, or of an XSL processor with a (possibly) optimized FOT processor chain.
A given XSL processor might be implemented such that it can instantiate arbitrary objects (very likely with COM, CORBA and/or Java), making it possible to instantiate an XSL Bean in a number of different ways. For example, in the following diagram, a <list> element is being instantiated as an object (for example, a ListBox JavaBean) or as a <ul> list in HTML.
XSL Bean Processing and Instantiation Model
It is equally possible to produce a high-quality formatted version for print, and in a web delivery component it should be possible to specify whether a UI should be sent to a browser as a set of applets, or in DHTML.
As such, an XSL Bean is best described as XML instance data with one or more associated XSL stylesheets for controlling the instantiated form. The ability to support multiple media and looks and feels through style selection is a key differentiator.
Deployment of XSL Beans falls into 3 major categories:
Assuming an XSL processor written in Java, the creation of a generic XSL Bean engine capable of instantiating arbitrary objects is fairly trivial. In Java it is possible to instantiate classes by name: using XML namespaces, and possibly other hints in the stylesheet, the XSL processor can determine the name of the flow object it wishes to instantiate, and do so. The flow objects instantiated could literally be any Java object that conformed to the interface.
It is possible to do something very similar using CORBA as well.
The only problem with instantiating objects by name is that the operation is slow. For performance-sensitive applications (such as a stylesheet editor), it is probably unacceptable to incur this overhead; so application-specific instantiation code might be needed for an otherwise generic XSL engine (i.e. hard coding the FOT vocabulary).
Note that an XSL Bean engine could be used over and over again within applications. Almost all of the application GUI's could be built using an XSL Bean Engine, and they would be available as Java applets or applications, or as WWW-based GUI's. Forms based editing can be seen as a useful extension of the basic XSL Bean environment (in effect, this is distributed XSL Bean authoring).
XSL Beans development environments are discussed in detail elsewhere, but there are basically three choices :
The author's personal preference is to develop a native XSL Bean environment.
In both of the likely ways a development environment can be supplied (building or integration), JavaBeans would be used during the actual drag and drop layout editing. As such, the task of providing a standard set of XSL Beans can be broken into two major phases:
This paper has given the background and introduction to a platform independent UI framework called XSL Beans. XSL Beans are a combination of an XML instance, and one or more XSL stylesheets, which are used to drive object instantiation. This leads to a number of benefits over existing frameworks:
XML Beans could play a significant role in many applications.
The following is a list of recommended reading only. Compiling a full bibliography for the ideas in this paper is an almost impossible task.
The author wishes to gratefully acknowledge the early reviewers of this paper for their conscientious review and thoughtful comments. The reviewers, in no alphabetical order were:
[1] Here the term desktop interface describes an UI that runs on a desktop, such as MS Word, whereas a WWW interface is an interface running within a WWW browser, such as Netscape Navigator.
[2] Many of the ideas espoused here (and some parts of the text) are based on a paper "UI Description Using XML" written by the author in August of 1997. Those ideas, in turn, are based on ideas derived from work in the early 1990's on distributed hypermedia.
[3] Many studies have also shown that consistency of formatting in printed books results in speed and comprehension gains for readers.
[4] The Swing toolkit developed by JavaSoft allows one to choose the look and feel of a Java application at runtime. This is by no means a new idea: various X11 toolkits have had such capabilities, and LISP machines had the capability before them.
[5] MS Windows has a more complicated, and less intuitive model.
[6] The topic of behavioral specification using transition networks as described in chapter 5 of "Object-Oriented System Development") is very applicable here.
[7] Though there is a close relationship to functional programming.
[8] An interface is a set of methods and attributes/properties that an object exposes publicly. An interface differs from a class or object, in that interfaces are independent of implementations and class hierarchies.
[9] CORBA has always offered the ability for remote method invocation, and DCOM adds this capability to COM. As such, both COM and CORBA support distributed application architectures.
[10] It is interesting to note that most of the early OOP systems such as Smalltalk provided such capabilities as an intrinsic part of the object system, and so needed no special mechanisms.
[11] In most LISP dialects there is a first class object called a closure or continuation that effectively represents this.
[12] The author spearheaded this effort.
[13] The author has espoused this idea for a number of years as part of the "Document as UI" concept.
[14] Basically any object that can be constructed without needing data passed to the constructor can be instantiated as a flow object, with some caveats.
[15] This may seem to be a bad thing to do, but a similar situation exists with I18N in HTML, where the logical transcoding to Unicode does not actually happen in most browsers.
[16] Note that there could be multiple XSL stylesheets per DTD.