List of Examples


List of Examples

Example 1.1 A Plain Text Document That Indicates an Order for 12 Birdsong Clocks, SKU 244

Example 1.2 An XML Document That Indicates an Order for 12 Birdsong Clocks, SKU 244

Example 1.3 A Document That Indicates an Order for 12 Birdsong Clocks, SKU 244

Example 1.4 Still an Order for 12 Birdsong Clocks, SKU 244

Example 1.5 An XML Document That Indicates an Order for Multiple Products Shipped to Multiple Addresses

Example 1.6 An XML Document That Uses a Default Namespace

Example 1.7 An XML Document That Uses Two Default Namespaces

Example 1.8 A DTD for Order Documents

Example 1.9 order.xsd: A Schema for Order Documents

Example 1.10 order.sct: A Schematron Schema for Order Documents

Example 1.11 A CSS Stylesheet for Order Documents

Example 1.12 An XSLT Stylesheet for Order Documents

Example 1.13 An XSL-FO Document for the Clock Order

Example 2.1 An XML Document That Labels Elements with Schema Simple Types

Example 2.2 URLGrabber

Example 2.3 URLGrabberTest

Example 2.4 An RSS 0.91 Document

Example 2.5 An RSS 1.0 Document

Example 2.6 An XML-RPC Request Document

Example 2.7 POSTing an XML-RPC Request Document

Example 2.8 An XML-RPC Response

Example 2.9 An XML-RPC Request That Passes an Array as an Argument

Example 2.10 An XML-RPC Response Document That Returns an Array

Example 2.11 An XML-RPC Request That Passes a Struct as an Argument

Example 2.12 An XML-RPC Fault

Example 2.13 A DTD for XML-RPC

Example 2.14 A Schema for XML-RPC

Example 2.15 A SOAP Document That Requests the Current Stock Price of Red Hat

Example 2.16 A SOAP Response

Example 2.17 A SOAP Request for the Current Stock Price of Red Hat

Example 2.18 A SOAP Document That Returns the Current Stock Price of Red Hat

Example 2.19 A SOAP Fault Response

Example 2.20 A SOAP Document That Specifies the Encoding Style

Example 2.21 A Schema That Assigns Type to Elements in the http://namespaces.cafeconleche.org/xmljava/ch2/ Namespace

Example 2.22 A SOAP Request with a Digital Signature in the Header

Example 2.23 A SOAP Request with Two Header Entries

Example 2.24 A SOAP Request with a mustUnderstand Attribute

Example 2.25 A Master Schema for SOAP Trading Documents

Example 3.1 A Program That Calculates the Fibonacci Numbers

Example 3.2 The First Ten Fibonacci Numbers in an XML Document

Example 3.3 A Program That Outputs the Fibonacci Numbers as an XML Document

Example 3.4 Using Named Constants for Element Names

Example 3.5 A Java Program That Writes an XML Document Which Uses Attributes

Example 3.6 A Java Program That Generates a Valid Document

Example 3.7 A MathML Document That Contains Fibonacci Numbers

Example 3.8 A Java Program That Generates a MathML Document

Example 3.9 A Java Program That Writes an XML File

Example 3.10 Connecting an XML-RPC Server with URLConnection

Example 3.11 Connecting to a SOAP Server with URLConnection

Example 3.12 A Servlet That Generates XML

Example 4.1 A Class That Parses Comma-Separated Values into a List of HashMaps

Example 4.2 Naively Reproducing the Original Budget Table Structure in XML

Example 4.3 A Schema for the XML Budget Data

Example 4.4 Converting to XML with Attributes

Example 4.5 A Hierarchical Arrangement of the Budget Data

Example 4.6 The Budget Class

Example 4.7 The Agency Class

Example 4.8 The Bureau Class

Example 4.9 The Account Class

Example 4.10 The Subfunction Class

Example 4.11 The Driver Class That Builds the Data Structure and Writes It Out Again

Example 4.12 An XSLT Stylesheet That Converts Flat XML Data to Hierarchical XML Data

