XML Hacks

Book description

Developers and system administrators alike are uncovering the true power of XML, the Extensible Markup Language that enables data to be sent over the Internet from one computer platform to another or one application to another and retain its original format. Flexible enough to be customized for applications as diverse as web sites, electronic data interchange, voice mail systems, wireless devices, web services, and more, XML is quickly becoming ubiquitous.XML Hacks is a roll-up-your-sleeves guide that distills years of ingenious XML hacking into a complete set of practical tips, tricks, and tools for web developers, system administrators, and programmers who want to go far beyond basic tutorials to leverage the untapped power of XML.With plenty of useful real-world projects that illustrate how to define, read, create, and manipulate XML documents, XML Hacks shows readers how to put XML's power to work on the Internet and within productivity applications. Each Hack in this book can be read easily in a few minutes, saving programmers and administrators countless hours of searching for the right answer. And this is an O'Reilly Hacks book, so it's not just practical, imminently useful, and time-saving. It's also fun.From Anatomy of an XML Document to Exploring SOAP Messages XML Hacks shows you how to save time and accomplish more with fewer resources. If you want much more than the average XML user--to explore and experiment, do things you didn't know you could do with XML, discover clever shortcuts, and show off just a little--this invaluable book is a must-have.

Publisher resources

View/Submit Errata

