XPointers

XLinks let you link to a particular document, but you often need to be more precise than that. XPointers let you point to specific locations inside a documentwithout having to modify that document by embedding special tags or markers.

To point to a specific location in a document, the XPointer specification builds on the XPath specification. As you recall, we covered the XPath specification in Chapter 13; it let you identify specific nodes in a document with expressions such as /child::*[position()=126]/child::*[position() =first()] .

XPointers are in the W3C candidate recommendation stage. As of this writing, the version is September 11, 2001. You can find the most current version of this specification at www.w3.org/TR/xptr. Here's what W3C says about XPointers:

This specification defines the XML Pointer Language (XPointer), the language to be used as the basis for a fragment identifier for any URI reference that locates a resource whose Internet media type is one of text/xml, application/xml, text/xml-external-parsed-entity, or application/xml- external-parsed-entity.

XPointer, which is based on the XML Path Language (XPath), supports addressing into the internal structures of XML documents and external parsed entities. It allows for examination of a hierarchical document structure and choice of its internal parts based on various properties, such as element types, attribute values, character content, and relative position.

Although XPointer is built on the XPath specification (which is covered in Chapter 13 and is at www.w3.org/TR/xpath), the XPointer specification extends XPath in ways we'll see in this chapter.

How do you add an XPointer to a document's URI to specify a specific location in a document? You can append # (following the HTML usage for URLs that specify link targets) and then xpointer() , placing the XPath expression you want to use in the parentheses. Here's an example:

 <MOVIE_REVIEW xmlns:xlink = "http://www.w3.org/1999/xlink"      xlink:type = "simple"     xlink:show = "new"  xlink:href="http://www.starpowdermovies.com/reviews.xml#xpointer(/child::*[position( graphics/ccc.gif )=126]/child::* [position()=first()])">  Mr. Blandings Builds His Dream House </MOVIE_REVIEW> 

That gives us an overview of XLinks and XPointers. I'm going to cover both of these specifications, as well as the XBase specification, starting now with XLinks.



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net