Example 4.13 An XQuery That Converts Flat Data to Hierarchical Data

Example 4.14 A Program That Connects to a Relational Database Using JDBC and Converts the Table to Hierarchical XML

Example 5.1 A Response from the Fibonacci XML-RPC Server

Example 5.2 Reading an XML-RPC Response

Example 5.3 A SAX-Based Client for the Fibonacci XML-RPC Server

Example 5.4 The ContentHandler for the SAX Client for the Fibonacci XML-RPC Server

Example 5.5 A DOM-Based Client for the Fibonacci XML-RPC Server

Example 5.6 A JAXP-Based Client for the Fibonacci XML-RPC Server

Example 5.7 A JDOM-Based Client for the Fibonacci XML-RPC Server

Example 5.8 A dom4j-Based Client for the Fibonacci XML-RPC Server

Example 5.9 An ElectricXML-Based Client for the Fibonacci XML-RPC Server

Example 5.10 An XMLPULL-Based Client for the Fibonacci XML-RPC Server

Example 6.1 A SAX Program That Parses a Document

Example 6.2 The SAX ContentHandler Interface

Example 6.3 A SAX ContentHandler That Writes All #PCDATA onto a java.io.Writer

Example 6.4 The Driver Method for the Text Extractor Program

Example 6.5 A Subclass of DefaultHandler That Writes All #PCDATA onto a java.io.Writer

Example 6.6 A ContentHandler Interface That Resets Its Data Structures Between Documents

Example 6.7 A ContentHandler Class That Builds a GUI Representation of an XML Document

Example 6.8 The SAX Attributes Interface

Example 6.9 A ContentHandler Class That Spiders XLinks

Example 6.10 A SAX Client for the Fibonacci XML-RPC Server

Example 6.11 A ContentHandler That Prints Processing Instruction Targets and Data on System.out

Example 6.12 The NamespaceSupport Class

Example 6.13 A Document That Uses Ignorable White Space to Prettify the XML

Example 6.14 An XML Document Containing a Potentially Skipped Entity Reference

Example 6.15 The SAX Locator Interface

Example 6.16 Determining the Locations of Events

Example 7.1 The SAX InputSource Class

Example 7.2 The EntityResolver Interface

Example 7.3 An XHTML EntityResolver

Example 7.4 The SAXException Class

Example 7.5 The SAXParseException Class

Example 7.6 A SAX Program That Parses a Document and Identifies the Line Numbers of Any Well-Formedness Errors

Example 7.7 The ErrorHandler Interface

Example 7.8 A SAX Program That Reports All Problems Found in an XML Document

Example 7.9 A SAX Program That Validates Documents

Example 7.10 A SAX Program That Echoes the Parsed Document

Example 7.11 The LexicalHandler Interface

Example 7.12 An Implementation of the LexicalHandler Interface

Example 7.13 The DeclHandler Interface

Example 7.14 A Program That Prints Out a Complete DTD

Example 7.15 Making Maximal Use of Xerces' Special Capabilities

Example 7.16 The DTDHandler Interface

Example 7.17 A Caching DTDHandler

Example 7.18 A Notation Utility Class

Example 7.19 An UnparsedEntity Utility Class

Example 7.20 A Program That Lists the Unparsed Entities and Notations Used in an XML Document

Example 8.1 The XMLFilter Interface

Example 8.2 A Filter That Blocks All Events

Example 8.3 A Filter That Filters Nothing

Example 8.4 A Filter That Times All Parsing

Example 8.5 Parsing a Document through a Filter

Example 8.6 A ContentHandler Filter

Example 8.7 A Filter That Substitutes Its Own ContentHandler

Example 8.8 A Program That Filters Documents

Example 8.9 A ContentHandler Filter That Throws Away Non-XHTML Elements

Example 8.10 The AttributesImpl Helper Class

Example 8.11 Changing One Element into Another

Example 8.12 A Subclass of XMLFilterImpl

Example 8.13 Accessing Databases through SAX

Example 8.14 A Very Simple User Interface for Extracting XML Data from a Relational Database

