Java Reference
In-Depth Information
TOPIC
CONCEPT
XML Docu-
ment Struc-
ture
An XML document consists of a prolog and a document body. The document body contains the data and
the prolog provides the information necessary for interpreting the document body.
Markup
Markup consists of XML elements that may also include attributes, where an attribute is a name-value
pair.
Well-
Formed
XML
A well-formed XML document conforms to a strict set of rules for document definition, as defined by the
XML language specification.
DTDs
The structure and meaning of a particular type of XML document can be defined within a Document Type
Definition (DTD). A DTD can be defined in an external file or it can be part of a document.
Valid XML
Documents
A valid XML document is a well-formed document that has a DTD.
A DTD is identified by a DOCTYPE declaration in a document.
DOCTYPE
Declarations
XML Ele-
ments
XML markup divides the contents of a document into elements by enclosing segments of the data
between tags.
Element At-
tributes
Attributes provide a way for you to embed additional data within an XML element.
CDATA Sec-
tions
A CDATA section in an XML document contains unparsed character data that is not analyzed by an XML
processor.
Schemas
Using the Schema Definition language to define a schema for XML documents provides a more flexible
alternative to DTDs.
The SAX
API
The SAX API defines a simple event-driven mechanism for analyzing XML documents.
SAX Pars-
ers
A SAX parser is a program that parses an XML document and identifies each element in a document by
calling a particular method in your program. The methods that are called by a parser to identify elements
are those defined by the SAX API.
SAX Pars-
ing Events
You can create a class that has methods to handle SAX2 parsing events by extending the DefaultHand-
ler class that defines do-nothing implementations of the methods. The DefaultHandler2 class extends
DefaultHandler to provide methods for extensions to SAX2.
DOM Pars-
ers
A DOM parser makes an entire XML document available encapsulated in an object of type Document .
You can call methods for the Document object to extract the contents of the document.
Search WWH ::




Custom Search