XML and Java¿ Developing Web Applications

by ; ; ; ; ; ; ; ;
Edition: 2nd
Format: Paperback
Pub. Date: 2002-05-13
Publisher(s): Addison-Wesley Professional
List Price: $59.99

Rent Book

Select for Price
There was a problem. Please try again later.

New Book

We're Sorry
Sold Out

Used Book

We're Sorry
Sold Out

eBook

We're Sorry
Not Available

How Marketplace Works:

  • This item is offered by an independent seller and not shipped from our warehouse
  • Item details like edition and cover design may differ from our description; see seller's comments before ordering.
  • Sellers much confirm and ship within two business days; otherwise, the order will be cancelled and refunded.
  • Marketplace purchases cannot be returned to eCampus.com. Contact the seller directly for inquiries; if no response within two days, contact customer service.
  • Additional shipping costs apply to Marketplace purchases. Review shipping costs at checkout.

Summary

When we had the opportunity to write 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 concluded that a book on how to develop programs that deal with XML as data would be the most needed and that we could contribute through our experience in writing the parser. Several XML books were on the market, but most of them were either about the specifications or about creating XML documents. Few of them described how to write programs with XML as the input and output data format. Because Java was the implementation language of XML4J Parser and because many features (such as built-in Unicode character support) make XML and Java a perfect match, Java was a natural choice 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 have 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—can be combined to solve real-world problems, and to discuss how these technologies will change the way future e-Business applications will be developed. The first edition of the book was not an introduction or a reference to each technology, and neither is the second edition. 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. The first half covers basic tools for dealing with XML in Java. Here we concentrate only on the solid, stable technologies. XML technologies that were not W3C Recommendations at the time of writing are deliberately not included. That the beginning chapters are about “basic” technologies does not mean that these chapters are introductory. It simply means that these technologies and tools are the absolute minimum 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, because we covered a lot of programming techniques and hints for making the most of these tools. In the later chapters, on the other hand, we include emerging technologies, such as SOAP and Web services, that we believe are crucial for future e-Business solutions. Those who are looking for new technologies for their next projects and need to understand the potential and limitations of these technologies will find the chapters in the later chapters particularly useful.

All the sample programs in the book are available on 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 about new software technologies can be acquired only through playing with them—running them, changing the configurations and modifying lines of code, and rerunning them to see the effects. We recommend that readers try the samples on the CD-ROM as much as possible. We made every effort to ensure that the samples are complete and run on most, if not all, platforms that support the latest Java runtimes. Any updates to the contents of the book can be downloaded from the publisher’s Web site at http://www.awl.com/cseng/.



0201770040P05092002

Author Biography

Hiroshi Maruyama is Manager of Network Applications at IBM's Tokyo Research Laboratory and Associate Professor of Computer Science at the Tokyo Institute of Technology. At IBM, his team developed one of the first XML processors to be fully compliant with the XML standard as set forth by the W3C (World Wide Web Consortium). Kent Tamura and Naohiko Uramoto are members of Hiroshi's team, developing XML tools and applications. Naohiko is also a member of a W3C working group.

Table of Contents

