×

Uh-oh, it looks like your Internet Explorer is out of date.

For a better shopping experience, please upgrade now.

XML in a Nutshell: A Desktop Quick Reference
     

XML in a Nutshell: A Desktop Quick Reference

3.9 10
by Elliotte Rusty Harold, W. Scott Means
 

See All Formats & Editions

If you're a developer working with XML, you know there's a lot to know about XML, and the XML space is evolving almost moment by moment. But you don't need to commit every XML syntax, API, or XSLT transformation to memory; you only need to know where to find it. And if it's a detail that has to do with XML or its companion standards, you'll find it--clear, concise

Overview

If you're a developer working with XML, you know there's a lot to know about XML, and the XML space is evolving almost moment by moment. But you don't need to commit every XML syntax, API, or XSLT transformation to memory; you only need to know where to find it. And if it's a detail that has to do with XML or its companion standards, you'll find it--clear, concise, useful, and well-organized--in the updated third edition of XML in a Nutshell.With XML in a Nutshell beside your keyboard, you'll be able to:

  • Quick-reference syntax rules and usage examples for the core XML technologies, including XML, DTDs, Xpath, XSLT, SAX, and DOM
  • Develop an understanding of well-formed XML, DTDs, namespaces, Unicode, and W3C XML Schema
  • Gain a working knowledge of key technologies used for narrative XML documents such as web pages, books, and articles technologies like XSLT, Xpath, Xlink, Xpointer, CSS, and XSL-FO
  • Build data-intensive XML applications
  • Understand the tools and APIs necessary to build data-intensive XML applications and process XML documents, including the event-based Simple API for XML (SAX2) and the tree-oriented Document Object Model (DOM)
This powerful new edition is the comprehensive XML reference. Serious users of XML will find coverage on just about everything they need, from fundamental syntax rules, to details of DTD and XML Schema creation, to XSLT transformations, to APIs used for processing XML documents. XML in a Nutshell also covers XML 1.1, as well as updates to SAX2 and DOM Level 3 coverage. If you need explanation of how a technology works, or just need to quickly find the precise syntax for a particular piece, XML in a Nutshell puts the information at your fingertips.Simply put, XML in a Nutshell is the critical, must-have reference for any XML developer.

Editorial Reviews

bn.com
The Barnes & Noble Review
Trying to capture all of XML in one compact book is like trying to capture the universe moments after the Big Bang: Things are expanding in an awful hurry. But this tutorial and reference comes close.

Elliotte Rusty Harold and W. Scott Means organize XML in a Nutshell -- and by extension XML itself -- into four sections. The first offers clear, to-the-point explanations of the key concepts every XML user and developer needs to understand -- from elements and attributes to well-formedness, DTDs to namespaces. Section II covers the XML technologies most widely used in what the authors call "narrative-centric" documents -- from web pages through gigantic Defense Department documentation manuals. Here's where they introduce XHTML, basic XSL Transformations, XPath, Xlinks, Xpointers, Cascading Style Sheets, and the evolving XSL Formatting Objects specification.

Section III addresses XML's role as the data format of choice for Internet-based information sharing and storage. Harold and Means introduce XML programming models, then offer quick introductions to both DOM and SAX.

Like most O'Reilly ...in a Nutshell books, XML in a Nutshell ends with a comprehensive reference section, presenting syntax, descriptions, attributes, and in the case of DOM, Java bindings and example code.

There are a few things missing -- for example, coverage of SOAP, and of specialized XML applications such as MathML. But overall, the book succeeds admirably in its goals: to become your first-line source whenever you need to learn something new about XML. (Bill Camarda) (Bill Camarda)

Bill Camarda is a consultant and writer with nearly 20 years' experience in helping technology companies deploy and market advanced software, computing, and networking products and services. His 15 books include Special Edition Using Word 2000 and Upgrading & Fixing Networks For Dummies®, Second Edition.

Booknews
Introduces the basic rules of XML syntax for document markup, the details of document type definition (DTD) creation, and the APIs used to read and write XML documents in a variety of programming languages. A series of quick-reference chapters lists syntax rules for XPath, XSLT, SAX, and DOM. Annotation c. Book News, Inc., Portland, OR (booknews.com)

