Enter your mobile number or email address below and we'll send you a link to download the free Kindle App. Then you can start reading Kindle books on your smartphone, tablet, or computer - no Kindle device required.

  • Apple
  • Android
  • Windows Phone
  • Android

To get the free app, enter your mobile phone number.

Kindle Price: £18.71

Save £13.28 (42%)

includes VAT*
* Unlike print books, digital books are subject to VAT.

These promotions will be applied to this item:

Some promotions may be combined; others are not eligible to be combined with other offers. For details, please see the Terms & Conditions associated with these promotions.

Deliver to your Kindle or other device

Deliver to your Kindle or other device

XML in a Nutshell (In a Nutshell (O'Reilly)) by [Harold, Elliotte Rusty, Means, W. Scott]
Kindle App Ad

XML in a Nutshell (In a Nutshell (O'Reilly)) Kindle Edition

4.4 out of 5 stars 7 customer reviews

See all formats and editions Hide other formats and editions
Amazon Price
New from Used from
Kindle Edition
"Please retry"
£18.71

Length: 714 pages

Kindle Books from 99p
Load up your Kindle library before your next holiday -- browse over 500 Kindle Books on sale from 99p until 31 August, 2016. Shop now

Product Description

About the Author

Elliotte Rusty Harold is originally from New Orleans to which he returns periodically in search of a decent bowl of gumbo. However, he currently resides in the Prospect Heights neighborhood of Brooklyn with his wife Beth, dog Shayna, and cat Marjorie (named after his mother-in-law). He's a frequent speaker at industry conferences including Software Development, Dr. Dobb's Architecure & Design World, SD Best Practices, Extreme Markup Languages, and too many user groups to count. His open source projects include the XOM Library for processing XML with Java and the Amateur media player.

W. Scott Means has been a professional software developer since 1988, when he joined Microsoft Corporation at the age of 17. He was one of the original developers of OS/2 1.1 and Windows NT, and did some of the early work on the Microsoft Network for the Microsoft Advanced Technology and Business Development group. Since then he has written software for everything from multiplayer casino games to railroad geometry measurement equipment. For Scott's latest projects and musings on software development, visit his blog at smeans.com.

Excerpt. © Reprinted by permission. All rights reserved.

Chapter 9 Xpath

XPath is a non-XML language for identifying particular parts of XML documents. XPath lets you write expressions that refer to, for example, the first person element in a document, the seventh child element of the third person element, theID 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 to which an XLink links. The W3C XML Schema Language uses XPath expressions to define uniqueness and identity constraints. XForms relies on XPath to bind form controls to instance data, express constraints on user-entered values, and calculate values that depend on other values.

XPath expressions can also represent numbers, strings, or Booleans. This lets XSLT stylesheets carry out simple arithmetic for purposes such as numbering and cross-referencing figures, tables, and equations. String manipulation in XPath lets XSLT perform tasks such as making the title of a chapter uppercase in a headline or extracting the last two digits from a year.

The Tree Structure of an XML Document
An XML document is a tree made up of nodes. Some nodes contain one or more other nodes. There is exactly one root node, which 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 nodesText nodes
• Attribute nodes
• Comment nodes
• Processing-instruction nodes
• Namespace nodes

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

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

Example 9-1. The example XML document used in this chapter

<?xml-stylesheet type="application/xml" href="people.

Richard
P
Feynman

physicist
Playing the bongoes

The XPath data model has several nonobvious features. First of all, the root node of the tree is not the same as the root element. The root node of the tree contains the entire document including the root element, as well as any comments and processing instructions that occur before the root element start-tag or after the root element end-tag. In Example 9-1, this means the root node contains the xmlstylesheet processing instruction, as well as the root element people.

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

Finally, xmlns and xmlns:prefix attributes are not considered attribute nodes. However, namespace nodes are attached to every element node for which a declaration
is in scope. They are not attached to just the single element where the
namespace is declared.

Location Paths
The most useful XPath expression is a location path. A location path identifies a set of nodes in a document. This set may be empty, may contain a single node, or may contain several nodes. These can be element nodes, attribute nodes, nmespace nodes, text nodes, comment nodes, processing-instruction nodes, root nodes, or any combination of these. A location path is built out of successive location steps. Each location step is evaluated relative to a particular node in the document called the context node.

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

/ is an absolute location path because no matter what the context node is—that is, no matter where the processor was in the input document when this template rule was applied—it always means the same thing: the root node of the document. It is relative to which document you’re processing, but not to anything within that document.


Product details

  • Format: Kindle Edition
  • File Size: 4293 KB
  • Print Length: 714 pages
  • Simultaneous Device Usage: Unlimited
  • Publisher: O'Reilly Media; 3 edition (23 Sept. 2004)
  • Sold by: Amazon Media EU S.à r.l.
  • Language: English
  • ASIN: B0093T2JFS
  • Text-to-Speech: Enabled
  • X-Ray:
  • Word Wise: Not Enabled
  • Enhanced Typesetting: Not Enabled
  • Average Customer Review: 4.4 out of 5 stars 7 customer reviews
  • Amazon Bestsellers Rank: #404,445 Paid in Kindle Store (See Top 100 Paid in Kindle Store)
  •  Would you like to give feedback on images or tell us about a lower price?


Customer Reviews

4.4 out of 5 stars
Share your thoughts with other customers

Top Customer Reviews

Format: Paperback Verified Purchase
As a scientist and one who has some programining experience I am accustomed to grappling with difficult texts and difficult concepts. I don't roll over and give up if the info is not fed to me in nice, easy, bite-sized bits.
Along the long and continuing learning curve of becoming a scientist I have encountered a number of texts where I felt 'if you can actually extract meaning and useable information from the this then you don't need to read it because you are, infact, an expert anyway' - as was clearly the case with a couple of the previous reviewers.
It would be wrong of me to completely diss this book as I don't know whether it would be a really useful book for the intended readership - whovever that might be - no info is given in the text or on the cover as to whoever the intended readership is. Hence the two stars (I felt I wanted to give it none)
I would therefore offer up the following (I think fair) comments:
This text is NOT an introduction to XML - it is clearly written for those who already have a good working knowledge of XML.
Contrary to a previous review I think the book is NOT at all a good overview of XML. If you want to know why and where you would need to use XML, whether it is necessary for the purpose you wish to pursue, overall where XML is deployed and why it is fit for the purposes, then this book does not really answer this type of question. Yes the authors do give some very brief, one line statements about applications but they are very, very brief, terse, and dead ends.
The book is not a practical 'OK let's do it' book which guides you through creating a simple XML document (whatever), no guidance is given as to what tools you need to use XML or to see the results.
Read more ›
Comment 2 people found this helpful. Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback.
Sorry, we failed to record your vote. Please try again
Report abuse
Format: Paperback Verified Purchase
True to form for the Nutshell guides, its brief, to the point and explains most XML related concepts XSL, XPATH, XML Schema etc in a really readble format.

If you've every written an kind of programming language then this is an excellent guide to take you through XML.

I wouldn't say the coverage is 100%, it simply wouldn't fit in a concise guide like this if it were, it will cover the vast majority - theres always google for that one case of something really odd.
Comment 5 people found this helpful. Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback.
Sorry, we failed to record your vote. Please try again
Report abuse
Format: Paperback Verified Purchase
I sold this book. I wish I hadn't.

I write 'correct' XHTML: all the online tutorials tell me that, hey, I've got it down already. They're wrong; I hadn't even skimmed the surface!

This hefty tome takes you all the way from first XML principles to tantalising challenges, where you see just how powerful a universally-understood protocol can be. I read those parts, but wasn't ready to put them into practice ... I want the book back!!

I'd advise getting it, using it until the pages have turned to mulch, and keeping up with the related websites. Don't let its weight & volume put you off, like I did!
Comment 2 people found this helpful. Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback.
Sorry, we failed to record your vote. Please try again
Report abuse
Format: Paperback Verified Purchase
As for all the 'In a Nutshell' books this gives a good overview and context for XML, so even if you don't end up doing any programming, you could benefit from reading it anyway.
Comment Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback.
Sorry, we failed to record your vote. Please try again
Report abuse
click to open popover