Foreword xv
Preface xix
Web Applications, XML, and Java
1(20)
Introduction
1(5)
Structure of This Book
2(4)
Web Applications
6(9)
From Static Contents to Dynamic Contents
6(1)
From B2C to B2B-From Web for Eyeballs to Web for Programs
7(4)
Interoperability Is Everything
11(2)
From Distributed Applications to Decentralized Applications
13(2)
The World of Web Services-More Dynamic Integration
15(1)
Other Application Areas of XML
15(2)
Metadata
15(1)
Configuration Files
16(1)
Rich Documents
16(1)
Some XML Basics
17(3)
Standardization Process
17(1)
Validity and Well-Formedness
18(1)
Namespaces
19(1)
Summary
20(1)
Parsing XML Documents
21(38)
Introduction
21(4)
XML Processors
21(1)
Working with Xerces
22(3)
Basics of Parsing Documents
25(10)
Parsing Well-Formed Documents
25(4)
Parsing Valid Documents
29(5)
Design Point: Well-Formed versus Valid
34(1)
More about Parsing XML Documents
35(8)
Parsing XML Documents with Namespaces
35(3)
Parsing XML Documents with XML Schema
38(2)
Design Point: The DTD versus XML Schema
40(1)
Parsing XML Documents with JAXP
40(3)
Design Point: JAXP and Xerces Native API
43(1)
Programming Interfaces for Document Structure
43(14)
DOM: Tree-Based API
45(3)
SAX: Event-Driven API
48(7)
Design Point: DOM versus SAX
55(2)
Summary
57(2)
Generating and Serializing XML Documents
59(26)
Introduction
59(1)
Creating a DOM Tree from Scratch
60(10)
Creating a Document Object
60(2)
Creating and Appending Child Nodes
62(5)
Handling Namespaces
67(3)
Validating a Generated DOM Tree
70(4)
Serializing a DOM Tree
74(4)
Using the XMLSerializer Package
74(1)
Discussions about Serialization
75(3)
Handling Whitespace
78(5)
Internationalization
83(1)
XML Declarations
83(1)
Charset Parameter
84(1)
Summary
84(1)
Working with DOM
85(24)
Introduction
85(1)
DOM Basics
85(10)
Accessing and Updating the Status of a Node
86(1)
Accessing Structural Information
87(4)
Inserting, Detaching, and Replacing a Child Node
91(3)
DOM Tree and Attributes
94(1)
Advanced DOM
95(13)
How to Simplify Your Code by Removing Entity References
96(1)
Tree Traversal
97(2)
DOM Collection Is Live
99(1)
Moving Nodes over Documents
100(1)
Namespaces in DOM
100(8)
Summary
108(1)
Working with SAX
109(34)
Introduction
109(1)
Basic Tips for Using SAX
109(11)
ContentHandler
109(5)
Using and Writing SAX Filters
114(5)
New Features of SAX2
119(1)
DOM versus SAX
120(21)
Performance: Memory and Speed
120(8)
Conversion from DOM to SAX and Vice Versa
128(13)
Summary
141(2)
Parser Tricks
143(44)
Introduction
143(1)
General Tricks
143(12)
Namespace Validation with DTDs
144(2)
Entity Resolution
146(5)
Working with Sockets
151(4)
Basic Xerces Tricks
155(10)
Extended Parser Options
155(2)
Custom DOM Implementation
157(8)
Advanced Xerces Tricks
165(20)
The Xerces Native Interface
166(3)
Components and the Component Manager
169(1)
Parser Configurations
170(8)
Building Parser Configurations from Xerces2 Components
178(7)
Summary
185(2)
XPath and XSLT
187(48)
XPath
187(12)
What Is XPath?
187(1)
Syntax and Semantics of XPath
188(5)
XPath and Namespaces
193(2)
XPath Programming in Java
195(4)
XSLT
199(26)
What Is XSLT?
200(1)
Syntax and Semantics of XSLT
200(11)
XSLT Programming in Java
211(14)
Pros and Cons of XSLT, XPath, DOM, and SAX
225(8)
Execution Efficiency
225(1)
Development Efficiency
226(7)
Summary
233(2)
Bridging Application Data Structure and XML
235(24)
Introduction
235(2)
Mapping to Almost Isomorphic Tree Structures
237(6)
Structure Adjustment by XSLT
243(3)
Mapping to Tables
246(1)
Mapping to Hash Tables
247(4)
Mapping to Graph Structures
251(6)
Summary
257(2)
Working with Schemas: Datatypes and Namespaces
259(36)
Introduction
259(1)
W3C XML Schema
260(21)
Mimicking DTDs
261(9)
Datatypes
270(6)
Using Namespaces
276(4)
Advanced Features
280(1)
Further Information
281(1)
Relax NG
281(12)
Mimicking DTDs
282(6)
Using Datatypes and Facets of W3C XML Schema
288(1)
Using Namespaces
289(1)
Co-occurrence Constraints
290(2)
Further Information
292(1)
Summary
293(2)
XML Application Server
295(58)
The Background of the XML Application Server
295(3)
The Need for a Common Framework for Building Web Applications
296(1)
What Is an XML Application Server?
297(1)
Servlet
298(32)
Returning XML Documents from a Servlet
299(11)
Receiving XML Documents
310(18)
Considerations for State Management
328(2)
JavaServer Pages
330(14)
What Is JSP?
330(3)
An Informational JSP Returning XML Documents
333(4)
The Combination of Servlet and JSP
337(7)
Apache Cocoon
344(7)
Having Well-Grounded Goals
344(2)
Integrating and Multichanneling XML Documents Using Cocoon
346(5)
Summary
351(2)
XML and Databases
353(54)
Introduction
353(1)
Storing and Searching for XML Documents
354(3)
Mapping from an XML Document to Tables
357(6)
Designing Relational Tables
360(1)
Defining the Primary Keys in a Table
360(1)
Designing a Table for Multiply Occurring Elements
360(1)
Datatype Mapping
361(1)
Semantics of Data
361(1)
Two Approaches
362(1)
Mapping from Tables to an XML Document
363(4)
Nested and Flat Representation
364(3)
Element versus Attribute Representation
367(1)
Program Examples
367(31)
Mapping Method
368(14)
XPath Method
382(16)
A Servlet for Accessing a Database
398(3)
Working with EJB
401(5)
The Importance of EJB
401(2)
A Simple EJB
403(3)
Summary
406(1)
XML Messaging
407(56)
Introduction
407(5)
Distributed Computing and Interoperability
407(2)
Overview of XML Messaging
409(2)
New-Generation Distributed Programming
411(1)
Simple Object Access Protocol
412(15)
The Birth of Soap
412(1)
Travel Reservation Example
413(5)
Basic Concepts of SOAP
418(8)
To Use SOAP or Not?
426(1)
SOAP Engines
427(34)
Prototyping a Soap Engine
427(26)
Soap Engine Products
453(6)
Java API for SOAP
459(2)
Summary
461(2)
Web Services
463(58)
Emergence of Web Services
463(4)
Publishing, Finding, and Integration
463(2)
What Are Web Services?
465(1)
Status of Web Services
466(1)
Web Services Description
467(24)
Overview of WSDL
467(7)
WSDL as an Interface Definition Language
474(4)
WSDL Tools
478(3)
Programming with WSDL4J
481(9)
JAX-RPC
490(1)
Service Registration and Discovery
491(17)
Overview of UDDI
492(3)
Programming with UDDI4J
495(11)
Registering WSDL with the UDDI Registry
506(2)
Application to Dynamic e-Business
508(9)
Application Scenario
508(2)
Discovering Businesses on the Fly
510(3)
Dynamic Binding
513(4)
Enterprise Web Services
517(2)
Summary
519(2)
Security
521(40)
Introduction
521(1)
IT System Security in General
522(1)
Security Requirements on B2B Systems
522(3)
Security of Communication
523(1)
Access Control
524(1)
SSL/TLS
525(13)
Server Authentication
525(1)
Client Authentication
526(2)
Selecting a Public-Key Infrastructure
528(2)
Configuring a Server and a Client for SSL/TLS
530(3)
SSL/TLS Programming in Java
533(3)
Firewall Considerations
536(1)
Summary of Using SSL/TLS
537(1)
XML Digital Signature
538(12)
XML Canonicalization
538(2)
XML Digital Signature Sample
540(2)
Signing XML Documents with XML Security Suite for Java
542(5)
Verifying XML Digital Signature with XML Security Suite for Java
547(3)
Access Control in Java
550(7)
Declarative Access Control and Programmatic Access Control
550(2)
Declarative Access Control
552(1)
Programmatic Access Control
553(4)
Security Architecture of EJB
557(1)
Security in Web Services
557(3)
Using SSL/TLS and XML Digital Signature in SOAP
558(1)
Access Control in SOAP Applications
558(1)
Partial Encryption of XML
558(1)
Security Service as Web Services
559(1)
Summary
560(1)
Data Binding
561(24)
Introduction
561(1)
Generating Java Classes from a Schema
561(12)
JAXB
562(5)
Relaxer
567(6)
Pros and Cons of Generating a Java Program from a Schema
573(1)
Generating an XML Document from Java Classes
573(11)
Castor XML
574(5)
Pros and Cons of Generating XML Documents from Java Classes
579(3)
SOAP Encoding
582(2)
Summary
584(1)
Principles of Schema Languages
585(26)
Introduction
585(1)
Schemas as Syntactic Constraints
586(6)
Checking Unexpected Documents
586(2)
What Happens If We Neglect Schemas?
588(3)
Desiderata for Schema Languages
591(1)
Schemas as Data Models
592(9)
Documents as Character Strings
592(2)
Documents as Trees
594(3)
Documents as Data Compliant with Schemas
597(2)
Documents as Information for Web Applications
599(1)
Desiderata for Schema Languages
600(1)
Interworking with Other Software
601(2)
Interworking with Programming Languages
601(1)
Relational Databases
602(1)
Desiderata for Schema Languages
602(1)
General-Purpose Schema Languages
603(3)
DTD
603(1)
W3C XML Schema
603(1)
RELAX NG
604(1)
Schematron
605(1)
Special-Purpose Schema Languages
606(3)
RDF Schema
606(2)
RELAX Namespace
608(1)
Summary
609(2)
Appendix A About the CD-ROM 611(2)
Appendix B Useful Links and Books 613(8)
B.1 XML
613(3)
B.1.1 General
613(1)
B.1.2 Software
614(1)
B.2 Java
615(1)
B.2.1 Platform and SDK
615(1)
B.2.2 Web Applications
615(1)
B.2.3 Database
615(1)
B.2.4 Messaging
615(1)
B.2.5 Security
616(1)
B.3 Web Services
616(1)
B.3.1 General
616(1)
B.3.2 Software
616(1)
B.4 Standards
616(1)
B.5 Books
617(4)
B.5.1 Java
617(1)
B.5.2 XML/SGML
618(1)
B.5.3 Web Services
619(1)
B.5.4 Other Topics
619(2)
Appendix C XML-Related Standardization Activities 621(20)
C.1 XML Core
622(2)
C.1.1 Namespace
622(1)
C.1.2 XML Fragment Interchange
622(1)
C.1.3 XML Inclusions
623(1)
C.1.4 XML Infoset
624(13)
C.2 XML Tools
625(2)
C.2.1 XPath
625(1)
C.2.2 XML Pointer, XML Base, and XML Linking
625(1)
C.2.3 Extensible Stylesheet Language
626(1)
C.3 Schema Languages
627(2)
C.3.1 XML Schema
627(1)
C.3.2 Relax Ng
628(1)
C.3.3 Schematron
629(1)
C.4 APIs
629(2)
C.4.1 Document Object Model
629(1)
C.4.2 Simple API for XML
630(1)
C.5 XML Security
631(2)
C.5.1 XML Signature
631(1)
C.5.2 XML Encryption
631(1)
C.5.3 Platform for Privacy Preferences Project
632(1)
C.6 Web Services
633(1)
C.6.1 XML Protocol (SOAP)
633(1)
C.6.2 Web Services Description Language
634(1)
C.6.3 Universal Description, Discovery, and Integration
634(1)
C.7 Java Specification Requests
634(3)
C.8 Other Topics
637(1)
C.8.1 Web Distributed Authoring and Versioning
637(1)
C.8.2 Wireless Markup Language
638(3)
C.8.3 XHTML
638(1)
C.8.4 XML Query
639(2)
Appendix D JDBC Primer 641(10)
D.1 Introduction
641(1)
D.2 JDBC Package
642(2)
D.3 Loading a JDBC Driver
644(1)
D.4 Connecting to a Database
645(1)
D.5 Submitting a Query
646(2)
D.6 Using a Connection Pool
648(3)
Index 651

