TextualDisplay Developer's Guide

Authors:
Sergei Chevtsov, SEAL Development, Inc.
$Id: textdisp_dev_guide.html,v 1.5 2007/07/26 19:02:52 chevtsov Exp $

Abstract

This document describes how to use TextualDisplay from an Eclipse plugin. In a nutshell, TextualDisplay displays textual data on screen using XML serialization, transformation to XHTML, and rendering via CSS.

Status of this Document

This section describes the status of this document at the time of its publication.
This seems to be the final version.

Overview

We recommend you take the following steps:

  1. Install TextualDisplay
  2. Run an example application
  3. Manually serialize an instance of your data to an XML document.
  4. Write an XSLT stylesheet that transforms your XML document to an XHTML document.
  5. Display your XHTML document in a web browser by writing a CSS stylesheet.
  6. Embed your CSS stylesheet into your XSLT document.
  7. Upload your XSLT document to a web server.
  8. Call the TextualDisplay API from your plugin.

Installation

You get TextualDisplay as part of SEAL. In your plugin project, you need to add "edu.slac.stanford.seal.textdisp" as a required plugin.

Running the Textual Display example

Object-to-XML serialization

Example code:
MyData myData = new MyData();
String xml = new ObjectSerializer.toXML(myData);
System.out.print(xml);

Notes:
ObjectSerializer#toXML(Object) is a delegate to an XStream method. XStream is a very simple, but flexible and powerful library to serialize objects to XML. It is highly configurable, so if you are not satisfied with your generated XML, e.g. you find the names of the elements too long, use ObjectSerializer#getXStream() to get access to the XStream API.

XML-to-XHTML transformation

Example code:
MyData myData = new MyData();
String xml = new ObjectSerializer.toXML(myData);
String xslt = SealUtil.readUrlContent(new File("my_xslt.file").toURL());
String xhtml = new XMLUtil().transform(xml, xslt);
System.out.print(xhtml);

CSS stylesheet

Embed CSS into XSLT document

Upload XSLT

Call TextualDisplay

Example code:
MyData myData = new MyData();
URL myXsltUrl = new URL("http://my_xslt.xsl");
TextDispPlugin.getDefault().displayData(myData, myXsltUrl);

Notes:
We urge you not to hardcode the URL of your XSLT document. Instead, you can, for instance, use Eclipse's String externalization mechanism.

References

XStream
http://xstream.codehaus.org
XSLT Tutorial
http://w3schools.com/xsl/xsl_transformation.asp
CSS Tutorial
http://w3schools.com/css/default.asp