HAPPY BOOKSGIVING
Use code BOOKSGIVING during checkout to save 40%-55% on books and eBooks. Shop now.
Register your product to gain access to bonus material or receive a coupon.
Topic coverage includes:
The first edition of XML and Java earned rave reviews for its exceptionally practical, thorough, and example-rich coverage of XML development with Java. Now, the authors -- all leading-edge XML experts from IBM -- have updated the book to reflect the latest XML tools, technologies, and best practices. From start to finish, they provide expert insight and "jumpstart" examples that are immediately applicable to real-world problems. Coverage includes: parsing and generating XML documents; working with DOM/DOM2 and SAX/SAX2; schemas and validation; document manipulation with XPath and XSLT; and utilizing advanced XML parsers. The authors introduce XML programming with servlets and JSP; XML database integration; XML messaging and Web services; data binding and security solutions; and more.
Web Services in Perspective: What Is Its Value, and Why Should We Care?
XML and Web Services Security: How Can We Protect XML-based B2B Systems?
XML and Java: Bridging Application Data Structure and XML
Click below for Sample Chapter(s) related to this title:
Sample
Chapter 8
Foreword.
Preface.
1. Web Applications, XML, and Java.
Introduction.
Structure of This Book.
Web Applications.
From Static Contents to Dynamic Contents.
From B2C to B2B-From Web for Eyeballs to Web for Programs.
Interoperability Is Everything.
From Distributed Applications to Decentralized Applications.
The World of Web Services-More Dynamic Integration.
Other Application Areas of XML.
Metadata.
Configuration Files.
Rich Documents.
Some XML Basics.
Standardization Process.
Validity and Well-Formedness.
Namespaces.
Summary.
Introduction.
XML Processors.
Working with Xerces.
Basics of Parsing Documents.
Parsing Well-Formed Documents.
Parsing Valid Documents.
Design Point: Well-Formed versus Valid.
More about Parsing XML Documents.
Parsing XML Documents with Namespaces.
Parsing XML Documents with XML Schema.
Design Point: The DTD versus XML Schema.
Parsing XML Documents with JAXP.
Design Point: JAXP and XercesNative API.
Programming Interfaces for Document Structure.
DOM: Tree-Based API.
SAX: Event-Driven API.
Design Point: DOM versus SAX.
Summary.
Introduction.
Creating a DOM Tree from Scratch.
Creating a Document Object.
Creating and Appending Child Nodes.
Handling Namespaces.
Validating a Generated DOM Tree.
Serializing a DOM Tree.
Using the XMLSerializer Package.
Discussions about Serialization.
Handling Whitespace.
Internationalization.
XML Declarations.
Charset Parameter.
Summary.
Introduction.
DOM Basics.
Accessing and Updating the Status of a Node.
Accessing Structural Information.
Inserting, Detaching, and Replacing a Child Node.
DOM Tree and Attributes.
Advanced DOM.
How to Simplify Your Code by Removing Entity References.
Tree Traversal.
DOM Collection Is Live.
Moving Nodes over Documents.
Namespaces in DOM.
Summary.
Introduction.
Basic Tips for Using SAX.
ContentHandler.
Using and Writing SAX Filters.
New Features of SAX2.
DOM versus SAX.
Performance: Memory and Speed.
Conversion from DOM to SAX and Vice Versa.
Summary.
Introduction.
General Tricks.
Namespace Validation with DTDs.
Entity Resolution.
Working with Sockets.
Basic Xerces Tricks.
Extended Parser Options.
Custom DOM Implementation.
Advanced Xerces Tricks.
The Xerces Native Interface.
Components and the Component Manager.
Parser Configurations.
Building Parser Configurations from Xerces2 Components.
Summary.
XPath.
What Is XPath?
Syntax and Semantics of XPath.
XPath and Namespaces.
XPath Programming in Java.
XSLT.
What Is XSLT?
Syntax and Semantics of XSLT.
XSLT Programming in Java.
Pros and Cons of XSLT, XPath, DOM, and SAX.
Execution Efficiency.
Development Efficiency.
Summary.
Introduction.
Mapping to Almost Isomorphic Tree Structures.
Structure Adjustment by XSLT.
Mapping to Tables.
Mapping to Hash Tables.
Mapping to Graph Structures.
Summary.
Introduction.
W3C XML Schema.
Mimicking DTDs.
Datatypes.
Using Namespaces.
Advanced Features.
Further Information.
RELAX NG.
Mimicking DTDs.
Using Datatypes and Facets of W3C XML Schema.
Using Namespaces.
Co-occurrence Constraints.
Further Information.
Summary.
The Background of the XML Application Server.
The Need for a Common Framework for Building Web Applications.
What Is an XML Application Server?
Servlet.
Returning XML Documents from a Servlet.
Receiving XML Documents.
Considerations for State Management.
JavaServer Pages.
What Is JSP?
An Informational JSP Returning XML Documents.
The Combination of Servlet and JSP.
Apache Cocoon.
Having Well-Grounded Goals.
Integrating and Multichanneling XML Documents Using Cocoon.
Summary.
Introduction.
Storing and Searching for XML Documents.
Mapping from an XML Document to Tables.
Designing Relational Tables.
Defining the Primary Keys in a Table.
Designing a Table for MultiplyOccurring Elements.
Datatype Mapping.
Semantics of Data.
Two Approaches.
Mapping from Tables to an XML Document.
Nested and Flat Representation.
Element versus Attribute Representation.
Program Examples.
Mapping Method.
XPath Method.
A Servlet for Accessing a Database.
Working with EJB.
The Importance of EJB.
A Simple EJB.
Summary.
Introduction.
Distributed Computing and Interoperability.
Overview of XML Messaging.
New-Generation Distributed Programming.
Simple Object Access Protocol.
The Birth of SOAP.
Travel Reservation Example.
Basic Concepts of SOAP.
To Use SOAP or Not?
SOAP Engines.
Prototyping a SOAP Engine.
SOAP Engine Products.
Java API for SOAP.
Summary.
Emergence of Web Services.
Publishing, Finding, and Integration.
What Are Web Services?
Status of Web Services.
Web Services Description.
Overview of WSDL.
WSDL as an Interface Definition Language.
WSDL Tools.
Programming with WSDL4J.
JAX-RPC.
Service Registration and Discovery.
Overview of UDDI.
Programming with UDDI4J.
Registering WSDL with the UDDI Registry.
Application to Dynamic e-Business.
Application Scenario.
Discovering Businesses on the Fly.
Dynamic Binding.
Enterprise Web Services.
Summary.
Introduction.
IT System Security in General.
Security Requirements on B2B Systems.
Security of Communication.
Access Control.
SSL/TLS.
Server Authentication.
Client Authentication.
Selecting a Public-Key Infrastructure.
Configuring a Server and a Client for SSL/TLS.
SSL/TLS Programming in Java.
Firewall Considerations.
Summary of Using SSL/TLS.
XML Digital Signature.
XML Canonicalization.
XML Digital Signature Sample.
Signing XML Documents with XML Security Suite for Java.
Verifying XML Digital Signature with XML Security Suite for Java.
Access Control in Java.
Declarative Access Control and Programmatic Access Control.
Declarative Access Control.
Programmatic Access Control.
Security Architecture of EJB.
Security in Web Services.
Using SSL/TLS and XML Digital Signature in SOAP.
Access Control in SOAP Applications.
Partial Encryption of XML.
Security Service as Web Services.
Summary.
Introduction.
Generating Java Classes from a Schema.
JAXB.
Relaxer.
Pros and Cons of Generating a Java Program from a Schema
Generating an XML Document from Java Classes.
Castor XML.
Pros and Cons of Generating XML Documents from Java Classes.
SOAP Encoding.
Summary.
Introduction.
Schemas as Syntactic Constraints.
Checking Unexpected Documents.
What Happens If We Neglect Schemas?
Desiderata for Schema Languages.
Schemas as Data Models.
Documents as Character Strings.
Documents as Trees.
Documents as Data Compliant with Schemas.
Documents as Information for Web Applications.
Desiderata for Schema Languages.
Interworking with Other Software.
Interworking with Programming Languages.
Relational Databases.
Desiderata for Schema Languages.
General-Purpose Schema Languages.
DTD.
W3C XML Schema.
RELAX NG.
Schematron.
Special-Purpose Schema Languages.
RDF Schema.
RELAX Namespace.
Summary.
XML.
General.
Software.
Java.
Platform and SDK.
Web Applications.
Database.
Messaging.
Security.
Web Services.
General.
Software.
Standards.
Books.
Java.
XML/SGML.
Web Services.
Other Topics.
XML Core.
Namespace.
XML Fragment Interchange.
XML Inclusions.
XML Infoset.
XML Tools.
XPath.
XML Pointer, XML Base, and XML Linking.
Extensible Stylesheet Language.
Schema Languages.
XML Schema.
RELAX NG.
Schematron.
APIs.
Document Object Model.
Simple API for XML.
XML Security.
XML Signature.
XML Encryption.
Platform for Privacy Preferences Project.
Web Services.
XML Protocol (SOAP).
Web Services Description Language.
Universal Description, Discovery, and Integration.
Java Specification Requests.
Other Topics.
Web Distributed Authoring and Versioning.
Wireless Markup Language.
XHTML.
XML Query.
Introduction.
JDBC Package.
Loading a JDBC Driver.
Connecting to a Database.
Submitting a Query.
Using a Connection Pool.
When we had an opportunity of writing a book on XML in February 1998, which was just after we had released the first XML4J Parser from IBM’s alphaWorks Web site, we discussed what we could achieve through publishing a book. We immediately came to a conclusion that a book on how to develop programs that deal with XML as data would be the most needed and we could contribute through our experience in writing the parser. There were several XML books on the market but most of them were either about the specifications themselves or about creating XML documents. Very few of them described how to write programs with XML as input and output data format. Because Java was the implementation language of XML4J Parser, and also because there are many features that make XML and Java are a perfect match such as built-in Unicode character support, it was a natural choice to pick Java as the programming language. More importantly, Java was becoming the mainstream language for server side programming. We believe that the first edition of the book satisfied, at least to a certain extent, the needs of developers who desperately needed to know the potential and limitations of these two emerging technologies and how they can be best applied to real world situations.
We keep the same goals in this edition with more new technologies—to show how the emerging technologies around XML and Java, such as DOM Level 2, SAX2, XSLT, J2EE, XML Schema, and Web Services, are combined to solve real world problems and to discuss how these technologies will change the way the future e-Business applications will be developed. The first edition of the book was never an introduction nor a reference to each technology piece, and the second edition is not, either. Each of these topics is worth an entire book. We do not list all the features of these technologies. Instead, we explain why you should be interested in them and how you can apply them to your problem by showing real world examples.
This book has two parts. Part I covers basic tools for dealing with XML in a Java environment. Here we concentrate on the solid, stable technologies only. XML technologies that were not W3C recommendations at the time of writing, are not included deliberately. That Part I is about “basic” technologies does not mean that these chapters are introductory. It simply means that these technologies and tools are the absolute minimum that you need to understand in order to develop an XML-based application. Seasoned developers who trust only basic and proven tools will also find these chapters useful, as we covered a lot of programming techniques and hints for making the most out of these tools. In Part II, on the other hand, we included emerging technologies such as SOAP and Web Services, which we believe crucial for the future e-business solutions. For those who are looking for new technologies for their next projects and need to understand the potential and limitations of these technologies, chapters in Part II will be particularly useful.
All the sample programs in the book are available in the accompanying CD-ROM. Each sample has its own README file that describes how to set up and run it. It is our strong belief that knowledge on new software technologies can be acquired only through playing with them—running them, changing the configurations and modifying lines of code and re-running them to see the effects. We recommend that the readers try the samples in the CD-ROM as much as possible. We made every effort that the samples are complete and run on most, if not all, platforms that support the latest Java runtimes. Any updates on the contents of the book can be downloaded from the publisher’s Web site.
Hiroshi Maruyama, Kent Tamura, and Naohiko Uramoto released one of the first books that provided a practical introduction to developing XML applications using Java in early 1999. Three years later, much has happened in the XML community: many new specifications have been released that were not discussed in the first edition, and some have been widely implemented in both commercial products and open source software, usually written in Java. Furthermore, the Java and XML communities have become more tightly integrated than they were in 1999, when many Java developers saw XML as more of a threat than an opportunity. Now the mantra “Java is portable code, XML is portable data” is repeated frequently.
The release of XML and Java, Second Edition roughly coincides with the release of JDK 1.4, which incorporates XML technologies into the very core of Java. Sun has defined the Java API for XML Processing (JAXP) that incorporates both the de facto standard SAX API and the World Wide Web Consortium’s Document Object Model (DOM) API. Also, JAXP fills in some of the gaps between these cross-platform standards to define JAXP APIs for loading, configuring, and invoking an XML parser and serializing DOM objects to XML text. Additional Java tools are being developed to assist in other XML-related tasks, such as the JAXM for XML messaging and JAXB to “compile” XML schemas into Java classes that automatically parse, validate, and serialize instances of them. Even more importantly, the basic XML functionality is automatically available to JDK and JRE 1.4 users without additional downloading or installation.
XML and Java, Second Edition is an excellent resource for Java developers and system architects or advanced students needing to understand how to work with these new XML features being tightly bundled with Java. It assumes a basic working knowledge of XML and Java, so the experienced reader need not skip over widely covered introductory material. Furthermore, it exploits the combined expertise of the various authors while avoiding most of the discontinuity, redundancy, and inconsistency all too common in multi-author books.
The book is organized into two parts, the first set of chapters (mostly written by Maruyama, Tamura, and Uramoto) effectively covers the core XML technologies such as XML namespaces, SAX, DOM, schemas, and XSLT and how they can be used in Java programs. Part II primarily covers more experimental or Java-specific tools such as application servers and EJB, messaging, data binding, and Web Services tools such as SOAP, UDDI, and WSDL. In less knowledgeable hands, this wealth of material could be overwhelming, but the authors’ deep expertise in these subjects allows them to handle it quite effectively, offering both concrete examples and high-level design guidance. Ryo Neyama’s Chapter 10 provides a very useful overview of server-side Java XML programming using servlets, JSP, and Apache Cocoon. Yuichi Nakamura contributes two chapters on XML messaging and Web services that clearly show that Java developers have all they tools they need to participate in the Web Services revolution. The principal authors contribute chapters describing the state of the art in using databases, security services, and the generation of Java classes from XML schema. The accompanying CD-ROM contains plenty of material for hands-on learning of the techniques covered in the book.
The emphasis throughout the book is on how to use the cross-platform standard tools from Java code; the authors do not succumb to the temptation to spend much time on those XML tools that exploit Java’s strengths and idioms. This leaves the reader better equipped to work with XML on other platforms as well as from Java, and the knowledgeable Java programmer who understands the XML standards will have little trouble picking up the Java-specific tools.
This is not to say that the authors uncritically describe the Sun or W3C view of Java or XML. It provides an independent perspective, such as by illustrating how to use the Apache Xerces XML parser via the Java-standard JAXP interfaces instead of the Crimson parser included with JAXP. Likewise, Andy Clark’s Chapter 6 on Parser Tricks shows how to use some of the more complex and obscure bits of XML (such as external parsed entities) effectively by using the features of the Apache Xerces parser. Other challenges one faces in the terra incognita at the borders of XML and Java technology are described, and routes around the worst pitfalls mapped.
One especially valuable feature of XML and Java, Second Edition is its treatment of the rather contentious subject of XML schemas and DTDs. XML 1.0 defines a Document Type Definition syntax describing constraints on XML structures that a validating parser must enforce, and the W3C has more recently produced Recommendation defining an XML Schema Definition Language. The W3C schema language has not been particularly well received in the XML community, however, and several alternatives have been proposed. The International Organization for Standardization has undertaken an effort to define an international standard ISO/IEC JTC1/SC34 Document Schema Definition Language (DSDL), which covers XML DTDs, W3C schemas, the RELAX-NG XML schema language, and the Schematron XPath-based tree pattern constraint language. It appears that XML users will have a menu of standard schema language options to choose from, some more appropriate than others for specific situations but none completely suitable for all scenarios.
This book has two chapters covering these subjects written by Makoto Murata, a co-author of the RELAX-NG specification and a researcher who has convincingly applied mathematical techniques to practical problems in the XML world. Chapter 9 presents information about XML schemas likely to be most useful to practitioners: it says what problems they are supposed to solve, presents the ways in which DTDs, W3C Schema, and RELAX-NG address these problems, and summarizes the strengths and weaknesses of each. Chapter 16 addresses the larger principles at stake here in more depth, covering additional schema languages such as Schematron and RDF Schema. Together, these chapters provide a concise but rather profound summary of the state of the art in XML schema language theory and practice that should be of great use in guiding Java developers through the dynamic but confusing world of XML schemas.
The first edition of XML and Java played an important role in introducing Java developers to XML. The second edition not only brings this introduction up to date as Java and XML have evolved, but also shows the authors’ deepening understanding of these technologies and how they fit together.
Michael Champion
Advisory Research and Development Specialist, Software AG
Darmstadt, Germany
Click below to download the Index file related to this title:
Index