Linking in XHTML 2.0
by Micah DubinkoThe Embedding Attribute Collection
So far, all the links that I've discussed are href-style links, which the user clicks to make things happen. But you'll also encounter links that load immediately -- especially images. For these, XHTML 2.0 defines the Embedding attribute collection.
The showcase attribute in this collection is src, which bears the URL of the remote resource, and normally gets traversed while the main document is loading; it requires no special action from the user. The other attribute, type, provides additional metadata about what?s expected at the other end.
One key design feature that?s easy to miss: If it can be loaded, the linked-to content replaces the element in question; in other words, a fallback mechanism is built-in, even over multiple levels of nesting. Listing 3 shows how this works.
Listing 3. Embedding fallback
<nl>
<li href="scp.html"/>
<li href="/"/>
</nl>
</p>
In Listing 3, a text-only browser, or a graphical browser with images turned off sees a navigation list, but everyone else sees the interactive image map defined on the p element, the details of which are specified in map1. This fallback behavior is used to good effect with the object element, as shown in Listing 4.
Listing 4. Object fallback
<object src="earthtime.swf" type="application/x-shockwave-flash">
<!-- Else, try the image -->
<object src="earthtime.jpg" type="image/jpeg"/">
<!-- Else, alternate text -->
A map of the earth showing night and day
</object>
</object>
Browsers encountering the code in Listing 4 first try to load the Flash applet. If that fails for any reason, the browser attempts to load the JPG image. If that too fails, then the browser displays the innermost alternate text. Web users welcome this kind of flexibility.
Are We There Yet?
It's safe to say that standards development around hypertext linking hasn't worked out the way anyone initially envisioned it. But at last, it looks like progress is being made. XHTML 2.0 goes to great lengths to remain friendly to authors who learn mainly through their browser?s View source feature, while adding power and flexibility.
XHTML 2.0 is approaching a Last Call period, during which time the Working Group will solicit constructive comments. If other W3C efforts serve as a reliable guide, this could be a lengthy and possibly contentious period. But even today, XHTML 2.0 has a positive effect as it stimulates linking-related discussions within the Web development community. All the right people are now aware of the issues, and talking things through, and that?s good news.
Only time will tell what the end result will be. Yet many are hopeful that XHTML 2.0 will be a step towards a better Web.
Resources
• Check out Robin Cover?s archive, which includes a thorough compendium of documents on XML and linking. So closely were these topics tied together that many of the earlier links appear under the XML page. Others appear under the XLL page.
• Get an alternate viewpoint on XHTML linking through " A Hyperlink Offering," the author?s fictional account of a discussion between two literary characters about some of the challenges of hypertext linking.
• Go straight to the source and read the XLink 1.0 W3C Recommendation.
• Next, compare notes with the HLink Working Draft, dated September 2002 (and not likely to be updated again).
• Finally, read the latest XHTML 2.0 Working Draft to see the current status of linking in XHTML.
• Read about the replacement for frames (that?s often used with the target attribute), XFrames, a W3C Working Draft that works alongside XHTML 2.0.
• See if new specifications or documents are under development at the W3C -- consult the Technical Reports page.
• Read the full text of the O?Reilly book XForms Essentials online. XForms takes a similar approach to linking as XHTML 2.0. You can also order the book from the developerWorks Developer Bookstore.
• Want a more complete understanding of how all the major XML standards interrelate? Check out Uche Ogbuji?s excellent four-part survey of XML standards here on developerWorks:
• Part 1 -- The core standards (January 2004)
• Part 2 -- XML processing standards (February 2004)
• Part 3 -- The most important vocabularies (February 2004)
• Part 4 -- Detailed cross-reference of the most important XML standards (March 2004)
• Find more XML resources on the developerWorks XML zone.
• Learn how you can become an IBM Certified Developer in XML and related technologies.
Options:
Printer Friendly
Email Friend
Micah Dubinko is a consultant and founder of Brain Attic, L.L.C., a software vendor and consultancy specializing in defeating information overload. He wrote XForms Essentials for O'Reilly Media and served on the Working Group that developed XForms 1.0. He lives and works in Phoenix, AZ. You can contact him at micah@brainattic.info.
