You are previewing Sams Teach Yourself XML in 24 Hours, Third Edition.
O'Reilly logo
Sams Teach Yourself XML in 24 Hours, Third Edition

Book Description

The third edition of Sams Teach Yourself XML in 24 Hours, Complete Starter Kit is everything you need to know about the XML language and how to use it in practical, innovative applications. Understanding the syntax of XML is only a small part of the learning process; understanding how to apply it is the larger part of the learning process, and is the primary focus of this book. It covers a broad range of topics, and wil show you how to use XML to mine data on the web, how to use it to interact with existing data services such as iTunes and Google, and how to use it in applications such as e-books, online speech synthesis, and multimedia. Sams Teach Yourself XML in 24 Hours, Complete Starter Kit, Third Edition will teach you what you need to know to get up and running with XML and more importantly, how to do cool things with it!

Table of Contents

  1. Copyright
    1. Dedication
  2. About the Author
  3. Acknowledgments
  4. We Want to Hear from You!
  5. Introduction
    1. How This Book Is Structured
    2. What You’ll Need
    3. How to Use This Book
  6. I. XML Essentials
    1. 1. Getting to Know XML
      1. The What and Why of XML
        1. A Quick History of HTML
        2. Getting Multilingual with XML
        3. The Convergence of HTML and XML
      2. XML and Web Browsers
      3. Real-World XML
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    2. 2. Creating XML Documents
      1. A Quick XML Primer
        1. XML Building Blocks
        2. Inside an Element
        3. XML’s Five Commandments
        4. Special XML Symbols
        5. The XML Declaration
      2. Selecting an XML Editor
      3. Constructing Your First XML Document
      4. Viewing Your XML Document
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
  7. II. Defining XML Data
    1. 3. Defining Data with DTD Schemas
      1. Creating Your Own Markup Languages
      2. Schemas and XML Data Modeling
        1. Document Type Definitions (DTDs)
        2. XML Schema (XSDs)
      3. Comparing Schema Technologies
      4. The Importance of Document Validation
      5. DTD Construction Basics
        1. Breaking Down a DTD
        2. Pondering Elements and Attributes
      6. Digging Deeper into Elements
        1. Peeking Inside Empty Elements
        2. Housing Children with Element-Only Elements
        3. Combining Content and Children with Mixed Elements
        4. Keeping Your Options Open with Any Elements
      7. Putting Attributes to Work
        1. Working with Multiple Attributes
      8. A Complete DTD Example
      9. Summary
      10. Q&A
      11. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    2. 4. Digging Deeper into XML Documents
      1. Leaving a Trail with Comments
      2. Characters of Text in XML
      3. The Wonderful World of Entities
        1. Parsed Entities
        2. General Entities
        3. Parameter Entities
        4. Unparsed Entities
        5. Internal Versus External Entities
      4. The Significance of Notations
      5. Working with CDATA
      6. Using XML to Create an Online Radio
      7. Summary
      8. Q&A
      9. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    3. 5. Putting Namespaces to Use
      1. Understanding Namespaces
      2. Naming Namespaces
      3. Declaring and Using Namespaces
        1. Default Namespaces
        2. Explicit Namespaces
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    4. 6. Using SVG to Draw Scalable Graphics
      1. What Is SVG?
        1. Bitmap Versus Vector Graphics
      2. SVG and Related Technologies
        1. Microsoft’s Answer to Vector Graphics
        2. Macromedia Flash
        3. SVG for Mobile Devices
      3. Inside the SVG Language
        1. The Bare Bones of SVG
        2. SVG Coordinate Systems
      4. Creating an SVG Drawing
        1. The Root Element
        2. Drawing Shapes with SVG Child Elements
          1. Rectangles
          2. Circles
          3. Ellipses
          4. Lines
          5. Compound Shapes
            1. Polygons
            2. Polylines
          6. Styling Shapes with CSS Style Properties
          7. Filling with Gradients
        3. Drawing a Path
        4. Text in SVG
          1. Free-Standing Text
          2. Text Along a Path
      5. Embedding an SVG Drawing in a Web Page
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    5. 7. Using XML Schema
      1. XML Schema Construction Basics
        1. XSD Data Types
        2. XSD Schemas and XML Documents
      2. Working with Simple Types
        1. The String Type
        2. The Boolean Type
        3. Number Types
        4. Date and Time Types
        5. Custom Types
          1. Enumerated Types
          2. List Types
          3. Patterned Types
      3. Digging into Complex Types
        1. Empty Elements
        2. Element-Only Elements
        3. Mixed Elements
        4. Sequences and Choices
      4. Namespaces and XSD Schemas
        1. The xsd Prefix
        2. Referencing Schema Documents
      5. A Complete XML Schema Example
      6. RELAX NG and the Future of XML Schema
      7. Summary
      8. Q&A
      9. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    6. 8. Validating XML Documents
      1. Document Validation Revisited
      2. Validation Tools
        1. DTD Validation
        2. XSD Validation
        3. Validate Document
      3. Repairing Invalid Documents
        1. Check That Document is Well Formed
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
  8. III. Formatting and Displaying XML Documents
    1. 9. XML Formatting Strategies
      1. Style Sheets and XML Formatting
        1. The Need for Style Sheets
        2. Getting to Know CSS and XSL
          1. Cascading Style Sheets (CSS)
          2. Extensible Style Language (XSL)
        3. Rendering XML with Style Sheets
      2. Leveraging CSS, XSLT, and XSL-FO
      3. Style Sheets in Action
        1. The CSS Solution
        2. The XSLT Solution
      4. Summary
      5. Q&A
      6. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    2. 10. Styling XML Content with CSS
      1. Getting to Know CSS
        1. A CSS Style Primer
        2. Layout Properties
        3. Formatting Properties
      2. Wiring a Style Sheet to an XML Document
      3. Your First CSS Style Sheet
      4. Inside CSS Positioning
        1. Tinkering with the z-Index
        2. Creating Margins
        3. A Little Padding for Safety
        4. Keeping Things Aligned
      5. The Ins and Outs of Text Formatting
        1. Working with Fonts
        2. Jazzing Up Text with Colors and Image Backgrounds
        3. Tweaking the Spacing of Text
      6. Your Second Complete Style Sheet
      7. Summary
      8. Q&A
      9. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    3. 11. Getting Started with XSL
      1. XSL Basics
      2. The Pieces and Parts of XSL
        1. XSL Transformation
        2. XPath
        3. XSL Formatting Objects
      3. An XSLT Primer
        1. Templates
        2. Patterns and Expressions
      4. Wiring an XSL Style Sheet to an XML Document
      5. Your First XSLT Style Sheet
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    4. 12. Transforming XML with XSLT
      1. A Closer Look at XSLT
        1. Creating and Applying Templates
        2. Processing Nodes
        3. Sorting Nodes
      2. Pattern Essentials
      3. Putting Expressions to Work
        1. Working with Operators
        2. Using Standard Functions
      4. A Complete XSLT Example
      5. Yet Another XSLT Example
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    5. 13. Access Your iTunes Music Library via XML
      1. The Role of XML in iTunes
      2. Digging Into the iTunes Library File
      3. Linking to Tracks in the iTunes Store
      4. Building an iTunes Web Viewer
        1. Revisiting the iTunes XML Music Library
        2. Inside the iTunes Viewer XSLT Stylesheet
        3. Viewing the End Result in a Browser
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    6. 14. Formatting XML with XSL-FO
      1. What Is XSL-FO?
      2. Working with the XSL-FO Language
        1. The Core XSL-FO Document Structure
        2. Styling Text in XSL-FO
        3. Controlling Spacing and Borders
        4. Managing Pages
      3. Validating an XSL-FO Document
      4. Converting an XSL-FO Document to PDF
      5. A More Complete XSL-FO Example
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    7. 15. Using XML to Hack Google Maps
      1. Getting to Know Google Maps
      2. Google Maps Customization Basics
        1. Getting Your Own API Key
        2. Touring the Google Maps API
        3. Obtaining the Geocoordinates of a Location
      3. Brainstorming a Custom Mapping Application
      4. Developing a Custom Map Document
      5. Hacking Together a Custom Google Map
        1. Displaying the Custom Map
        2. Styling a Custom Information Window
        3. Testing Out the Finished Map
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
  9. IV. Processing and Managing XML Data
    1. 16. Parsing XML with the DOM
      1. What Is the DOM?
      2. How the DOM Works
        1. Language Bindings
        2. Using the DOM Tree
      3. DOM Interfaces
        1. The Node Interface
        2. The Document Interface
        3. The Element Interface
        4. The Attr Interface
        5. The NodeList Interface
      4. Binding XML Data to a Web Page
      5. Using the DOM to Access XML Data
        1. Loading an XML Document
        2. Traversing the DOM Tree
      6. A Complete DOM Example
      7. Updating the DOM Tree
      8. Summary
      9. Q&A
      10. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    2. 17. SAX: The Simple API for XML
      1. What Is SAX?
        1. A Really Brief History of SAX
        2. SAX 1.0
        3. SAX 2.0
      2. Writing Programs That Use SAX Parsers
      3. Obtaining a SAX Parser
        1. Xerces
        2. libxml
        3. Python
      4. Using SAX with Java
      5. Inside the SAX Sample Program
        1. The main() Method
        2. Implementing the ContentHandler Interface
        3. Implementing the ErrorHandler Interface
        4. Testing the Document Printer Program
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    3. 18. Querying XML Data with XQuery
      1. What Is XQuery?
      2. XML Data Querying 101
        1. Querying with Wildcards
        2. Using Filters to Search for Specific Information
        3. Referencing Attributes
      3. Processing XQuery Results
      4. Getting to Know Saxon
      5. Practical XML Querying with XQuery and Saxon
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    4. 19. Using XML with Databases
      1. A Quick Relational Database Primer
      2. The World’s Shortest Guide to SQL
        1. Retrieving Records Using SELECT
        2. The WHERE Clause
        3. Inserting Records
        4. Updating Records
        5. Deleting Records
      3. Databases and XML
        1. Resolving XML Data into Database Tables
        2. Storing XML Documents in a Database
      4. Exporting an XML Document from a Database
      5. Accessing Data from a Database as XML
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    5. 20. Using XML to Assist Search Engines
      1. Web Crawling Basics
      2. Getting to Know Google Sitemaps
      3. Inside the Google Sitemap Protocol
      4. Creating Your Own Sitemap
        1. A Basic Sitemap Document
        2. Breaking Your Mapping into Multiple Documents
      5. Validating Your Sitemap
      6. Submitting Your Sitemap to Google
      7. Using an Automated Sitemap Tool
      8. Summary
      9. Q&A
      10. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
  10. V. XML’s Impact on HTML
    1. 21. Adding Structure to the Web with XHTML
      1. XHTML: A Logical Merger
      2. Comparing XHTML and HTML
      3. Creating and Validating XHTML Documents
        1. Preparing XHTML Documents for Validation
        2. Putting Together an XHTML Document
        3. Validating an XHTML Document
      4. Migrating HTML to XHTML
        1. Hands-on HTML to XHTML Conversion
        2. Automated HTML to XHTML Conversion
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    2. 22. Addressing and Linking XML Documents
      1. Understanding XPath
      2. Navigating a Document with XPath Patterns
        1. Referencing Nodes
        2. Referencing Attributes and Subsets
      3. Using XPath Functions
        1. Node Functions
        2. String Functions
        3. Boolean Functions
        4. Number Functions
      4. The Role of XPath
      5. HTML, XML, and Linking
      6. Addressing with XPointer
        1. Building XPointer Expressions
        2. Creating XPointers
      7. Linking with XLink
        1. Understanding XLink Attributes
        2. Creating Links with XLink
      8. A Complete XLink Example
      9. Summary
      10. Q&A
      11. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    3. 23. Going Wireless with WML and XHTML Mobile
      1. XML and the Wireless Web
      2. WML Essentials
        1. Nuts and Bolts
        2. The WML Root Element
        3. Navigation in WML
        4. Content in WML
      3. Creating WML Documents
        1. Before You Start—Tools of the Trade
        2. Laying Down the Infrastructure
        3. The Basic WML Document
        4. Setting Up Cards
        5. Formatting Text
        6. Four Ways to Navigate
          1. Good Old Anchors
          2. The select>option Setup
          3. Map to OK Button
        7. Associating an Event with a Task
          1. Map to Menu Button
        8. Inserting WBMP Images
        9. Accepting User Input
      4. Blending WML with XHTML Mobile
      5. Summary
      6. Q&A
      7. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
    4. 24. Syndicating the Web with RSS News Feeds
      1. A Brief History of RSS
      2. Using an RSS News Aggregator
      3. Inside the RSS 2.0 Language
      4. Creating and Validating a News Feed
      5. Displaying a News Feed
        1. Creating a News Feed Document
        2. Transforming the News Feed for Display
      6. Summary
      7. Q&A
      8. Workshop
        1. Quiz
        2. Quiz Answers
        3. Exercises
  11. VI. Appendix
    1. A. XML Resources
      1. General XML Resources
      2. XML Tools
      3. XML-Based Languages
      4. XML Specifications