Describing Resources: xlink:role and xlink:title

Describing Resources: xlink:role and xlink:title

Two important XLink attributes are xlink:role and xlink:title , which let you describe a remote resource. Both of these attributes are optional. Here's an example that puts both of these attributes to work:

Listing ch15_05.xml
 <MOVIE_REVIEW xmlns:xlink = "http://www.w3.org/1999/xlink"     xlink:type = "simple"     xlink:show = "new"  xlink:role = "MOVIE_REVIEW[EN]"   xlink:title = "Review of 'Mr. Blandings Builds His Dream House'"  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> 

The xlink:title attribute here has the value "Review of 'Mr. Blandings Builds His Dream House'" . This is a human-readable description of the resource that the link links to; the idea here is that a person can read this text to get more information about the remote resource that the link points to. An application might display this text on demand.

The text of the xlink:role attribute, on the other hand, is designed to be read by software. A link's role indicates the category of a link. In this case, the text of the link's role is "MOVIE_REVIEW[EN]" .

No attempt has been made to standardize roles as there has been in the Remote Description Framework language we first saw in Chapter 1, "Essential XML"; there are simply too many possibilities. Although search engines can use the link's role to classify the link, you usually use roles to define directional links when creating extended links, and I'll take a look at that soon.

If you want to create valid documents, you have to declare the xlink:role and xlink:title attributes, as in this case where I'm using a DTD and giving xlink:role the fixed value "MOVIE_REVIEW[EN]" in <MOVIE_REVIEW> elements:

 <!ELEMENT MOVIE_REVIEW (#PCDATA)>  <!ATTLIST MOVIE_REVIEW     xmlns:xlink CDATA  #FIXED "http://www.w3.org/1999/xlink"     xlink:type  CDATA  #FIXED "simple"     xlink:href  CDATA  #REQUIRED     xlink:title CDATA  #IMPLIED     xlink:role  CDATA  #FIXED "MOVIE_REVIEW[EN]" > 


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