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