Table of contents

  1. XML Hacks
  2. A Note Regarding Supplemental Files
  3. Credits
    1. Author
    2. Contributors
  4. Preface
    1. Why XML Hacks?
    2. How This Book Is Organized
    3. Conventions Used in This Book
    4. Using Code Examples
    5. How to Contact Us
    6. Got a hack?
    7. Acknowledgments
  5. 1. Looking at XML Documents
    1. Hacks #1-10
    2. 1. Read an XML Document
      1. The XML Declaration
        1. Version information
        2. The encoding declaration
        3. The standalone declaration
      2. Comments
      3. Elements
        1. Mixed content
      4. Attributes
        1. Character references
      5. CDATA Sections
      6. See Also
    3. 2. Display an XML Document in a Web Browser
    4. 3. Apply Style to an XML Document with CSS
      1. Processing Instructions
      2. Cascading Style Sheets
      3. Applying a Stylesheet to an XML Document
      4. See Also
    5. 4. Use Character and Entity References
      1. Character References
        1. The xml:lang attribute
      2. Entity References
    6. 5. Examine XML Documents in Text Editors
      1. Vim
      2. Emacs with nXML
      3. See Also
    7. 6. Explore XML Documents in Graphical Editors
      1. xmlspy
      2. xRay2
      3. <oXygen/>
      4. See Also
    8. 7. Choose Tools for Creating an XML Vocabulary
      1. Well-Formedness, Validation, and Schemas
        1. DTD
        2. Other schema languages
      2. Namespaces
      3. See Also
    9. 8. Test XML Documents Online
      1. RUWF
      2. RXP
      3. Brown University’s Validation Form
    10. 9. Test XML Documents from the Command Line
      1. RXP
      2. xmlvalid
      3. xmllint
      4. xmlwf
    11. 10. Run Java Programs that Process XML
      1. JAR Files
      2. The Java Classpath
      3. Using a JAR File as an Executable on Windows 2000 or XP
  6. 2. Creating XML Documents
    1. Hacks #11-30
    2. 11. Edit XML Documents with <oXygen/>
    3. 12. Edit XML Documents with Emacs and nXML
      1. Spotting Validity Errors in Real Time
      2. Getting Help with nXML
      3. Using Context-Sensitive Completion
      4. Making nXML Work Your Way
      5. Entering and Displaying Special Characters
      6. See Also
    4. 13. Edit XML with Vim
      1. Basic Configuration
      2. Syntax Highlighting
      3. Indentation
      4. Folding
      5. Automation
      6. See Also
    5. 14. Edit XML Documents with Microsoft Word 2003
      1. Attaching Schemas to Word
      2. Using XSLT with Word 2003
      3. Saving Word 2003 Files as XML
      4. See Also
    6. 15. Work with XML in Microsoft Excel 2003
      1. See Also
    7. 16. Work with XML in Microsoft Access 2003
      1. See Also
    8. 17. Convert Microsoft Office Files, Old or New, to XML
      1. DocBook
    9. 18. Create an XML Document from a Text File with xmlspy
      1. See Also
    10. 19. Convert Text to XML with Uphill
      1. Trying It Out
      2. How the Code Works
        1. The markup class
        2. The uphill class
      3. Summary
      4. See Also
    11. 20. Create Well-Formed XML with Minimal Manual Tagging Using an SGML Parser
      1. From HTML to XML
      2. Marking Up the Names of People
      3. See Also
    12. 21. Create an XML Document from a CSV File
      1. See Also
    13. 22. Convert an HTML Document to XHTML with HTML Tidy
    14. 23. Transform Documents with XQuery
      1. See Also
    15. 24. Execute an XQuery with Saxon
      1. Executing XQuery from a File Using Saxon
      2. Piping Queries to Saxon
      3. Executing XQuery from Java Using XQJ
      4. Executing XQuery on the Web
      5. See Also
    16. 25. Include Text and Documents with Entities
      1. Unparsed Entities and Notations
    17. 26. Include External Documents with XInclude
      1. See Also
    18. 27. Encode XML Documents
      1. ISO/IEC 8859
      2. UTF-8 and UTF-16
        1. The Byte Order Mark
      3. See Also
    19. 28. Explore XLink and XML
      1. XML Base
      2. XLink
      3. Other XLink Functionality
        1. Extended links
        2. XLink linkbases
      4. See Also
    20. 29. What’s the Diff? Diff XML Documents
      1. DecisionSoft’s xmldiff
      2. DeltaXML’s XML Comparator
      3. IBM’s XML Diff and Merge Tool
      4. See Also
    21. 30. Look at XML Documents Through the Lens of the XML Information Set
  7. 3. Transforming XML Documents
    1. Hacks #31-58
    2. 31. Understand the Anatomy of an XSLT Stylesheet
      1. The Document Element
      2. Templates
        1. Using apply-templates
        2. A literal result element
        3. The attribute value template
        4. The copy-of and copy elements
    3. 32. Transform an XML Document with a Command-Line Processor
      1. Saxon
        1. Instant Saxon
        2. Full Java version of Saxon
      2. Xalan
      3. MSXSL
    4. 33. Transform an XML Document Within a Graphical Editor
      1. xmlspy
      2. xRay2
      3. <oXygen/>
      4. See Also
    5. 34. Analyze Nodes with TreeViewer
    6. 35. Explore a Document Tree with the xmllint Shell
      1. xmllint Shell Commands
    7. 36. View Documents as Tables Using Generic CSS or XSLT
    8. 37. Generate an XSLT Identity Stylesheet with Relaxer
    9. 38. Pretty-Print XML Using a Generic Identity Stylesheet and Xalan
    10. 39. Create a Text File from an XML Document
      1. Built-in Templates
    11. 40. Convert Attributes to Elements and Elements to Attributes
      1. Element-to-Attribute Conversion
      2. Attribute-to-Element Conversion
      3. See Also
    12. 41. Convert XML to CSV
      1. See Also
    13. 42. Create and Process SpreadsheetML
    14. 43. Choose Your Output Format in XSLT
    15. 44. Transform Your iTunes Library File
    16. 45. Generate Multiple Output Documents with XSLT 2.0
    17. 46. Generate XML from MySQL
    18. 47. Generate PDF Documents from XML and CSS
    19. 48. Process XML Documents with XSL-FO and FOP
      1. XSL-FO Basics
      2. Generating a PDF
      3. See Also
    20. 49. Process HTML with XSLT Using TagSoup
      1. Using TagSoup and TSaxon
    21. 50. Build Results with Literal Result and Instruction Elements
      1. Literal Result Elements and Literal Text
      2. Instruction Elements
    22. 51. Write Push and Pull Stylesheets
    23. 52. Perform Math with XSLT
    24. 53. Transform XML Documents with grep and sed
      1. grep
      2. sed
      3. See Also
    25. 54. Generate SVG with XSLT
      1. See Also
    26. 55. Dither Scatterplots with XSLT and SVG
    27. 56. Use Lookup Tables with XSLT to Translate FIPS Codes
      1. The FIPS Code Example
      2. Putting the Lookup Table in the Stylesheet
      3. Running the Hack
    28. 57. Grouping in XSLT 1.0 and 2.0
      1. Grouping with XSLT 1.0
      2. Grouping with XSLT 2.0
      3. See Also
    29. 58. Use EXSLT Extensions
      1. EXSLT’s date:date( ), date:time( ), and math:lowest( ) Functions
      2. EXSLT’s exsl:node-set Function
      3. See Also
  8. 4. XML Vocabularies
    1. Hacks #59-67
    2. 59. Use XML Namespaces in an XML Vocabulary
      1. See Also
    3. 60. Create an RDDL Document
      1. See Also
    4. 61. Create and Validate an XHTML 1.0 Document
      1. See Also
    5. 62. Create Books, Technical Manuals, and Papers in XML with DocBook
      1. See Also
    6. 63. Create a SOAP 1.2 Document
      1. See Also
    7. 64. Identify Yourself with FOAF
      1. The FOAF Vocabulary
      2. Personal Metadata
      3. Identifying Marks
      4. It’s Who You Know
      5. Finer-Grained Relationships
      6. Image Is Everything
      7. Publishing FOAF Data
      8. See Also
    8. 65. Unravel the OpenOffice File Format
      1. See Also
    9. 66. Render Graphics with SVG
      1. See Also
    10. 67. Use XForms in Your XML Documents
      1. Anatomy of an XForms Document
      2. Simple Approaches to Trying Out XForms
      3. A Working Example
      4. See Also
  9. 5. Defining XML Vocabularies with Schema Languages
    1. Hacks #68-79
    2. 68. Validate an XML Document with a DTD
      1. External Subset
        1. The text declaration
        2. Element type declarations and content models
        3. Attribute-list declarations
      2. Internal Subset
        1. Using an internal subset and an external subset together
      3. Parameter Entities
      4. Other Things That Can Go in a DTD
        1. Comments
        2. Conditional sections
        3. Unparsed entities and notations
    3. 69. Validate an XML Document with XML Schema
      1. A Quick Introduction to XML Schema
      2. Validation with XML Schema Tools
        1. XSD Schema Validator
      3. xmllint
      4. xsv
      5. Other XML Schema Features
      6. See Also
    4. 70. Validate Multiple Documents Against an XML Schema at Once
    5. 71. Check the Integrity of a W3C Schema
    6. 72. Validate an XML Document with RELAX NG
      1. XML Syntax
        1. xmllint
        2. Jing
        3. A more complex RELAX NG schema
      2. Compact Syntax
        1. Jing with compact syntax
        2. RNV
        3. A more complex RELAX NG schema in compact syntax
      3. See Also
    7. 73. Create a DTD from an Instance
      1. Trang
      2. Relaxer
      3. DTDGenerator
      4. xmlspy
    8. 74. Create an XML Schema Document from an Instance or DTD
      1. LuMriX.net’s DTD2XS
      2. Microsoft XSD Inference 1.0
      3. Trang
      4. Relaxer
      5. xmlspy
    9. 75. Create a RELAX NG Schema from an Instance
      1. Trang (XML Syntax)
      2. Relaxer (XML Syntax)
      3. Trang (Compact Syntax)
    10. 76. Convert a RELAX NG Schema to XML Schema
    11. 77. Use RELAX NG and Schematron Together to Validate Business Rules
      1. Pulling Schematron Out of RELAX NG
      2. See Also
    12. 78. Use RELAX NG to Generate DTD Customizations
      1. Generating an RNC Schema
        1. Flattening your DTD
        2. Generating an RNC schema from your flattened DTD
      2. Creating an RNC Schema Customization File
      3. Compiling Your Customization File
      4. Converting Your RNC Customization File to RNG XML Syntax
      5. Using incelim.xsl to Compile Your RNG Customization File
      6. Generating Your DTD Subset
    13. 79. Generate Instances Based on Schemas
      1. Generating an Instance with xmlspy
      2. Generating an Instance with the Sun Instance Generator
      3. See Also
  10. 6. RSS and Atom
    1. Hacks #80-90
    2. 80. Subscribe to RSS Feeds
      1. Radio UserLand
      2. AmphetaDesk
      3. NewsGator
      4. See Also
    3. 81. Create an RSS 0.91 Document
    4. 82. Create an RSS 1.0 Document
      1. See Also
    5. 83. Create an RSS 2.0 Document
      1. See Also
    6. 84. Create an Atom Document
      1. Feed Entries
      2. See Also
    7. 85. Validate RSS and Atom Documents
      1. See Also
    8. 86. Create RSS with XML::RSS
      1. See Also
    9. 87. Syndicate Content with Movable Type
      1. Syndicating the Whole Post
      2. Including Trackback Links
      3. Creating Specialized Feeds
      4. Category Feeds
      5. Syndicating Comments
    10. 88. Post RSS Headlines on Your Site
      1. The Code
      2. Running the Hack
    11. 89. Create RSS 0.91 Feeds from Google
    12. 90. Syndicate a List of Books from Amazon with RSS and ASP
      1. What You Need
      2. The Code
      3. Running the Hack
  11. 7. Advanced XML Hacks
    1. Hacks #91-100
    2. 91. Pipeline XML with Ant
      1. Validating an XML Document
      2. The Jing Task
      3. An XML Pipeline Example
      4. See Also
    3. 92. Use Elements Instead of Entities to Avoid the “amp Explosion Problem”
      1. See Also
    4. 93. Use Cocoon to Create a Well-Formed View of a Web Page, Then Scrape It for Data
      1. Cocoon in 60 Seconds
      2. Running the Hack
      3. Extending the Hack
    5. 94. From Wiki to XML, Through SGML
      1. SGML: A Language for Describing Wikis
      2. An SGML Document Type for Wiki
      3. Which Wiki?
      4. Wiki as SGML
    6. 95. Create Well-Formed XML with JavaScript
      1. The Element Function
      2. Adding Attributes
      3. Extending the Hack
      4. Creating Large Chunks of XML
      5. See Also
    7. 96. Inspect and Edit XML Documents with the Document Object Model
      1. DOM Inspector
      2. Python’s minidom
      3. DOM in Java
      4. See Also
    8. 97. Processing XML with SAX
      1. A Little Help from SAX
      2. See Also
    9. 98. Process XML with C#
      1. Getting C#
      2. Writing an XML Document with XmlTextWriter
      3. Reading XML
      4. See Also
    10. 99. Generate Code from XML
      1. Using Relaxer to Generate Java
      2. Using xmlspy to Generate C#
      3. See Also
    11. 100. Create Well-Formed XML with Genx
      1. Setting Up Genx
      2. Compiling Genx
      3. A First Example
      4. Declare Markup for Better Performance
  12. Index
  13. About the Author
  14. Colophon
  15. Copyright

Product information

  • Title: XML Hacks
  • Author(s): Michael Fitzgerald
  • Release date: July 2004
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596007119