Example 8.15 Attaching Multiple Handlers of the Same Type to a Single Parser

Example 9.1 Which Modules Does Oracle Support?

Example 9.2 An XML-RPC Request Document

Example 9.3 A Program That Uses Xerces to Check Documents for Well-Formedness

Example 9.4 A Program That Uses the Oracle XML Parser to Check Documents for Well-Formedness

Example 9.5 A Program That Uses JAXP to Check Documents for Well-Formedness

Example 9.6 A Program That Uses JAXP to Check Documents for Well-Formedness

Example 9.7 A Program That Uses DOM3 to Check Documents for Well-Formedness

Example 9.8 The Node Interface

Example 9.9 Changing Short Type Constants to Strings

Example 9.10 A Class to Inspect the Properties of a Node

Example 9.11 Walking the Tree with the Node Interface

Example 9.12 A Method That Changes a Document by Reordering Nodes

Example 9.13 The NodeList Interface

Example 9.14 Using JAXP to Read and Write an XML Document

Example 9.15 The DOMException Class

Example 10.1 The DOMImplementation Interface

Example 10.2 The DOMImplementationRegistry Class

Example 10.3 The DOMImplementationSource Interface

Example 10.4 The Document Interface

Example 10.5 Using DOM to Build an SVG Document in Memory

Example 10.6 A DOM Program That Outputs the Fibonacci Numbers as an XML Document

Example 10.7 A Valid MathML Document That Contains Fibonacci Numbers

Example 10.8 A DOM Program That Outputs the Fibonacci Numbers as a MathML Document

Example 10.9 A Valid MathML Document That Uses Prefixed Names

Example 10.10 The Properties of a Document Object

Example 10.11 An XML-RPC Request Document

Example 10.12 An XML-RPC Response Document

Example 10.13 A DOM-Based XML-RPC Servlet

Example 10.14 A DOM-Based SOAP Servlet

Example 11.1 The Element Interface

Example 11.2 Extracting Examples from DocBook

Example 11.3 A Document That Uses Attributes

Example 11.4 A DOM Program That Adds Attributes

Example 11.5 The NamedNodeMap Interface

Example 11.6 An XLink Spider That Uses DOM

Example 11.7 The CharacterData Interface

Example 11.8 Rot-13 Encoder for XML Documents

Example 11.9 The Text Interface

Example 11.10 Printing the Text Nodes in an XML Document

Example 11.11 The CDATASection Interface

Example 11.12 Merging CDATA Sections with Text Nodes

Example 11.13 The EntityReference Interface

Example 11.14 Inserting Entity References into a Document

Example 11.15 The Attr Interface

Example 11.16 Specifying All Attributes

Example 11.17 The ProcessingInstruction Interface

Example 11.18 Reading PseudoAttributes from a ProcessingInstruction

Example 11.19 The Comment Interface

Example 11.20 A DOM Program That Prints Comments

Example 11.21 The DocumentType Interface

Example 11.22 The Entity Interface

Example 11.23 Listing Parsed Entities Used in the Document

Example 11.24 The Notation Interface

Example 11.25 Listing the Notations Declared in a DTD

Example 12.1 The NodeIterator Interface

Example 12.2 The DocumentTraversal Factory Interface

Example 12.3 Using a NodeIterator to Extract All of the Comments from a Document

Example 12.4 Using a NodeIterator to Retrieve the Complete Text Content of an Element

Example 12.5 The NodeFilter Interface

Example 12.6 An Implementation of the NodeFilter Interface

Example 12.7 The TreeWalker Interface

Example 12.8 The ExampleFilter Class

Example 12.9 Navigating a Subtree with TreeWalker

Example 13.1 Using Xerces' OutputFormat Class to "Pretty Print" XML

Example 13.2 Using Xerces' OutputFormat Class to "Pretty Print" MathML

Example 13.3 The DOM3 DOMWriter Interface

Example 13.4 The DOM3 DOMErrorHandler Interface

Example 13.5 Serializing with DOMWriter

