Working with XML

来源:百度文库 编辑:神马文学网 时间:2024/04/29 17:48:39
Working with XML: Table of Contents
1. A Quick Introduction to XMLWhat is XML?Tags and Attributes
Empty Tags
Comments in XML Files
The XML Prolog
Processing InstructionsWhy is XML Important?What can you do with XML?
2. XML and Related Specs: Digesting the Alphabet SoupW3C RecommendationsSAXDOMDTDRDFNamespaces
W3C Proposed RecommendationsRDF SchemaW3C Working DraftsXSLXLLXLinkXPointerXHTMLXML Schema
W3C "Notes"Schema ProposalsDDML / XSchemaDCD
SOXOther W3C NotesICE

Standards that Build on XMLSMIL
MathML
SVG
DrawMLeCommerce StandardscXML
CBLSoftware Administration and Maintenance StandardsDMTF
WebDAV
3. An Overview of the APIsThe JAXP APIsAn Overview of SAX and DOMThe SAX Parser3b. Other SAX APIsThe Document Object Model (DOM)The Project X Reference ImplementationWhere Do You Go from Here?
4. Designing an XML Data StructureSaving Yourself Some WorkAttributes and ElementsForced Choices
Stylistic ChoicesNormalizing DataNormalizing DTDs
1. Writing a Simple XML FileCreating the File
Writing the Declaration
Adding a Comment
Defining the Root Element
Adding Attributes to an Element
Adding Nested Elements
Adding HTML-Style Text
Adding an Empty Element
The Finished Product2a. Echoing an XML File with the SAX ParserCreate the Skeleton
Import the Classes We Need
Setting up for I/O
Setting up the Parser
Implementing the DocumentHandler Interface
Writing the Output
Spacing the Output
Handling Document Events
Compiling the Program
Running the Program
Command Scripts
Checking the Output
Identifying the Events
Compressing the Output
Inspecting the Output
Documents and Data2b. Adding Additional Event HandlersIdentifying the Document‘s Location
Handling Processing Instructions
Summary3. Handling Errors with the Nonvalidating ParserIntroducing an Error
Handling a SAXParseException
Handling a SAXException
Improving the SAXParseException Handler
Handling a ParserConfigurationException
Handling an IOException
Understanding NonFatal Errors
Handling NonFatal Errors
Handling Warnings4. Substituting and Inserting TextHandling Special CharactersPredefined Entities
Character ReferencesUsing an Entity Reference in an XML DocumentHandling Text with XML-Style SyntaxHandling CDATA and Other Characters
5a. Creating a Document Type Definition (DTD)Basic DTD Definitions
Defining Text and Nested Elements
Limitations of DTDs
Special Element Values in the DTD
Referencing the DTD 5b. DTD‘s Effect on the Nonvalidating ParserTracking Ignorable Whitespace
Cleanup
Documents and Data
Empty Elements, Revisited 5c. Defining Attributes and Entities in the DTDDefining Attributes in the DTD
Defining Entities in the DTD
Echoing the Entity References
Additional Useful Entities
Referencing External Entities
Echoing the External Entity
Summarizing Entities5d. Referencing Binary EntitiesUsing a MIME Data Type
The Alternative: Using Entity References6. Using the Validating ParserConfiguring the Factory
Using an Environment Variable
Experimenting with Validation Errors
Error Handling in the Validating Parser7a. Defining Parameter Entities and Conditional Sections Creating and Referencing a Parameter Entity
Conditional Sections 7b. Parsing the Parameterized DTDDTD Warnings8. Using a LexicalEventListenerHow the LexicalEventListener WorksWorking with a LexicalEventListenerEchoing Comments
Echoing Other Lexical Information
9. Using the DTDHandler and EntityResolverThe DTDHandler API
The EnityResolver API
Part III: XML and the Document Object Model (DOM)1. Generating a DOM from XML dataReading an XML Document into a DOMCreate the Skeleton
Import the Required Classes
Declare the DOM
Handle Errors
Instantiate the Factory
Get a Parser and Parse the FileWrite Out the XMLUse XmlDocument
Run the ProgramAdditional InformationConfiguring the Factory
Handling Validation ErrorsLooking Ahead
2. Generating XML from an Arbitrary Data StructureHow It Works
Modify the "Parser" to Generate SAX Events
Implement the org.xml.sax.Parser Interface
Create a Factory
Wire Your "Parser" to an XmlDocumentBuilder
Write it Out
Run It3a. Displaying a DOM HierarchyEchoing Tree NodesConvert DomEcho to a GUI AppAdd Import Statements
Create the GUI Framework
Add the Display ComponentsCreate Adapters to Display the DOM in a JTreeDefine the AdapterNode Class
Define the TreeModel AdapterFinish it Up
3b. Examining the Structure of a DOMDisplaying a Simple TreeDisplaying a More Complex TreeFinishing Up
4. Constructing a User-Friendly JTree from a DOMCompressing the Tree ViewMake the Operation Selectable
Identify "Tree" Nodes
Control Node Visibility
Control Child Access
Check the Results
Extra CreditActing on Tree SelectionsIdentify Node Types
Concatenate Subnodes to Define Element Contents
Display the Content in the JTree
Wire the JTree to the JEditorPane
Run the App
Extra CreditHandling ModificationsFinishing Up
5. Creating and Manipulating a DOMObtaining a DOM from the FactoryModify the Code
Create Element and Text Nodes
Run the AppNormalizing the DOMOther OperationsTraversing Nodes
Creating Attributes
Removing and Changing NodesFinishing Up
6. Using NamespacesDefining a NamespaceReferencing a NamespaceDefining a Namespace Prefix
Additional InformationJava‘s Encoding Schemes