Next: Getting Started
Up: XML Enhancements to Java™
Previous: XML Enhancements to Java™
Subsections
Introduction
XML has emerged as the de facto standard for data integration;
it has become an integral part of diverse application domains such as
databases, messaging systems, Web Services, etc. Despite the
popularity of XML, current mechanisms for developing XML-based
applications in Java are low level. For example, APIs such as W3C Document
Object Module (DOM) [World Wide Web
Consortium 2000] or Simple API for XML (SAX) [SAX ],
provide minimal support for ensuring that programs are correct with respect
to the XML Schemas [Thompson et al. 2004] governing the XML data. With
data-binding approaches such as Java Architecture for XML Binding
(JAXB) [Vajjhala and
Fialli 2004], a programmer must
understand how the specification maps XML Schemas to Java™
classes and cannot program purely in terms of the XML data.
Furthermore, there is no support for ensuring the correctness of XPath
expressions [Clark and
DeRose 1999] evaluated against documents. In these
systems, a mistyped XPath expression (where one of the element names is
misspelled) would not raise an error at run time -- it would silently
return no results. Finally, runtime library approaches to XML, such as
DOM, cannot take advantage
of compiler techniques in order to optimize the performance of XML
processing. The high cost of processing XML is a common complaint.
XML Enhancements to Java™, or XJ,
is a research language designed to facilitate the development of
applications that process XML data. It is
a strict extension to Java 1.4 --
programs that are valid according to the Java Language Specification
1.4 [Gosling
et al. 2000] are valid XJ programs; they have identical
behavior in both languages. XJ adds a few constructs to Java to
facilitate XML processing:
- The semantics of the import statement is extended to
allow for the import of XML Schemas, in addition to packages and types.
Element declarations in an imported XML Schema are
available to a programmer as classes.
- Programmers may write XPath expressions inline to navigate and extract
information from XML data. The XJ compiler type checks XPath expressions
with respect to appropriate XML Schema types to detect errors.
- Programmers may construct XML data by writing literal XML inline. Again,
the compiler ensures that the constructed XML is valid with respect to
appropriate XML types.
- The result of compiling an XJ class is standard bytecode that can be
executed on any Java Virtual Machine.
In subsequent sections, we describe how to install the XJ system, compile
and execute programs (§2). We provide an overview of
the constructs of the XJ programming language (§3), and
discuss the limitations of the current system (§4).
XJ is an evolving language and we will be adding features that address
some of the current limitations (§5). We welcome
any suggestions for improvement both in terms of syntax as well as
language semantics.
All examples in this manual refer to the Totals.xj sample which is
provided with the XJ distribution. The XML Schema used by the sample,
the Totals.xj XJ class, and input data are provided for reference in
Appendix A.
The "sample code" typesetting is used to highlight sample XJ code, and
the "schema construct" typesetting is used to highlight XML Schema constructs.
To get the latest XJ information (including the latest version of this
manual) on-line, access the IBM external XJ project page at
http://www.research.ibm.com/xj/.
Reporting Bugs
Please either use the XJ forum on alphaWorks (http://alphaworks.ibm.com/tech/xj) or
send mail to xj@watson.ibm.com.
Next: Getting Started
Up: XML Enhancements to Java™
Previous: XML Enhancements to Java™
XJ Group
2005-09-13