| home / programming / xml_24 / 2 | [previous] |
|
|
This code consists of six different links: five for the top five movies and
one as a contact link near the bottom of the document. The movie links all link
to Amazon.com, whereas the contact link directs you to my web site. The movie
links all have their show attributes set to replace,
which means the linked resource is opened in the same window as (replaces) the
original document. The contact link is slightly different in that its show
attribute is set to new (line 45), which means the linked resource
is opened in a new window. The actuate attribute for all of the
links is set to onRequest (line 46), which requires the user to
click the links in order for them to be navigated. Figure 22.5 shows the Top
Five movie document as viewed in Firefox.

You may be wondering how the browser knows to underline the links. There isn’t anything magical going on here. I just neglected to show you the CSS stylesheet that is responsible for styling the Top Five document. You can find this stylesheet along with the complete code for this book on my web site, which is located at http://www.michaelmorrison.com/.
If you think of an XML document as a hierarchical tree of data, which it is, then it’s not too hard to make a comparison between XML documents and the family trees used in genealogy. This comparison is useful because it turns out that one of the best ways to interact with XML data is by thinking in terms of nodes of data that are related to each other as family members. For example, there are parent, child, and sibling nodes at most points in a document’s node tree. XPath is a technology that takes advantage of this hierarchical nature of XML by allowing you to reference parts of XML documents as nodes within a node tree. Although you’ve heard mention of XPath earlier in the book, this hour formally introduced you to it and explored what it has to offer in terms of referencing XML documents.
XPath plays a role in two other emerging XML technologies, XLink and XPointer, which bring advanced linking support to XML, and at some point to the web. You found out about the theoretical underpinnings of XML linking and what it aims to accomplish. You then learned how to create expressions in XPointer, followed by links in XLink. Although you gained some practical knowledge of XLink and XPointer, there unfortunately is very little support for either technology in major web browsers at the moment. Even so, they are compelling enough technologies that you need to keep an eye out for them potentially making an impact in the XML landscape at some point.
Q. What is the relationship between XPath and XPointer?
A. XPath is a simple path language that uses patterns and expressions to reference portions of an XML document tree. XPointer extends XPath by offering more specific referencing capabilities within XML documents. XPointer also serves as the basis for identifying link sources and targets in XLink, which is the standard linking technology for XML.
Q. Why bother learning about XLink if it still isn’t supported to any serious degree in major web browsers?
A. The reason for learning about XLink has to do with the fact that it could possibly represent the future of XML document linking. The W3C spent years developing XLink with the goal of it becoming a standard technology with wide support. Admittedly, it’s difficult to get excited about a technology that is somewhat intangible at the moment, but that doesn’t necessarily lessen the future significance of XLink.
Q. Assuming XLink is eventually adopted by web browsers, how will it affect the HTML anchor link?
A. The HTML anchor link (a) is a unique element in HTML that has special meaning to web browsers. In terms of XML, the HTML a element is just another element that happens to be interpreted as a linking element. When browsers add support for XLink, it will be very easy for them to support the a element for backward compatibility, while also supporting new XLink links. Don’t forget that with XLink you can create your own anchor links with very little effort.
The Workshop is designed to help you anticipate possible questions, review what you’ve learned, and begin learning how to put your knowledge into practice.
1. How do you reference the current node in an XML document using XPath?
2. What is the difference between the / and // patterns in XPath?
3. What is a link repository?
4. What is a location path?
5. What is the difference between an inline link and an out-of-line link?1. To reference the current node in an XML document, you use a single period (.) as the pattern.
2. The / pattern in XPath is used to reference the root node of a document, whereas the // pattern selects all the child nodes of a particular node.
3. A link repository is a database of links that describe useful connections between resources on the Web.
4. A location path is a construct used to describe the path that must be followed to arrive at a node within an XML document tree; location paths are the building blocks of XPointer expressions.
5. The content associated with an inline link serves as one of the link’s participating resources, whereas the content associated with an out-of-line link does not.1. Now that you understand XPath a little better, modify the vehicles template
in the vehicles.xsl stylesheet from Hour 13 so that only green vehicles are
selected and displayed.
Excerpted from Sams Teach Yourself XML in 24 Hours, Complete Starter Kit, 3rd Edition by Michael Morrison. ISBN 067232797X, Copyright © 2005. Used with the permission of Que & Sams Publishing.
| home / programming / xml_24 / 2 | [previous] |
Created: March 27, 2003
Revised: December 19, 2005
URL: http://webreference.com/programming/xml_24/2