Example 13.6 The DOM3 DOMImplementationLS Interface

Example 13.7 An Implementation-Independent DOM3 Program to Build and Serialize an XML Document

Example 13.8 The DOMWriterFilter Interface

Example 13.9 Filtering Everything That Isn't XHTML on Output

Example 13.10 Using a DOMWriterFilter

Example 14.1 A JDOM Program That Produces an XML Document Containing Fibonacci Numbers

Example 14.2 A Fibonacci DTD

Example 14.3 A JDOM Program That Produces a Valid XML Document

Example 14.4 A MathML Document Containing the First Three Fibonacci Numbers

Example 14.5 A JDOM Program That Uses Namespaces

Example 14.6 A JDOM Program That Uses the Default Namespace

Example 14.7 A JDOM Program That Checks XML Documents for Well-Formedness

Example 14.8 A JDOM Program That Validates XML Documents

Example 14.9 A JDOM Program That Lists the Elements Used in a Document

Example 14.10 A JDOM Program That Lists the Nodes Used in a Document

Example 14.11 A JDOM Program That Schema Validates Documents

Example 14.12 A JDOM Program That Passes Documents to a SAX ContentHandler

Example 15.1 The JDOM Document Class

Example 15.2 Inspecting Elements

Example 15.3 An XML-RPC Request Document

Example 15.4 The JDOM Filter Interface

Example 15.5 The JDOM ContentFilter Class

Example 15.6 The JDOM ElementFilter Class

Example 15.7 A Filter for xml-stylesheet Processing Instructions in the Prolog

Example 15.8 Moving Elements between Documents

Example 15.9 Searching for RDDL Resources

Example 15.10 The JDOM Attribute Class

Example 15.11 The JDOM Text Class

Example 15.12 JDOM-Based Rot-13 Encoder for XML Documents

Example 15.13 The JDOM CDATA Class

Example 15.14 The JDOM ProcessingInstruction Class

Example 15.15 The JDOM Comment Class

Example 15.16 Printing Comments

Example 15.17 The JDOM Namespace Class

Example 15.18 An XML Document That Uses Namespace Prefixes in Attribute Values

Example 15.19 The JDOM DocType Class

Example 15.20 Validating XHTML with the DocType Class

Example 15.21 The JDOM EntityRef Class

Example 16.1 Weather Data in XML

Example 16.2 A SOAP Response Document

Example 16.3 An XML-RPC Request Document

Example 16.4 A SOAP Request Document

Example 16.5 The Xalan XPathAPI Class

Example 16.6 The XPathEvaluator Interface

Example 16.7 The XPathResult Interface

Example 16.8 An XML Document That Contains Namespace Bindings and an XPath Search Expression

Example 16.9 The DOM3 XPathExpression Interface

Example 17.1 An XSLT Stylesheet for XML-RPC Request Documents

Example 17.2 An XSLT Stylesheet That Echoes XML-RPC Requests

Example 17.3 An XML-RPC Request Document

Example 17.4 An XML-RPC Response Document

Example 17.5 An XSLT Stylesheet That Calculates Fibonacci Numbers

Example 17.6 A Servlet That Uses TrAX and XSLT to Respond to XML-RPC Requests

Example 17.7 Testing the Availability of TrAX Features

Example 17.8 The TrAX URIResolver Interface

Example 17.9 A URIResolver Class

Example 17.10 The TrAX ErrorListener Interface

Example 17.11 An ErrorListener That Uses the Logging API

Example 17.12 The TrAX OutputKeys Class

Example 17.13 The TrAX DOMSource Class

Example 17.14 The TrAX DOMResult Class

Example 17.15 The TrAX SAXSource Class

Example 17.16 The TrAX SAXResult Class

Example 17.17 The TrAX StreamSource Class

Example 17.18 The TrAX StreamResult Class

Example 17.19 A Java Class That Calculates Fibonacci Numbers

Example 17.20 The Xalan ExpressionContext Interface

Example 17.21 A Stylesheet That Uses an Extension Element