Extended Links

You may be used to the idea of simple links much as they work in HTML and as I've discussed them here, but here's where we broaden things by getting into extended links. Extended links are very general and really indicate relationships between resources. An extended link can involve multiple resources, multiple paths between those resources, bidirectional paths, and " out-of-line " links. It helps to think very generally here, in terms of all the possible relationships you might have between data resources.

The upcoming concepts may seem very vague when compared to the concrete functionality of simple links. Keep in mind that the W3C is trying to let you describe, in XML terms, all the possible relationships that might exist among multiple resources, as well as how those relationships work. It's a big job. In technical terms, an extended link is called a directed labeled graph. The resources it connects are called the vertices, and the actual links between resources are the edges of the graph.

In general terms, then, an extended link is made up of the connections between a set of resources. Such resources may be local, which means they're actually part of the extended link element, or remote, which means they're not part of the extended link element (but does not mean that they have to be in another document). If a link does not contain any local resources at all, it's called an out-of-line link.

So how does an application use an extended link? That's completely up to the application. I'll provide some ideas here, but so far, things are really up in the air. No generally available software packages that I know of implement true extended links.

A hypothetical example might be a so-called expert system, in which the links among multiple resources are traversed depending on "yes" or "no" answers to questions. The idea here is that by answering a series of questions, an expert system can progressively narrow a search and direct you to a resource that will provide the answer to quite complex queries.

As mentioned, resources that participate in an extended link can be either local or remote. A local resource is part of the extended link itself and is contained in an element that has its xlink:type attribute set to "resource" .

On the other hand, remote resources are outside the extended link element, but not necessarily in another document. You use locator elements to point to remote resources, and those elements have their xlink:type attributes set to "locator" . When you create a locator element, you must also give its xlink:href attribute a value that points to the remote resource.

Here's an example of an extended link. This link contains four resources: two inline links and two out-of-line links:

 <ASTRO_DATA xmlns:xlink="http://www.w3.org/1999/xlink"           xlink:type="extended" xlink:title="Planetary Data">     <NAME xlink:type="resource" xlink:role="NAME">         Planetary Data     </NAME>     <DATE xlink:type="resource" xlink:role="LAST_UPDATED">         September 1, 2003     </DATE>     <PLANET_DATA xmlns:xlink = "http://www.w3.org/1999/xlink"         xlink:type = "locator"         xlink:show = "embed"         xlink:href="http://www.starpowdermovies.com/ch15_06.xml#xpointer(/descendant:: graphics/ccc.gif PLANET[position() = 1]">         xlink:title="Mercury"         xlink:role="PLANETARY_DATA"     </PLANET_DATA>     <PLANET_DATA xmlns:xlink = "http://www.w3.org/1999/xlink"         xlink:type = "locator"         xlink:show = "embed"         xlink:href="http://www.starpowdermovies.com/ch15_06.xml#xpointer(/descendant:: graphics/ccc.gif PLANET[position() = 2]">         xlink:title="Venus"         xlink:role="PLANETARY_DATA"     </PLANET_DATA>     <PLANET_DATA xmlns:xlink = "http://www.w3.org/1999/xlink"         xlink:type = "locator"         xlink:show = "embed"         xlink:href="http://www.starpowdermovies.com/ch15_06.xml#xpointer(/descendant:: graphics/ccc.gif PLANET[position() = 3]">         xlink:title="Earth"         xlink:role="PLANETARY_DATA"     </PLANET_DATA> </ASTRO_DATA> 

The inline links here are those links that have the xlink:type value "resource" and whose resources are actually contained in the linking element. In this case, that's the <NAME> and <DATE> links. Both of these contain a local resource, which is simply text here, although it could consist of multiply-nested XML elements, if you prefer.

The out-of-link links here have the xlink:type attribute value "locator" . These links serve to locate remote resources, which may be in the same document or in another document. In this example, the remote resources are all in another document, ch15_06.xml.

As before, if you want to create valid documents, you must declare the attributes and elements you're using. That might look like this, where I'm adding a DTD:

Listing ch15_08.xml
 <?xml version = "1.0"?> <!DOCTYPE ASTRO_DATA  [ <!ELEMENT ASTRO_DATA (NAME, DATE, PLANET_DATA*) > <!ATTLIST ASTRO_DATA     xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink"     xlink:type (extended) #FIXED "extended"     xlink:title CDATA #IMPLIED     xlink:role CDATA #IMPLIED> <!ELEMENT NAME (#PCDATA)> <!ATTLIST NAME     xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink"     xlink:type CDATA #FIXED "resource"     xlink:role CDATA #IMPLIED     xlink:title CDATA #IMPLIED > <!ELEMENT DATE (#PCDATA)> <!ATTLIST DATE     xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink"     xlink:type CDATA #FIXED "resource"     xlink:role CDATA #IMPLIED     xlink:title CDATA #IMPLIED > <!ELEMENT PLANET_DATA (#PCDATA)> <!ATTLIST PLANET_DATA     xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink"     xlink:type CDATA #FIXED "locator"     xlink:href CDATA #REQUIRED     xlink:role CDATA #IMPLIED     xlink:title CDATA #IMPLIED     xlink:show CDATA #IMPLIED > ]> <ASTRO_DATA xmlns:xlink="http://www.w3.org/1999/xlink"          xlink:type="extended" xlink:title="Planetary Data">     <NAME xlink:type="resource" xlink:role="NAME">         Planetary Data     </NAME>     <DATE xlink:type="resource" xlink:role="LAST_UPDATED">         September 1, 2003     </DATE>     <PLANET_DATA xmlns:xlink = "http://www.w3.org/1999/xlink"         xlink:type = "locator"         xlink:show = "embed"         xlink:href="http://www.starpowdermovies.com/ch15_06.xml#xpointer(/descendant:: graphics/ccc.gif PLANET[position() = 1]">         xlink:title="Mercury"         xlink:role="PLANETARY_DATA">     </PLANET_DATA>     <PLANET_DATA xmlns:xlink = "http://www.w3.org/1999/xlink"         xlink:type = "locator"         xlink:show = "embed"         xlink:href="http://www.starpowdermovies.com/ch15_06.xml#xpointer(/descendant:: graphics/ccc.gif PLANET[position() = 2]">         xlink:title="Venus"         xlink:role="PLANETARY_DATA">     </PLANET_DATA>     <PLANET_DATA xmlns:xlink = "http://www.w3.org/1999/xlink"         xlink:type = "locator"         xlink:show = "embed"         xlink:href="http://www.starpowdermovies.com/ch15_06.xml#xpointer(/descendant:: graphics/ccc.gif PLANET[position() = 3]">         xlink:title="Earth"         xlink:role="PLANETARY_DATA">     </PLANET_DATA> </ASTRO_DATA> 

So far, all we've done is indicate whether elements that participate in an extended link represent local or remote resources. You can do more if you use the xlink:from and xlink:to attributesthey allow you to create directed links, or arcs.



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