Excerpts

When we had the opportunity to write 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 concluded that a book on how to develop programs that deal with XML as data would be the most needed and that we could contribute through our experience in writing the parser. Several XML books were on the market, but most of them were either about the specifications or about creating XML documents. Few of them described how to write programs with XML as the input and output data format. Because Java was the implementation language of XML4J Parser and because many features (such as built-in Unicode character support) make XML and Java a perfect match, Java was a natural choice 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 have the same goals in this edition with more new technologiesto show how the emerging technologies around XML and Java such as DOM Level 2, SAX2, XSLT, J2EE, XML Schema, and Web servicescan be combined to solve real-world problems, and to discuss how these technologies will change the way future e-Business applications will be developed. The first edition of the book was not an introduction or a reference to each technology, and neither is the second edition. 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. The first half covers basic tools for dealing with XML in Java. Here we concentrate only on the solid, stable technologies. XML technologies that were not W3C Recommendations at the time of writing are deliberately not included. That the beginning chapters are about "basic" technologies does not mean that these chapters are introductory. It simply means that these technologies and tools are the absolute minimum 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, because we covered a lot of programming techniques and hints for making the most of these tools. In the later chapters, on the other hand, we include emerging technologies, such as SOAP and Web services, that we believe are crucial for future e-Business solutions. Those who are looking for new technologies for their next projects and need to understand the potential and limitations of these technologies will find the chapters in the later chapters particularly useful.All the sample programs in the book are available on 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 about new software technologies can be acquired only through playing with themrunning them, changing the configurations and modifying lines of code, and rerunning them to see the effects. We recommend that readers try the samples on the CD-ROM as much as possible. We made every effort to ensure that the samples are complete and run on most, if not all, platforms that support the latest Java runtimes. Any updates to the contents of the book can be downloaded from the publisher's Web site at http://www.awl.com/cseng/ . 0201770040P05092002

An electronic version of this book is available through VitalSource.

This book is viewable on PC, Mac, iPhone, iPad, iPod Touch, and most smartphones.

By purchasing, you will be able to view this book online, as well as download it, for the chosen number of days.

Digital License

You are licensing a digital product for a set duration. Durations are set forth in the product description, with "Lifetime" typically meaning five (5) years of online access and permanent download to a supported device. All licenses are non-transferable.

More details can be found here.

A downloadable version of this book is available through the eCampus Reader or compatible Adobe readers.

Applications are available on iOS, Android, PC, Mac, and Windows Mobile platforms.

Please view the compatibility matrix prior to purchase.