Product Details

ISBN-13:
9781449379049
Publisher:
O'Reilly Media, Incorporated
Publication date:
09/23/2004
Series:
In a Nutshell (O'Reilly)
Sold by:
Barnes & Noble
Format:
NOOK Book
Pages:
714
File size:
7 MB

Read an Excerpt

Chapter 9: XPath

XPath is a non-XML language used to identify particular parts of XML documents. XPath lets you write expressions that refer to the document's first person element, the seventh child element of the third person element, the ID attribute of the first person element whose contents are the string "Fred Jones," all xml-stylesheet processing instructions in the document's prolog, and so forth. XPath indicates nodes by position, relative position, type, content, and several other criteria. XSLT uses XPath expressions to match and select particular elements in the input document for copying into the output document or further processing. XPointer uses XPath expressions to identify the particular point in or part of an XML document that an XLink links to.

XPath expressions can also represent numbers, strings, or Booleans, so XSLT stylesheets carry out simple arithmetic for numbering and cross-referencing figures, tables, and equations. String manipulation in XPath lets XSLT perform tasks like making the title of a chapter uppercase in a headline, but mixed case in a reference in the body text.

The Tree Structure of an XML Document

An XML document is a tree made up of nodes. Some nodes contain other nodes. One root node ultimately contains all other nodes. XPath is a language for picking nodes and sets of nodes out of this tree. From the perspective of XPath, there are seven kinds of nodes:

  • The root node

  • Element nodes

  • Text nodes

  • Attribute nodes

  • Comment nodes

  • Processing instruction nodes

  • Namespace nodes

Note the constructs not included in this list: CDATA sections, entity references, and document type declarations. XPath operates on an XML document after these items have merged into the document. For instance, XPath cannot identify the first CDATA section in a document or tell whether a particular attribute value was included directly in the source element start tag or merely defaulted from the declaration of the attribute in the DTD.

Consider the document in Example 9-1. This document exhibits all seven types of nodes. Figure 9-1 is a diagram of this document's tree structure....

...The XPath data model has several inobvious features. First, the tree's root node is not the same as its root element. The tree's root node contains the entire document, including the root element and comments and processing instructions that occur before the root element start tag or after the root element end tag. In Example 9-1, the root node contains the xml-stylesheet processing instruction and the root element people.

The XPath data model does not include everything in the document. In particular, the XML declaration and DTD are not addressable via XPath. However, if the DTD provides default values for any attributes, then XPath recognizes those attributes. The homepage element has an xlink:type attribute supplied by the DTD. Similarly, any references to parsed entities are resolved. Entity references, character references, and CDATA sections are not individually identifiable, though any data they contain is addressable. For example, XSLT does not enable you to make all text in CDATA sections bold because XPath doesn't know what text is and isn't part of a CDATA section.

Finally, xmlns attributes are reported as namespace nodes. They are not considered attribute nodes, though a non-namespace aware parser will see them as such. Furthermore these nodes are attached to every element and attribute node for which that declaration has scope. They are not just attached to the single element where the namespace is declared.

Location Paths

The most useful XPath expression is a location path. A location path uses at least one location step to identify a set of nodes in a document. This set may be empty, contain a single node, or contain several nodes. These nodes can be element, attribute, namespace, text, comment, processing instruction, root nodes, or any combination of them.

The Root Location Path

The simplest location path is the one that selects the document's root node. This path is simply the forward slash /. (You'll notice that a lot of XPath syntax was deliberately chosen to be similar to the syntax used by the Unix shell. Here / is the root of a Unix filesystem and / is the root node of an XML document.) For example, this XSLT template uses the XPath pattern / to match the entire input document tree and wrap it in an html element...

Meet the Author

