“ The sophistication and language are very appropriate for Java and XML application developers. You can tell by the way the author writes that he too is a developer. He delves very deeply into the topics and has really taken things apart and investigated how they work. I especially like his coverage of ‘ gotchas, ’ pitfalls, and limitations of the technologies.” — John Wegis, Web Engineer, Sun Microsystems, Inc.
“ Elliotte has written an excellent book on XML that covers a lot of ground and introduces current and emerging technologies. He helps the novice programmer understand the concepts and principles of XML and related technologies, while covering the material at a level that’ s deep enough for the advanced developer. With a broad coverage of XML technologies, lots of little hints, and information I haven’ t seen in any other book on the topic, this work has become a valuable addition to my technical library.” — Robert W. Husted, Member, Technical Staff, Requisite Technology, Inc.
“ The code examples are well structured and easy to follow. They provide real value for someone writing industrial-strength Java and XML applications. The time saved will repay the cost of this book a hundred times over.
“ The book also contains more of the pearls of wisdom we’ ve come to expect from Elliotte Rusty Harold— the kind of pointers that will save developers weeks, if not months, of time.” — Ron Weber, Independent Software Consultant Written for Java programmers who want to integrate XML into their systems, this practical, comprehensive guide and reference shows how to process XML documents with the Java programming language. It leads experienced Java developers beyond the basics of XML, allowing them to design sophisticated XML applications and parse complicated documents."Processing XML with Java™ " provides a brief review of XML fundamentals, including XML syntax; DTDs, schemas, and validity; stylesheets; and the XML protocols XML-RPC, SOAP, and RSS. The core of the book comprises in-depth discussions on the key XML APIs Java programmers must use to create and manipulate XML files with Java. These include the Simple API for XML (SAX), the Document Object Model (DOM), and JDOM (a Java native API). In addition, the book covers many useful supplements to these core APIs, including XPath, XSLT, TrAX, and JAXP.Practical in focus, "Processing XML with Java™ "is filled with over two hundred examples that demonstrate how to accomplish various important tasks related to file formats, data exchange, document transformation, and database integration. You will learn how to read and write XML documents with Java code, convert legacy flat files into XML documents, communicate with network servers that send and receive XML data, and much more. Readers will find detailed coverage of the following: How to choose the right API for the jobReading documents with SAXSAX filtersValidation in several schema languagesDOM implementations for JavaThe DOM Traversal ModuleOutput from DOMReading and writing XML documents with JDOMSearchingXML documents with XPathCombining XSLT transforms with Java code TrAX, the Transformations API for XMLJAXP, the Java API for XML ProcessingIn addition, the book includes a convenient quick reference that summarizes the major elements of all the XML APIs discussed. A related Web site, located at http: //www.cafeconleche.org/books/xmljava/, contains the entire book in electronic format, as well as updates and links referenced in the book.With thorough coverage of the key XML APIs and a practical, task-oriented approach, "Processing XML with Java™ " is a valuable resource for all Java programmers who need to work with XML.
(NOTE: Each chapter concludes with a Summary.)List of Examples. List of Figures. Preface. Who You Are.What You Need to Know.What You Need to Have.How to Use This Book.The Online Edition.Some Grammatical Notes.Contacting the Author.Acknowledgments.I. XML. 1. XML for Data. Motivating XML.A Thought Experiment.Robustness.Extensibility.Ease-of-Use.XML Syntax.XML Documents.XML Applications.Elements and Tags.Text.Attributes.XML Declaration.Comments.Processing Instructions.Entities.Namespaces.Validity.DTDs.Schemas.Schematron.The Last Mile.Stylesheets.CSS.Associating Stylesheets with XML Documents.XSL.2. XML Protocols: XML-RPC and SOAP. XML as a Message Format.Envelopes.Data Representation.HTTP as a Transport Protocol.How HTTP Works.HTTP in Java.RSS.Customizing the Request.Query Strings.How HTTP POST Works.XML-RPC.Data Structures.Faults.Validating XML-RPC.SOAP.A SOAP Example.Posting SOAP Documents.Faults.Encoding Styles.SOAP Headers.SOAP Limitations.Validating SOAP.Custom Protocols.3. Writing XML with Java. Fibonacci Numbers.Writing XML.Better Coding Practices.Attributes.Producing Valid XML.Namespaces.Output Streams, Writers, and Encodings.A Simple XML-RPC Client.A Simple SOAP Client.Servlets.4. Converting Flat Files to XML. The Budget.The Model.Input.Determining the Output Format.Validation.Attributes.Building Hierarchical Structures from Flat Data.Alternatives to Java.Imposing Hierarchy with XSLT.The XML Query Language.Relational Databases.5. Reading XML. InputStreams and Readers.XML Parsers.Choosing an XML API.Choosing an XML Parser.Available Parsers.SAX.DOM.JAXP.JDOM.dom4j.ElectricXML.XMLPULL.II. SAX. 6. SAX. What Is SAX?Parsing.Callback Interfaces.Implementing ContentHandler.Using the ContentHandler.The DefaultHandler Adapter Class.Receiving Documents.Receiving Elements.Handling Attributes.Receiving Characters.Receiving Processing Instructions.Receiving Namespace Mappings."Ignorable White Space".Receiving Skipped Entities.Receiving Locators.What the ContentHandler Doesn't Tell You.7. The XMLReader Interface. Building Parser Objects.Input.InputSource.EntityResolver.Exceptions and Errors.SAXExceptions.The ErrorHandler Interface.Features and Properties.Getting and Setting Features.Getting and Setting Properties.Required Features.Standard Features.Standard Properties.Xerces Custom Features.Xerces Custom Properties.DTDHandler.8. SAX Filters. The Filter Architecture.The XMLFilter Interface.Content Filters.Filtering Tags.Filtering Elements.Filtering Attributes.Filters That Add Content.Filters versus Transforms.The XMLFilterImpl Class.Parsing Non-XML Documents.Multihandler Adapters.III. DOM. The Document Object Model.The Evolution of DOM.DOM Modules.Application-Specific DOMs.Trees.Document Nodes.Element Nodes.Attribute Nodes.Leaf Nodes.Nontree Nodes.What Is and Isn't in the Tree.DOM Parsers for Java.Parsing Documents with a DOM Parser.JAXP DocumentBuilder and DocumentBuilderFactory.DOM3 Load and Save.The Node Interface.Node Types.Node Properties.Navigating the Tree.Modifying the Tree.Utility Methods.The NodeList Interface.JAXP Serialization.DOMException.Choosing between SAX and DOM.10. Creating XML Documents with DOM. DOMImplementation.Locating a DOMImplementation.Implementation-Specific Class.JAXP DocumentBuilder.DOM3 DOMImplementationRegistry.The Document Interface as an Abstract Factory.The Document Interface as a Node Type.Getter Methods.Finding Elements.Transferring Nodes between Documents.Normalization.11 The DOM Core. The Element Interface.Extracting Elements.Attributes.The NamedNodeMap Interface.The CharacterData Interface.The Text Interface.The CDATASection Interface.The EntityReference Interface.The Attr Interface.The ProcessingInstruction Interface.The Comment Interface.The DocumentType Interface.The Entity Interface.The Notation Interface.12. The DOM Traversal Module. NodeIterator.Constructing NodeIterators with DocumentTraversal.Liveness.Filtering by Node Type.NodeFilter.TreeWalker.13. Output from DOM. Xerces Serialization.OutputFormat.DOM Level 3.Creating DOMWriters.Serialization Features.Filtering Output.IV. JDOM. 14. JDOM. What Is JDOM?Creating XML Elements with JDOM.Creating XML Documents with JDOM.Writing XML Documents with JDOM.Document Type Declarations.Namespaces.Reading XML Documents with JDOM.Navigating JDOM Trees.Talking to DOM Programs.Talking to SAX Programs.Configuring SAXBuilder.SAXOutputter.Java Integration.Serializing JDOM Objects.Synchronizing JDOM Objects.Testing Equality.Hash Codes.String Representations.Cloning.What JDOM Doesn't Do.15. The JDOM Model. The Document Class.The Element Class.Constructors.Navigation and Search.Attributes.The Attribute Class.The Text Class.The CDATA Class.The ProcessingInstruction Class.The Comment Class.Namespaces.The DocType Class.The EntityRef Class.V. XPath/XSLT. 16. XPath. Queries.The XPath Data Model.Location Paths.Axes.Node Tests.Predicates.Compound Location Paths.Absolute Location Paths.Abbreviated Location Paths.Combining Location Paths.Expressions.Literals.Operators.Functions.XPath Engines.XPath with Saxon.XPath with Xalan.DOM Level 3 XPath.Namespace Bindings.Snapshots.Compiled Expressions.Jaxen.17. XSLT. XSL Transformations.Template Rules.Stylesheets.Taking the Value of a Node.Applying Templates.The Default Template Rules.Selection.Calling Templates by Name.TrAX.Thread Safety.Locating Transformers.The xml-stylesheet Processing Instruction.Features.XSLT Processor Attributes.URI Resolution.Error Handling.Passing Parameters to Stylesheets.Output Properties.Sources and Results.Extending XSLT with Java.Extension Functions.Extension Elements.VI. APPENDIXES. Appendix A: XML API Quick Reference. SAX.org.xml.sax.org.xml.sax.ext.org.xml.sax.helpers.DOM.The DOM Data Model.org.w3c.dom.org.w3c.dom.traversal.JAXP.javax.xml.parsers.TrAX.javax.xml.transform.javax.xml.transform.stream.javax.xml.transform.dom.javax.xml.transform.sax.JDOM.org.jdom.org.jdom.filter.org.jdom.input.org.jdom.output.org.jdom.transform.org.jdom.xpath.XMLPULL.org.xmlpull.v1.Appendix B: SOAP 1.1 Schemas. The SOAP 1.1 Envelope Schema.The SOAP 1.1 Encoding Schema.W3C Software Notice and License.Appendix C: Recommended Reading. Books.Specifications.Index. 0201771861T10222002
Java is the ideal language for processing XML documents. Consequently, more XML tools have been written in Java than in any other language. More open source XML tools are written in Java than in any other language. Processing XML with Java fills an immediate need for developers who are working with XML in Java. It is a comprehensive tutorial and reference to the major APIs. This book shows developers how to: save XML documents from their applications written in Java; read XML documents produced by other programs; communicate with network servers that send and receive XML data; validate documents they receive against DTDs, schemas, and business rules; and integrate XSLT into their programs.
Elliotte Rusty Harold is an internationally respected writer, programmer, and educator. He is an Adjunct Professor of Computer Science at Polytechnic University in Brooklyn, where he lectures on Java and object-oriented programming. His Cafe con Leche Web site has become one of the most popular sites for information on XML. In addition, he is the author and coauthor of numerous books, the most recent of which are The XML Bible (John Wiley & Sons, 2001) and XML in a Nutshell (O'Reilly, 2002).0201771861AB06062003