You are previewing Beginning XML, 5th Edition.

Beginning XML, 5th Edition

Cover of Beginning XML, 5th Edition by Danny Ayers... Published by Wrox
  1. Cover
  2. Contents
  3. Part I: Introducing XML
    1. Chapter 1: What is XML?
      1. Steps Leading up to XML: Data Representation and Markups
      2. The Birth of XML
      3. More Advantages of XML
      4. XML in Practice
      5. Summary
    2. Chapter 2: Well-Formed XML
      1. What Does Well-Formed Mean?
      2. Creating XML in a Text Editor
      3. Advanced XML Parsing
      4. The XML Infoset
      5. Summary
    3. Chapter 3: XML Namespaces
      1. Defining Namespaces
      2. Why Do You Need Namespaces?
      3. How Do You Choose a Namespace?
      4. How to Declare a Namespace
      5. Namespace Usage in the Real World
      6. When to Use and Not Use Namespaces
      7. Common Namespaces
      8. Summary
  4. Part II: Validation
    1. Chapter 4: Document Type Definitions
      1. What Are Document Type Definitions?
      2. Anatomy of a DTD
      3. DTD Limitations
      4. Summary
    2. Chapter 5: XML Schemas
      1. Benefits of XML Schemas
      2. XML Schemas in Practice
      3. Defining XML Schemas
      4. Creating a Schema from Multiple Documents
      5. Documenting XML Schemas
      6. XML Schema 1.1
      7. Summary
    3. Chapter 6: Relax NG and Schematron
      1. Why Do You Need More Ways of Validating XML?
      2. Setting Up Your Environment
      3. Using RELAX NG
      4. Using Schematron
      5. Summary
  5. Part III: Processing
    1. Chapter 7: Extracting Data From XML
      1. Document Models: Representing XML in Memory
      2. The XPath Language
      3. Summary
    2. Chapter 8: XSLT
      1. What XSLT Is Used For
      2. Setting Up Your XSLT Development Environment
      3. Foundational XSLT Elements
      4. Reusing Code in XSLT
      5. Understanding Built-In Templates and Built-In Rules
      6. Using XSLT 2.0
      7. XSLT and XPath 3.0: What’s Coming Next?
      8. Summary
  6. Part IV: Databases
    1. Chapter 9: XQUERY
      1. XQuery, XPath, and XSLT
      2. XQuery in Practice
      3. Building Blocks of XQuery
      4. The Anatomy of a Query Expression
      5. Some Optional XQuery Features
      6. Coming in XQuery 3.0
      7. Summary
    2. Chapter 10: XML and Databases
      1. Understanding Why Databases Need to Handle XML
      2. Analyzing which XML Features are Needed in a Database
      3. Using MySQL with XML
      4. Using SQL Server with XML
      5. Using eXist with XML
      6. Summary
  7. Part V: Programming
    1. Chapter 11: Event-Driven Programming
      1. Understanding Sequential Processing
      2. Using SAX in Sequential Processing
      3. Using XmlReader
      4. Summary
    2. Chapter 12: LINQ to XML
      1. What Is LINQ?
      2. Creating Documents
      3. Extracting Data from an XML Document
      4. Modifying Documents
      5. Transforming Documents
      6. Using VB.NET XML Features
      7. Summary
  8. Part VI: Communication
    1. Chapter 13: RSS, ATOM, and Content Syndication
      1. Syndication
      2. Working with News Feeds
      3. A Simple Aggregator
      4. Transforming RSS with XSLT
      5. Useful Resources
      6. Summary
    2. Chapter 14: WEB Services
      1. What Is an RPC?
      2. RPC Protocols
      3. The New RPC Protocol: Web Services
      4. The Web Services Stack
      5. Summary
    3. Chapter 15: SOAP and WSDL
      1. Laying the Groundwork
      2. The New RPC Protocol: SOAP
      3. Defining Web Services: WSDL
      4. Summary
    4. Chapter 16: AJAX
      1. AJAX Overview
      2. Introduction to JavaScript
      3. The XMLHttpRequest Function
      4. Using HTTP Methods with AJAX
      5. Accessibility Considerations
      6. The jQuery Library
      7. JSON and AJAX
      8. The Web Sever Back End
      9. A Larger Example
      10. Summary
  9. Part VII: Display
    1. Chapter 17: XHTML and HTML 5
      1. Background of SGML
      2. The Open Web Platform
      3. Introduction to XHTML
      4. XHTML and HTML: Problems and Workarounds
      5. Cascading Style Sheets (CSS)
      6. Unobtrusive JavaScript
      7. HTML 5
      8. Summary
    2. Chapter 18: Scalable Vector Graphics (SVG)
      1. Scalable Vector Graphics and Bitmaps
      2. The SVG Graphics Model
      3. SVG and CSS
      4. SVG Tools
      5. SVG Basic Built-in Shapes
      6. SVG Transforms and Groups
      7. SVG Definitions and Metadata
      8. Viewports and Coordinates
      9. SVG Colors and Gradients
      10. Including Bitmap Images in SVG
      11. SVG Text and Fonts
      12. SVG Animation Four Ways
      13. SVG and HTML 5
      14. SVG and Web Apps
      15. Making SVG with XQuery or XSLT
      16. Resources
      17. Summary
  10. Part VIII: Case Study
    1. Chapter 19: Case Study: XML in Publishing
      1. Background
      2. Project Introduction: Current Workflow
      3. Introducing a New XML-Based Workflow
      4. Creating a New Process
      5. Some Technical Aspects
      6. The Hoy Books Website
      7. Summary
  11. Appendix A: Answers to Exercises
  12. Appendix B: XPath Functions
  13. Appendix C: XML Schema Data Types
  14. Introduction
  15. Advertisements
O'Reilly logo

A

Answers to Exercises

CHAPTER 1 ANSWERS TO EXERCISES

Exercise 1 Solution

A sample document, now element-centric, is shown here:

<applicationUsers>
  <user>
    <firstName>Joe</firstName>
    <middleName>John</middleName>
    <lastName>Fawcett</lastName>
  </user>
  <user>
    <firstName>Danny</firstName>
    <middleName>John</middleName>
    <lastName>Ayers</lastName>
  </user>
  <user>
    <firstName>Catherine</firstName>
    <middleName>Elizabeth</middleName>
    <lastName>Middleton</lastName>
  </user>
</applicationUsers>

Exercise 2 Solution

The main disadvantage is that the size of the file is greatly increased. In general, each additional user needs an extra 72 bytes, compared to the original version. For a small number of users this probably won’t matter, but with a large number, or if you are transmitting many of these files, this could mean much more network traffic, leading to higher costs and reduced efficiency. This is one reason that, when designing an XML format for your data, it is recommended to choose attributes unless you have good reason not to.

CHAPTER 2 ANSWERS TO EXERCISES

Exercise 1 Solution

There are four errors altogether:

  • <xmlLibrary> is wrong as element names cannot begin with the letters XML whether uppercase or lowercase.
  • publicationYear=1898 is incorrect as all attribute values must be quoted, whether or not they contain spaces.
  • <title> Arms & The Man</title> is using a forbidden character, &, which needs be replaced with a entity reference, &amp;.
  • <play description> is illegal as it contains a ...

The best content for your career. Discover unlimited learning on demand for around $1/day.