Elliotte Rusty Harold is an adjunct professor of computer science at Polytechnic University in Brooklyn, New York, where he lectures on object-oriented programming and XML. His Cafe con Leche Web site has become one of the most popular sites for information on XML. In addition, he is the author and coauthor of numerous books, the most recent of which are "The XML Bible" (John Wiley & Sons, 2001) and "XML in a Nutshell" (O'Reilly, 2002).
0321150406AB08272003

Means began his career as a software developer with Microsoft in 1988, joining the company at the age of 17. He is currently serving as President and CEO of Enterprise Web Machines, a South Carolina-based Internet software product and services company.

Customer Reviews

Average Review:

Post to your social network

     

Most Helpful Customer Reviews

See all customer reviews

XML in a Nutshell 4.1 out of 5 based on 0 ratings. 7 reviews.
Anonymous More than 1 year ago
Guest More than 1 year ago
The organization of the book is great. Very useful and well written. It provides quick-reference syntax rules and usage examples for the core XML technologies, including XML, DTDs, Xpath, XSLT, SAX, and DOM. Develop an understanding of well-formed XML, DTDs, namespaces, Unicode, and W3C XML Schema. This new edition is the comprehensive XML reference. Serious users of XML will find coverage on just about everything they need, from fundamental syntax rules, to details of DTD and XML Schema creation, to XSLT transformations, to APIs used for processing XML documents. The initial chapter on SAX along with the reference chapter would give me a solid foundational base from which to work. If you need explanation of how a technology works, or just need to quickly find the precise syntax for a particular piece, XML in a Nutshell puts the information at your fingertips. I would recommend this book to someone interested in its topic. This book has earned a valued place on my reference shelf.
Guest More than 1 year ago
In my opinion, XML In A Nutshell is the definitive reference for XML syntax and use. I¿ve had this book on my desk since the first edition. Now at edition 3, this book just keeps getting better and better. It covers virtually every XML standard, provides lots of examples, and has a character set reference that I couldn¿t live without. Highly recommended for all XML questions. Like many of the ¿Nutshell¿ books, this book starts off with a lot of informational chapters, designed to give a high level view of many XML-related technologies. These chapters, while a bit vague in parts, are still very good and will answer most general questions. However, when you have a deeper question, the reference chapters in the second half of the book really shine. The reference material is well organized, making information easy to find and digest. Personally, my favorite chapters are the XPath Reference and the XSLT Reference sections. Anyone who works with XML on a daily basis should have this book at their desk. This is the one book to have on XML.
Guest More than 1 year ago
How much XML do you need to know? Me, I read and write XML daily in my programs. But without having to support legacy data, I've found that I can use a very minimal subject to good effect. No mixed content, no attributes in tags, etc. So I can use SAX very easily. And I only need a small subset of this book. But chances are that you may not be in such an easy situation. You might have to transform XML data using XSLT. While conceptually simple, the details are complex. So the book's section on XSLT can be vital. Another usage context is when you have to do some kind of search within XML data. The purview of XPath, XPointer and XLink. More good stuff to lookup here for explanations. Harold writes fluently about XML. He has several other well received books on XML. So technically, you can rely on this book to get the details right. But few of you should need to know all of this book. XML has grown vastly, to serve increasingly different and specialised needs. The book tries to address the totality of these needs. So don't be intimidated if you see chapters that you are totally unaware of. I'm in the same boat as you, and so are many others.
Guest More than 1 year ago
Let me put it this way : I have the first edition, yet I just shelled out $36 for the second edition. 'Nuff said.
Guest More than 1 year ago
My bunny head is a cow. I ate cerial sixteen times in one evening once. Toots toots, bo bo goots. Im going to throw at your face some darts.
Guest More than 1 year ago
The Nutshell series of books from O¿Reilly have a special section of my desk established for them; no other set of books condenses so much information for reference. This book is no exception to this fact.

Before I continue, please avoid buying an O¿Reilly Nutshell book expecting it to teach you about the topic it is intended for. As far as I¿ve worked with them, these books are not intended as a do-all be-all that other references want to be. The information introducing you to XML is sparse, so if you don¿t know anything about XML, get another book. I recommend XML: A Primer by Simon St. Laurent; it is an excellent learning tool, and though it doesn¿t go into all the detail the XML standard can go into (no book I¿ve found can do such), it provides the user with understanding of XML.

XML in a Nutshell is what I use when I¿ve forgotten how to use a certain aspect of XML detail. As a reference and a second book on XML, nothing comes close.