- XML Reference Guide
- Overview
- What Is XML?
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Table of Contents
- The Document Object Model
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- DOM and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- Implementations
- DOM and JavaScript
- Using a Repeater
- Repeaters and XML
- Repeater Resources
- DOM and .NET
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Downloads
- DOM and C++
- DOM and C++ Resources
- DOM and Perl
- DOM and Perl Resources
- DOM and PHP
- DOM and PHP Resources
- DOM Level 3
- DOM Level 3 Core
- DOM Level 3 Load and Save
- DOM Level 3 XPath
- DOM Level 3 Validation
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Implementations
- The Simple API for XML (SAX)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- SAX and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- SAX and .NET
- Informit Articles and Sample Chapters
- SAX and Perl
- SAX and Perl Resources
- SAX and PHP
- SAX and PHP Resources
- Validation
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Document Type Definitions (DTDs)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XML Schemas
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- RELAX NG
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Schematron
- Official Documentation and Implementations
- Validation in Applications
- Informit Articles and Sample Chapters
- Books and e-Books
- XSL Transformations (XSLT)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XSLT in Java
- Java in XSLT Resources
- XSLT and RSS in .NET
- XSLT and RSS in .NET Resources
- XSL-FO
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XPath
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XML Base
- Informit Articles and Sample Chapters
- Official Documentation
- XHTML
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XHTML 2.0
- Documentation
- Cascading Style Sheets
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XUL
- XUL References
- XML Events
- XML Events Resources
- XML Data Binding
- Informit Articles and Sample Chapters
- Books and e-Books
- Specifications
- Implementations
- XML and Databases
- Informit Articles and Sample Chapters
- Books and e-Books
- Online Resources
- Official Documentation
- SQL Server and FOR XML
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Implementations
- Service Oriented Architecture
- Web Services
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Creating a Perl Web Service Client
- SOAP::Lite
- Amazon Web Services
- Creating the Movable Type Plug-in
- Perl, Amazon, and Movable Type Resources
- Apache Axis2
- REST
- REST Resources
- SOAP
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- SOAP and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- WSDL
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- UDDI
- UDDI Resources
- XML-RPC
- XML-RPC in PHP
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Ajax
- Asynchronous Javascript
- Client-side XSLT
- SAJAX and PHP
- Ajax Resources
- JSON
- Ruby on Rails
- Creating Objects
- Ruby Basics: Arrays and Other Sundry Bits
- Ruby Basics: Iterators and Persistence
- Starting on the Rails
- Rails and Databases
- Rails: Ajax and Partials
- Rails Resources
- Web Services Security
- Web Services Security Resources
- SAML
- Informit Articles and Sample Chapters
- Books and e-Books
- Specification and Implementation
- XML Digital Signatures
- XML Digital Signatures Resources
- XML Key Management Services
- Resources for XML Key Management Services
- Internationalization
- Resources
- Grid Computing
- Grid Resources
- Web Services Resource Framework
- Web Services Resource Framework Resources
- WS-Addressing
- WS-Addressing Resources
- WS-Notifications
- New Languages: XML in Use
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Google Web Toolkit
- GWT Basic Interactivity
- Google Sitemaps
- Google Sitemaps Resources
- Accessibility
- Web Accessibility
- XML Accessibility
- Accessibility Resources
- The Semantic Web
- Defining a New Ontology
- OWL: Web Ontology Language
- Semantic Web Resources
- Google Base
- Microformats
- StructuredBlogging
- Live Clipboard
- WML
- XHTML-MP
- WML Resources
- Google Web Services
- Google Web Services API
- Google Web Services Resources
- The Yahoo! Web Services Interface
- Yahoo! Web Services and PHP
- Yahoo! Web Services Resources
- eBay REST API
- WordML
- WordML Part 2: Lists
- WordML Part 3: Tables
- WordML Resources
- DocBook
- Articles
- Books and e-Books
- Official Documentation and Implementations
- XML Query
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XForms
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Resource Description Framework (RDF)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Topic Maps
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation, Implementations, and Other Resources
- Rich Site Summary (RSS)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Simple Sharing Extensions (SSE)
- Atom
- Podcasting
- Podcasting Resources
- Scalable Vector Graphics (SVG)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- OPML
- OPML Resources
- Summary
- Projects
- JavaScript TimeTracker: JSON and PHP
- The Javascript Timetracker
- Refactoring to Javascript Objects
- Creating the Yahoo! Widget
- Web Mashup
- Google Maps
- Indeed Mashup
- Mashup Part 3: Putting It All Together
- Additional Resources
- Frequently Asked Questions About XML
- What's XML, and why should I use it?
- What's a well-formed document?
- What's the difference between XML and HTML?
- What's the difference between HTML and XHTML?
- Can I use XML in a browser?
- Should I use elements or attributes for my document?
- What's a namespace?
- Where can I get an XML parser?
- What's the difference between a well-formed document and a valid document?
- What's a validating parser?
- Should I use DOM or SAX for my application?
- How can I stop a SAX parser before it has parsed the entire document?
- 2005 Predictions
- 2006 Predictions
- Nick's Book Picks
One of the advantages of XML is its flexibility, but in the wrong hands, that can also be a disadvantage. For example, if you were going to represent a graphic image using XML, you could create your own format, but why should you? Why not use Scalable Vector Graphics (SVG) instead, so your users can simply use the existing SVG viewer? Simiarly, writing a web page in HTML means that there are existing cleints (browsers) that can read it. But what about producing longer works? DocBook is designed for just such a situation.
Like XML, DocBook is based on Standard Generalized Markup Language (SGML). It's actually been around since before XML, but has subsequently been adapted to XML's peculiarities. Originally designed for book-length works, DocBook documents are easily converted to HTML, PDF, or other environments using transformative or stylistic technhologes such as Extensible Stylesheet Language Transformations (XSLT) or Cascading Style Sheets (CSS), and standard solutions for these processses exist from the army of developers dedicated to the standard.
Let's take a look at a sample DocBook document. We'll start by looking at the informational elements. For example, a DocBook document containing the content of XML Primer Plus might start with:
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> <book> <bookinfo> <title>XML Primer Plus</title> <author> <firstname>Nicholas</firstname> <surname>Chase</surname> </author> <copyright> <year>2002</year> <holder>Sams Publishing</holder> </copyright> </bookinfo> ... </book>
From there, we can add parts and chapters:
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> <book> <bookinfo> <title>XML Primer Plus</title> <author> <firstname>Nicholas</firstname> <surname>Chase</surname> </author> <copyright> <year>2002</year><holder>Sams Publishing</holder> </copyright> </bookinfo> <preface> <title>Introduction</title> ... </preface> <part>> <title>XML Fundamentals</title> <chapter> <title>Basic XML Document Structure</title> ... </chapter> <chapter> <title>Designing XML Documents and Applications</title> ... </chapter> <chapter> <title>Manipulating Documents: The Document Object Model (DOM)</title> ... </chapter> ... </part> <part> <title>Using XML</title> <chapter> <title>Browser-Based XML: Cascading Style Sheets (CSS)</title> ... </chapter> <chapter> <title>Browser-Based XML: XHTML</title> ... </chapter> <chapter> <title>XML Linking Language (XLink)</title> ... </chapter> ... </part> <part> <title>Appendixes</title> <appendix> <title>Resources</title> ... </appendix> <appendix> <title>XML Information Set</title> ... </appendix> <appendix> <title>Questions and Answers</title> ... </appendix> </part> </book>
Now, within each of these chapters (or for that matter, within any sections that can contain content, such as the preface or an appendix) there are a myriad of useful elements that define the structure of the content. Perhaps the most commonly used would be the paragraph and section elements. For example:
... <chapter> <title>Designing XML Documents and Applications</title> <para>Before we actually build anything, let's look at planning the structure of the data. Yes, yes, I know, you're anxious to get your hands dirty, and so am I, but planning is an essential part of any applicaton and XML-related applications are no exception. The structure of your documents is the underpinning for your entire system. If you don't take the time to understand exactly what you're building, and more importantly, why you're building it, you're setting yourself up for failure.</para> <para>In this chapter, we're going to discuss the various aspects of planning for the data and structure ...</para> ... <sect1> <title>The Planning Process</title> <para>Because XML is inherenetly simple, the temptation is to simply create the structure as you go along, a process known as "designing at the keyboard." As tempting as this may be, a multitute of reasons exists for avoiding it.</para> ... <sect1> ... </chapter> ...
In actuality, there are serveral types of sections. Here I've used sect1, which can contain one or more sect2s, which can contain one or more sect3s, and so on, up to sect5 (but no further). You can also use sections, which can be infinitely recursed, or simplesects, which can't contain any other sections.
There are also numerous elements for dealing with items such as lists, code sections, references, tables, and so on. In fact, there are so many elements that a leaner version of DocBook, Simplified DocBook, has been created to make things a bit simpler.
Simplified DocBook is meant for smaller peices, such as articles, but you can also create these smaller pieces in DocBook proper. For example, an article from InformIT might look like this:
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> <article> <articleinfo> <title>Using XML and XSLT to Personalize a Web Site Part 1</title> <subtitle>Using XSLT to Transform XML to HTML</subtitle> <author> <firstname>Norman</firstname> <surname>Walsh</surname> </author> <copyright> <year>2001</year><holder>Nicholas Chase</holder> </copyright> </articleinfo> <para>You might assume that adding the word "personalization" to your Web site means adding a digit or two to your budget, but it doesn't have to be that way. Personalization means creating a Web site that adjusts to your visitors' preferences and interests, and to some extent, you can accomplish this with XML and XSL Transformations.</para> ... <section> <title>The Basic Idea</title> <para>You may already be familiar with the way that Cascading Style Sheets (CSS) can be used to change the look and feel of your Web site. With CSS, you specify the way that you want certain items to look by creating styles for classes of items, or even for specific HTML tags. Changing the site's look and feel means simply changing the style sheet. The browser then carries the changes through to each affected page. In this way, the same HTML page can look profoundly different, depending on the style sheet chosen.</para> ... </section> ... </article>
Overall, you can see that DocBook provides a ready-made structure for information content. Check out the resoruces for more information on using DocBook in your own projects, particularly when it comes to transforming it into other formats.