XLinkFilter: An Open Source Java XLink SAX Parser Filter


XLinkFilter is a layer that can rest between a SAX-compliant parser and Java applications which uses the SAX API to retrieve information from XML documents. This code is licensed by Simon St.Laurent under the Mozilla Public License. You may use this code and derivatives of this code in your own programs, whether or not they are free and/or open-source, but this code and portions of your programs that are derivative of this code must be distributed as source code under this license. If you're kind enough to send your enhanced code back to me, I'll make certain you are credited for your efforts in the source code.

As shown in Figure 1 (to the right) the XLink Filter uses John Cowan's ParserFilter class to insert itself between the parser and the application. The XLink filter (derived from the ParserFilter) passes all SAX events on to the application, which can do its own processing of the XML document represented by the SAX events, but only after noting all the XLink information contained in the document. (A LocationFilter class may optionally be inserted between the SAX parser and the XLinkFilter to provide more information about inline links.) When the parsing process is complete, the XLink Filter will leave behind a Link Collection, which can take requests from the Application regarding which elements contain links and what the targets and behaviors of those links should be.

The application will still need to implement the user interface for the links. Highlighting and traversing links will be done in very different ways for image maps and text documents, to cite just one example. The main thing the application will gain from the XLink Filter is convenience - developers won't have to build the XLink processing into their SAX event handlers, and can use a standard interface to linking information rather than having to rebuild that interface with each new application. At present, this model may also assist developers contending with the instability of the XLink specifications - only the Filter's code should need to change to reflect revisions in the standards, not the code of the applications. (Of course, it also depends on the nature of the changes to the spec - drastic changes may in fact require changes to the applications.) This isolation from the details of the XLink spec should hopefully allow multiple applications to implement XLink in a consistent way, easing the adoption of this crucial spec for hypertext development.

It should be noted that at present the XLink Filter is only supporting XLink, and not the accompanying XPointer specification. (XPointers may be created to identify the origins of inline links, using the LocationFilter.) If someone else would like to develop an open source Java XPointer implementation, it could fit neatly between the Link Collection and the Application Logic in Figure 1. Unfortunately, supporting the full range of XPointer possibilities is well beyond my programming skills at this point.

The Filter or Filters lie between the SAX parser and the application, and pass a collection of links to the application when finished.
Figure 1 - Event and Link Flows

Goals

For now, the goals are fairly simple. The XLink Filter will be an open source software project, built using Java. The XLink Filter project hopes to provide support for the entire XLink specification, and provide sample applications that implement the actions involved in linking. Initially, the filter will support simple and extended links between documents that have been visited by the user; eventually, it will provide support for extended hub groups to allow pre-fetching of links. Eventually, support for DOM-based applications will also be provided. Support for 'legacy' HTML documents is also important for transition.

XLinkFilter does not provide full-scale application support for XML display and behavior. XLinkFilter is just a library, providing tools for other applications to use. Hopefully, more sophisticated examples will demonstrate such capabilities in open source.

More information on XLinkFilter (and code!) is available through the links below. Two small examples of applications using XLinkFilter, including the LinkMap image map demo, are also available.

Overview | Design Notes | Documentation | Resources | Code | Next Generation

Last updated 12/15/98