Most Web applications require the presentation of database-generated information. XML, because of its ability to separate content from presentation, is fast becoming an industry standard for data exchange. Most XML tools work with either the SAX or DOM API. This article presents a way to blend the power of a database with the features of XML. It also provides a simple, pure Java implementation of XML APIs for databases that works with any JDBC data source. With this approach, XML tools can treat a database as a virtual XML document. (3,000 words)
XML and JSP are two of the hottest buzzwords these days. This article shows how you can use these two technologies together to make a dynamic Website. You also get a look at code examples for DOM, XPath, XSL, and other Java-XML techniques.
Apache XML Security is an open source implementation of the XML Digital Signature specification that allows you to digitally sign your Web service messages. Digital signatures assure your messages' receivers that the messages are really from you. After reading this article, which serves as an introductory tutorial to Apache XML Security, you will be well prepared to start signing your Web services messages. (2,400 words; December 20, 2002)
JDOM is a new API for reading, writing, and manipulating XML from within Java code. In April, Jason Hunter and Brett McLaughlin publicly released the API in a beta form. Based on the premise that using XML should be intuitive, simple, and productive, the API is optimized specifically for the Java programmer. In this article, the first of two parts, Hunter and McLaughlin explain how to use JDOM to read XML from an existing source. In Part 2, they will focus on how JDOM can create and mutate XML. (3,000 words)
XML has gained popularity as a platform- and language-independent format for transferring data across systems. In situations where you need to transfer binary data within an XML document, you must encode that binary data into an acceptable character format. This tip describes three different encoding approaches ranging from the simple to the most sophisticated techniques. (2,100 words; September 28, 2001)
7. XML document processing in Java using XPath and XSLT
In order to process an XML document, a Java application will typically use the Document Object Model (DOM) API as standardized by the W3C. In this article, Andre Tost shows that the XSLT and XPath standards provide a way of handling certain problems that is more elegant and efficient than simply using the DOM API. In fact, using DOM, XSLT, and XPath together, applying each to different problems, will lead to the best code. Tost will develop two code examples -- one using XPath and one using an XSLT stylesheet -- that show how these technologies can be used in Java. (1,500 words)
If you've written many full-blown applications in Java, especially ones in which input is accepted from a Web form or a Swing GUI, you've probably spent some time writing validation code -- that is, logic for every conceivable user error. At the end of the project, though, that code was most likely thrown away, tied to the specific application. While Java provides type safety, it lacks a rich means for setting data constraints. In this series, Brett McLaughlin solves that problem; he looks at why Java alone is insufficient and examines XML Schema as a way to set up rich constraints for data used by Java programs. At the end, you'll have a reusable set of extensible components that will allow you to never code validation logic again. (2,500 words)
This article develops a SAX API-based class library that is easily extended to create XML-to-Java mapping code. First, we explore the important ideas that drive the need for the class library. Then we develop a basic approach for implementing the library as well as a few samples that demonstrate some more advanced topics on parsing XML with the SAX API. (2,500 words)
This tip shows you how to parse XML when running in an applet or other space-restricted environment, such as a J2ME (Java 2 Platform, Micro Edition) application. The process limits functionality in a way that many small applications can accept. (1,000 words; May 31, 2002)
With XML evolving at a rapid pace, many developers get lost in a sea of acronyms. And since XML is fast becoming the way to exchange data, chances are you will need first-hand XML knowledge. Keeping up with XML means knowing when XForms, WSDL (Web Services Description Language), or RDF (Resource Description Framework) can help, or whether to use FO (Formatting Objects) or SVG (Scalable Vector Graphics), and if XQuery is worth considering. To help you better understand and use XML, Joe Walker defines many XML technologies crucial to Java developers. (3,900 words; September 27, 2002)
Apache XML Security is an open source implementation of the XML Digital Signature specification that allows you to digitally sign your Web service messages. Digital signatures assure your messages' receivers that the messages are really from you. After reading this article, which serves as an introductory tutorial to Apache XML Security, you will be well prepared to start signing your Web services messages. (2,400 words; December 20, 2002)
13. Transparently cache XSL transformations with JAXP
When using XSLT (Extensible Stylesheet Language Transformations) in Web environments, where numerous concurrent threads repeatedly use transformations, implementing a stylesheet cache drastically boosts performance. However, using a stylesheet cache on top of normal JAXP (Java API for XML Parsing) is often not convenient or suitable for pure JAXP users. This article introduces the idea of pushing cache functionality inside transformer factory implementations, making cache usage absolutely transparent. (1,300 words; May 2, 2003)
This article provides a simple method for creating valid XML and a simple DOM-like (Document Object Model) parser. This method is useful for small applications that need simple XML functionality without the size and complexity of the full range defined in the XML standards. The methods used to manage the XML data resemble those used to manage vectors, with the goal being to make the interface familiar and simple. (1,100 words; September 6, 2004)
In this article, the second of three, Dirk Reinshagen introduces SOAP to the XML messaging equation. He begins by describing SOAP and other related technologies, then reinforces with a simple example using SOAP to create an invoice. (1,500 words)
In just a few short years, the World Wide Web and HTML have taken the world by storm. But HTML's limitations and the ever-increasing demand for more flexibility in Internet systems has XML, the Extensible Markup Language, brewing on the horizon. Further, Java applications that move data around need a data representation format as portable as Java itself. Developers who learn XML now will find it a powerful tool for data representation, storage, modelling, and interoperation. Mark Johnson steps away from his popular JavaBeans column this month to introduce you to the world of XML: where it came from, why it's necessary, how it interoperates with existing Internet technology, and how to use it in your designs. You'll learn about Cascading Style Sheets and XSL, then follow up with a look at the XML and Java technology base at a promising Internet startup, with comments from that company's CEO and technical lead. By the time you've finished reading Mark's article, you'll understand why so many people are paying so much attention to this new data representation standard. (11,000 words)
The first article in this series introduced SAX, the Simple API for XML. This article delves further into using SAX in your applications. First, you'll read about document type definitions (DTDs), which specify the structure of an XML document. You'll learn about LAX, the Lazy API for XML (developed for this article), which makes using SAX even simpler. You'll then see LAX applied in a small document-processing system that uses the same XML data to generate documents for multiple purposes. (3,600 words)
In Web-authoring systems and information channel definitions, in middleware and in the core of enterprise databases, organizations and individuals are embracing XML as a powerful tool to help solve their data-management problems. But as powerful as it may be for representing data, XML is useless without an application to process it. In this article, you'll learn to use the Simple API for XML (SAX) interface to process XML documents in Java. (5,000 words)
JDOM is a new API for reading, writing, and manipulating XML from within Java code. In April, Jason Hunter and Brett McLaughlin publicly released the API in a beta form. Based on the premise that using XML should be intuitive, simple, and productive, the API is optimized specifically for the Java programmer. In this article, the first of two parts, Hunter and McLaughlin explain how to use JDOM to read XML from an existing source. In Part 2, they will focus on how JDOM can create and mutate XML. (3,000 words)
Separating content from presentation is one of XML's major features. But eventually you need to style that XML into something presentable. That's where XSL (Extensible Stylesheet Language) comes in -- XSL transforms XML from one document type to another. Servlets provide a great platform for doing those translations. In this article you'll learn how to transform XML into HTML, using servlets. (2,000 words)
The first two parts of this series presented the Simple API for XML (SAX) interface. SAX is easy to learn and use, and its limited functionality results in a compact parser. While SAX is the most common XML parsing mechanism, it has some limitations. This month, Mark Johnson explores those constraints and then takes an in-depth look at the Document Object Model (DOM), the most common alternative XML-processing mechanism. See how you can use DOM to manipulate the source code data in an illustrative example program. (3,700 words)
The SAX API is superior to the DOM API in many aspects of runtime performance. In this article we will explore using SAX to map XML data to Java. Because using SAX is not as intuitive as using DOM, we will also spend some time familiarizing ourselves with coding to SAX. (3,000 words)
If you've written many full-blown applications in Java, especially ones in which input is accepted from a Web form or a Swing GUI, you've probably spent some time writing validation code -- that is, logic for every conceivable user error. At the end of the project, though, that code was most likely thrown away, tied to the specific application. While Java provides type safety, it lacks a rich means for setting data constraints. In this series, Brett McLaughlin solves that problem; he looks at why Java alone is insufficient and examines XML Schema as a way to set up rich constraints for data used by Java programs. At the end, you'll have a reusable set of extensible components that will allow you to never code validation logic again. (2,500 words)
This article develops a SAX API-based class library that is easily extended to create XML-to-Java mapping code. First, we explore the important ideas that drive the need for the class library. Then we develop a basic approach for implementing the library as well as a few samples that demonstrate some more advanced topics on parsing XML with the SAX API. (2,500 words)
Constraining XML by using DTDs or XML Schema is a well-accepted practice. However, using those same mechanisms for constraining Java method arguments is uncharted territory. In this article, Brett looks at a roadmap for taking Java method parameters and validating them against constraints in an XML document. Various approaches will be examined, and you will begin to actually code the utilities for converting those XML constraints into usable Java utilities. (3,000 words)
26. Eliminate tedious programming: Recover data with XML and Reflection
The parsing of ResultSets forms one of the most significant tasks involved in retrieving data from a database. But, as a repetitious and uninteresting assignment, it is not a favorite among developers. In this article, Abhilash Koneri demonstrates how to supplant ResultSet parsing in the data access objects. Attention lazy programmers or managers who supervise a lackadaisical bunch: this article is for you! (To truly appreciate code reuse, you must be lazy!) (2,000 words)
Taking validation beyond simple if-then-else structures, XML Schemas can provide a better way to validate data in Java applications. In this article, Brett continues to build the validation framework and fill in the blanks left from the last article. You'll learn to parse the XML Schema, build up Java representations of the schema's constraints, and apply those constraints to an application's data. (3,600 words)
Taking validation beyond simple if-then-else structures, XML Schemas can provide a better way to validate data in Java applications. This final part in a four-part series continues to build the validation framework and fill in the blanks left from the previous article. You'll parse the XML Schema, build up Java representations of the schema's constraints, and learn how to apply those constraints to data in an application. (3,500 words)
In this article, the first of three, Dirk Reinshagen discusses XML messaging, specifically the basic premise of XML messaging, what it is, and why it is useful. Further, he presents a simple XML message broker for custom XML messages. In the course of developing this broker, he introduces general broker development strategies. In Part 2 and Part 3, Dirk will discuss the two emerging standards for XML messaging: SOAP and ebXML. (1,500 words)
In this article, the second of three, Dirk Reinshagen introduces SOAP to the XML messaging equation. He begins by describing SOAP and other related technologies, then reinforces with a simple example using SOAP to create an invoice. (1,500 words)
In this article, the last of three, Dirk Reinshagen introduces the JAXM API and the ebXML XML messaging standard. These two standards, working together, enable you to send SOAP messages in a message-oriented fashion. Dirk begins by describing JAXM's components. Next, he discusses ebXML, along with its various parts. He concludes with an example employing both JAXM and ebXML to send and receive SOAP messages. (2,300 words)
In this article, the last of three, Dirk Reinshagen introduces the JAXM API and the ebXML XML messaging standard. These two standards, working together, enable you to send SOAP messages in a message-oriented fashion. Dirk begins by describing JAXM's components. Next, he discusses ebXML, along with its various parts. He concludes with an example employing both JAXM and ebXML to send and receive SOAP messages. (2,300 words)
XSLT (Extensible Stylesheet Language Transformation) offers an excellent vehicle for styling XML documents as HTML. However, it shows some weakness when the transformation requires extensive logic. When XSLT languages fail to complete the job, you can extend your stylesheets with Java classes and take advantage of both languages' features. This article demonstrates how to extend XSLT with Java. You will learn how to instantiate and invoke methods on Java objects from within an XSLT stylesheet. The article also demonstrates how XML nodes are passed to Java classes and returned back to the stylesheet for further processing. (2,200 words; December 21, 2001)
The double buzz phrase "Java and XML" has been in the spotlight for a while now. Many programmers have realized that by using XML as a data format, they can make both their Java programs and their data cross-platform. These same programmers have also experienced severe headaches while writing and maintaining XML parsing and attribute validation code. Recent innovations in XML data binding, or mapping XML documents to Java objects, provide the headache remedy. XML data binding lets you seamlessly program with normal Java objects that represent your XML documents. This is much more luxurious than writing that grueling XML parsing code. What's more, instead of your Java program, a DTD (document type definition) or an XML Schema can maintain all your data validation rules. Think lazy: this validation stuff could become the responsibility of the XML expert in your office -- and not of the overworked Java programmer. In this article, Sam Brodkin walks you through two frameworks for generating Java classes automatically from XML data constraints: Sun's Java Architecture for XML Binding (JAXB) and Castor from the Exolab Group. Then he shows you how easy it is to use these classes in a test program that washes his socks. (2,800 words; December 28, 2001)
Event-driven XML document processing with SAX (Simple API for XML) and SAX2 can greatly improve performance and can avoid document size limits associated with in-memory representations such as DOM (Document Object Model) or JDOM. On the other hand, trying to wrap your brain around event-driven programming can drive you to a career in sales. In this article, Dennis Sosnoski aims to keep your career on track by introducing event-handler basics in Java. (2,700 words; February 8, 2002)
Frameworks for event-driven programming simplify working with complex document structures in SAX2 (Simple API for XML). In this article, the second in a three-part series, Dennis Sosnoski extends the handling approach he introduced in Part 1, by making it fully modular and easily extensible for nested document components. But SAX2 is not the only model for parsing XML, so Dennis also introduces the most exciting developing alternative to SAX2: pull parsing. Pull parsing puts control back where it belongs -- with your application. See how the example XML processing code changes with a pull parser interface, and decide for yourself the benefits of the two approaches! (2,800 words; March 29, 2002)
As XML pull parsers for Java become standardized, it's worth asking how they perform compared to SAX2 (Simple API for XML) push parsers. In this final article of his three-part XML document series, Dennis Sosnoski looks at two pull parsers based on the new Common API for XML Pull Parsing (XMLPull), then wraps up with an XML parser performance showdown. Will the pull challengers defeat the reigning SAX2 champions? (2,600 words; April 26, 2002)
Although SAX (the Simple API for XML) parsers are handy tools for parsing XML content, developing and maintaining a SAX parser can prove difficult. In this article, Leon Messerschmidt shows you how to use the information contained in XML Schemas to generate source code for a skeleton SAX parser. You also learn techniques to accomplish common XML parsing tasks. (1,800 words; May 17, 2002)
Much of the dialog about JavaBeans focuses on how to create them, not how to use them. This article, the first in a series, gives an overview of IBM's XML Bean Suite, a toolkit of JavaBeans components for processing XML. (3,300 words)
Last month's JavaBeans column introduced IBM's XML Beans, a suite of JavaBeans that process XML files. This month, Mark looks at the XMLEditor and XMLConvenience bean sets that make creating custom XML editors a snap. (3,400 words)
Last month's JavaBeans column showed you how to use XML JavaBeans to create a simple XML editor. This month, Mark Johnson demonstrates the XMLConvenience bean set, which simplifies building visual XML processing applications with XML JavaBeans. (3,500 words)