Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API

Newsletter sign-up

Sign up for our technology specific newsletters.

Enterprise Java
View all newsletters

Email Address:

Serve clients' specific protocol requirements with Brazil, Part 2

How to support XML applications with the Brazil project

In Part 1 of this series, I introduced the concept of a developer-friendly experimental Web server technology called Brazil. The Brazil technology supports additional functionality via handlers, the simple Brazil Scripting Language (BSL), and a global dictionary of system and user properties. (For more information on BSL, properties, and handlers, refer to Part 1 of this series.)

The technology also supports languages that facilitate the rapid creation of XML content. In this month's installment of this series, I will explain how to represent different types of data in XML while still supporting those applications that lack XML ability. I will apply XML to three example applications' data: detailed realtime weather data, stock data, and data from other applications or devices. In addition, I will demonstrate how to use other languages, such as Python and Tcl scripting, with the Brazil Web server. This article will focus on XML generation, with future articles covering XML consumption.

Read the whole series on Brazil technology:



Benefits of XML

Numerous Webpages combine formatting and data. One of the primary benefits of XML is that it facilitates the separation of data from the formatting of that data. Good Web applications will support XML while providing support for those that don't.

Let's begin with a small example that demonstrates the coupling of data with formatting. Let's say we're interested in the collection and display of weather data. To make the temperature bold in an HTML table, we could write the following code:

 <td>Temperature <bold>76,5 </bold> </td>


To generate the page, eventually the data and code must be combined. For example, the above code segment could be realized in BSL by the following:

 <td>Temperature  <bold> <property temperature> </bold> </td>


Listing 1. Combine data and formatting in HTML via the typical approach

If you need to place the temperature on a page, the above approach is much easier than creating HTML each time by generating the content with a procedural programming language that requires recompilation for simple changes. You also don't have to search for a location for the temperature; simply put the <property ws.sample.Temperature> tag anywhere on the HTML page where you would like realtime weather data, and the Brazil technology will rewrite the page so that it will display the data when a browser displays it.

In prior articles, I configured the Brazil Web server to interface with a realtime weather station and provide Web data in the typical manner -- content plus data together -- as shown in Listing 1. For display to users, this approach is suitable, but more and more new Web applications consist of data from multiple Websites. Requiring developers that work on these new types of applications to parse HTML can lead to complications. To create a new service, developers would have to parse the data to obtain the weather information from site A to combine with site C's data. A process that separates the formatting from the content would solve these complications.

1 | 2 | 3 | 4 | 5 | 6 |  Next >
Resources
Recent XML articles in JavaWorld