Creating Dynamic Content with Enhydra XMLC

Why open-source compiler Enhydra presents a slightly different approach from the more conventional JSP
By Wm. Paul Rogers

our assignment: To create a Web site that sings. You need to build from a fountain of information that continually replenishes itself. And you need to perform your magic on Web-page layout created by HTML designers.

There are a couple of ways to do this. One is Enhydra XMLC (eXtensible Markup Language Compiler), an open-source technology whose purpose closely parallels the utility of JavaServer Pages (JSP). Both technologies are designed to simplify the development of dynamically generated Web content, typically in a servlet architecture. The overall approach of each technology is, however, quite different.

JSP extends existing Java Servlet technology through the inclusion of Java code in markup language files, particularly HTML. JSP files are a mixture of markup code and Java code which are compiled into a servlet class. Executing inside a servlet context, the embedded Java code creates dynamic content to be returned by the servlet.

XMLC provides a similar functionality but without inserting Java specific tags or code into markup language files. For each input HTML file, XMLC generates a Java class capable of reproducing the exact markup of the file. The Java class actually contains a Document Object Model (DOM) representation of the Web page. This allows a developer to dynamically alter the page content by manipulating the DOM.

Rather than embed Java directly into the markup language file, the dynamic link between markup code and Java code is accomplished via the DOM. During compilation, XMLC creates convenience methods to facilitate DOM manipulation. In particular, XMLC adds the convenience method

getElementXXX()
for every standard markup tag that includes an attribute of the form ID="XXX". Having obtained a DOM Element reference, a Java developer may manipulate the element in any DOM consistent manner. Obviously these ID attributes need to be unique within a single markup language file to be meaningfully accessed by the Java code. Furthermore, since text manipulation is so common for dynamically generated Web pages, XMLC also adds the convenience method
setTextYYY(String)
for all SPAN tags with an attribute of the form ID="YYY". SPAN tags are standard HTML markup for delineating text content. These convenience methods provide an easy access point for dynamically generating text.

In this article I investigate using XMLC for generating dynamic Web content by developing a very simple Stock Quote page which displays a list of stock prices for a specified customer. The example HTML and Java code is purposely kept simple while still allowing the benefits of XMLC to shine. I do not cover XMLC installation and setup; please refer to the open-source site xmlc.enhydra.org for download and installation instructions.

 
Generating Dynamic Text Content

In this Article
Introduction Generating Dynamic Table Content
Generating Dynamic Text Content Adding Mock-up Content







FEATURE SOFTWARE:
dtSearch Web
Add power searching to your web site.
Buy Now!

Encrypt It
Encrypt and Decrypt Data, Passwords and Files within your application.
Buy Now!

FEATURE BOOK:
PointBase Mobile Edition
Enable local data access for mobile users.
Buy Now!
Enhydra.org

DevX Java 2 eLearning

DevX Java Zone

Product Review of the Week
Rational Suite 2001

Site of the Week

Book Review of the Week
Object-Oriented Implementation of Numerical Methods

Tip of the Day
Use Math.PI and Math.E for Scientific Calculations

Download of the Week
Ebitec JMS Mail Bridge





 
Sponsored Links

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map
Jupiterweb networks

internet.comearthweb.comDevx.comClickZ

Search Jupiterweb:

Jupitermedia Corporation has four divisions:
JupiterWeb, JupiterResearch, JupiterEvents, and JupiterImages

Copyright 2004 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Jupitermedia Corporate Info | Newsletters | Tech Jobs | E-mail Offers

Copyright Information/Privacy Statement