Presentation is loading. Please wait.

Presentation is loading. Please wait.

XLink & XPointer ShengWu. Contents Covered XLink –XLink Versus HTML links –Linking Elements –Simple Links –Link Behavior –Extended Links.

Similar presentations


Presentation on theme: "XLink & XPointer ShengWu. Contents Covered XLink –XLink Versus HTML links –Linking Elements –Simple Links –Link Behavior –Extended Links."— Presentation transcript:

1 XLink & XPointer ShengWu

2 Contents Covered XLink –XLink Versus HTML links –Linking Elements –Simple Links –Link Behavior –Extended Links

3 Contents Covered (Continued) XPointer –Why use Xpointer –Xpointers in links –Bare Names –Child Squences –Points –Ranges

4 XLinks Versus HTML Links What HTML links can do HTML made web possible to embed hypertext links in documents. These links could insert images or let the user to jump from inside one document to another document or another part of the same document.

5 (Continued) Limitations of HTML links a. URLs are limited to pointing at a single document. More granularity than that, such as linking to the third sentence of the 17 th paragraph in a document, requires you to manually insert named anchors in the targeted file. It can’t be done without write access to the document to which you are linking.

6 (continued) b. Furthermore, HTML links don’t maintain any sense of history or relations between documents. Links are purely one way. The linking document knows to whom it’s linking, but not vice versa.

7 (continued) What XLink can do Xlink is a proposal for more powerful links between documents. Xlink achieves everything possible with HTML’s URL-based hyperlinks and anchors. Beyond this, it supports multidirectional links where the links run in more than one direction. Any element can become a link, not just the a element.

8 (continued) Links do not even have to be stored in the same file as the documents they link. Furthermore, Xpointers allow links to point to arbitrary positions in an XML document. These features make XLinks more suitable.

9 (continued) Browser Support Netscape and Internet Explorer 5.5 and earlier have no support for any kind of Xlink. Although a few research projects use Xlinks, there are no general-purpose applications that support arbitrary Xlinks.

10 Linking Elements What is a linking element? In HTML, a link is defined with the tag. However, just as XML is more flexible with tags that describe elements, it is more flexible with tags that refer to external resources. In XML, any element can be a link. Elements that include links are called linking elements. Linking elements are identified by an xlink:type attribute.

11 Linking Element (Continued) xlink:type attribute values –simple –extended –locator – arc – resource – title

12 Linking Element (Continued) Xlink namespace –The xlink prefix must be bound to the http://www.w3.org/1999/xlink namespace URI. http://www.w3.org/1999/xlink – The xlink prefix is customary and should be used unless you have got a really good reason to change it.

13 Linking Element (Continued) Examples: a. <composer xmlns:xlink=“ http://www.w3.org/1999/xlink”http://www.w3.org/1999/xlink xlink:type=“simple” xlink:href=“ http://www.users.net/~beand/”>http://www.users.net/~beand/ Beth Anderson

14 Linking Elements (Continued) b. <footnote xmlns:xlink=“ http://www.w3.org/1999/xlink”http://www.w3.org/1999/xlink xlink:type=“simple” xlink:href=“footnote7.xml” > 7 c. <image xmlns:xlink=“ http://www.w3.org/1999/xlink”http://www.w3.org/1999/xlink xlink:type=“simple” xlink:href=“logo.gif” xlink:actuate=“onLoad” xlink:show=“embed” /> Note: the elements have semantic names that describe the content they contain rather than how the elements behave.

15 Simple Link Definition: A simple Xlink is encoded in an XML document as an element of arbitrary type that has an xlink:type attribute with the value simple and an xlink:href attribute. The attribute’s value is the link target’s URI. How simple link works? A simple link defines a one-way connection between two resources. The source, the connection’s starting resource, is itself the link element. The target or ending resource of the connection is identified by a URI. The URI may be something other than a URL. Simple links are the only links that are similar to HTML links.

16 Simple Link (continued) Example <novel xmlns:xlink=“ http://www.w3.org/1999/xlink” xlink:type=“simple” xlink:href=“urn:isbn:0688069444”> The Wonderful Wizard of Oz L. Frank Baum 1900

17 Link Behavior Some discussions How is the connection described by XLink presented to the end user or what dose it make software reading the document do? They don’t have just one answer. For instance, when the browser encounters a novel element that uses an http URI, clicking the link should probably load the text of the novel from the URL into the current window, thereby replacing the document that contained the link.

18 Link Behavior (Continued) Then again, maybe it should open a new window and show the user the new document in that window. The proper behavior for a browser encountering the novel element that uses an isbn URN is even less clear. Perhaps it should reserve the book with the specified ISBN at the local library. Or perhaps it should order the book from an online bookstore.

19 Link Behavior (Continued) Page authors can offer suggestions to browsers about how links should be handled by using the xlink:show and xlink:actuate attributes. Xlink:show –The xlink:show tells the browser or other application what to do when the link is activated. –It has five possible values: New: opens a new window and shows the content at the link’s URI (the ending resources) in that window.

20 Link Behavior (Continued) Replace: Shows the ending resource in the current window, replacing the current document Embed: Embeds the ending resources in the current document at the location of the link element. Other: Do something other than what new, replace, embed do. None: Specifies no behavior.

21 Link Behavior (Continued) Xlink:actuate –The xlink:actuate attribute tells the browser when to show the content. –The optional xlink:actuate has four possible value OnLoad: The link should be followed as soon as the application sees it. OnRequest: The link should be followed when the user asks to follow it. Other: Other markup in the document, not specified by xlink, determines when to follow the link. None: No details are available.

22 Link Behavior (Continued) Example <novel xlink:type=“simple” xlink:href=“ ftp://archive.org/pub/etext93/wizoz10.txt ” xlink:actuate=“onRequest” xlink:show=“replace”> The Wonderful Wizard of Oz L. Frank Baum This code says to wait for an explicit user request to follow the link and then replace the existing document with the document found at ftp://archive.org/pub/wizoz10.txt.

23 Link Semantics Xlink elements can have xlink:title and xlink:role attributes to specify the meaning the connection between the resources Xlink:title this attribute contains a small amount of plain text describing the remote resources. Xlink:role this attribute contains a URI pointing to a longer description of the remote resource.

24 Link Semantics (Continued) Example <novel xlink:type=“simple” xlink:href=“ ftp://archive.org/pub/etext93/wizoz10.txt ” xlink:title=“The complete text of the novel from project gutenberg” xlink:role=“ http://promo.net/pg/”>http://promo.net/pg/ The Wonderful Wizard of Oz L. Frank Baum

25 Extended Links Definition: An extended link describes a collection of resources and paths between those resources. Each path connects exactly tow resources. Any individual resource may be connected to another resource, two other resources, no resources, all other resources, or any subset of other resources in the collection. It may even connect back to itself. An extended link is a directed, labeled graph in which the paths are arcs, the documents are vertices, and the labels are URIs.

26 Extended Links (Continued) Simple links are easy to understand by analogy to HTML links. However, no obvious analogy exists for extended links. What the links look like, how applications treat them, and what user interfaces present them to people is all undecided.

27 Extended Links (Continued) Extended elements: in XML, an extended link is represented by an extended link element, an element of arbitrary type that has an xlink:type attribute with the value extended.

28 Extended Links (Continued) Most extended links contain local resources, remote resource, and arcs between those resources. A remote resource is represented by a locator element, which is any type of element that has an xlink:type attribute with the value locator. A local resource is represented by a resource element, any type of element that has an xlink:type attribute with resource. An arc element, any type of element that has an xlink:type attribute with the value arc, represents a connection between two resources.

29 Extended Links (Continued) Locator element –Each locator element has an xlink:type attribute with the value locator and an xlink:href attribute containing a URI for the resource it locates. –Usually each locator element also has an xlink:label attribute that serves as the element’s ID.

30 Extended Links (Continued) Example of locator element The Wonderful Wizard of Oz L. Frank Baum <edition xlink:type=“locator” xlink:href=“urn:isbn:06880694444” xlink:label=“ISBN06880694444”/> <edition xlink:type=“locator” xlink:href= “urn:isbn:0192839306” xlink:label=“ISBN0192839306”/>

31 Extended Links (Continued) Arc element –Paths between resources are called arcs. Arcs are represented by arc element. –Each arc element should have an xlink:from and an xlink:to attribute. Xlink:from identifies the link’s source and xlink:to identifies the link’s target. –Both xlink:from and xlink:to do not contain URIs, they contain a name matching the value of the xlink:label attribute of one of the locator elements in the extended links.

32 Extended links (Continued) Example (Mutiple arcs from one arc element) L. Frank Baum The Wonderful Wizard of Oz <edition xlink:type=“locator” xlink:href=“urn:isbn:99999” xlink:title=“Oxford University Press” xlink:role=“ http:// www.oup-usa.org/”www.oup-usa.org/ xlink:lable=“ISBN99999” />

33 Extended Links (Continued) <store xlink:type=“locator” xlink:href=“ http://www.amazon.com/….” xlink:label=“buy”>Amazon <store xlink:type=“locator” xlink:href=“ http://www.bookpool.com/…”http://www.bookpool.com xlink:label=“buy”>Bookpool <store xlink:type=“locator” xlink:href=“ http://www.ecampus.com/…” xlink:label=“buy”>Ecampus

34 Extended Links (Continued) <purchase xlink:type=“arc” xlink:from=“ISBN99999” xlink:to=“buy” />

35 Extended Links (Continued) Local resources Extended links can also contain local resources, in which the extended link element contains the data. A resource element represents each such resource. This is an element of arbitrary type that has an xlink:type with the value resource. The function of a resource element is similar to a locator element. But the locator elements represent remote resources.

36 Extended Links (Continued) Title Elements –Xlink:title attribute are not always enough for identifying the link. Thus, a title can instead (or in addition) be provided as a title type child element. –Title elements has the value title for their xlink:type attribute.

37 XPointer Xpointers address the individual parts of an XML document. Xpointer syntax builds on the Xpath syntax used by XSLT.

38 Why uses Xpointers Simple scheme HTML used some URLs contain fragment identifiers that identify the particular named anchor inside the document identified by the URL’s path. # separates this anchor from the path. For instance, URL http://java.sun.com/index.html#download asks browser look for a named anchor in the document at http://java.sun.com/index.html with the name download, such as this one http://java.sun.com/index.html#downloadhttp://java.sun.com/index.html It would then scroll the browser window to the position in the document where the anchor with the right name was found. Drawback of this simple scheme: To link to a particular point in the document, you must be able to modify the document to insert a named anchor at the point you’d like to link to.

39 Why uses Xpointer (Continued) Xpointer eliminates the restriction by allowing you to specify where you want to link to using full Xpath expressions as fragment identifier. Furthermore, Xpointer expands on Xpath by providing operations to select particular points in or ranges of an XML document. An Xpointer is simply an Xpath expression, often a location path, enclosed in the parentheses of xpointer(). xpointer(/) xpointer(//first_name),

40 Xpointers in Links Xpointers in URL Example: http://www.ibiblio.org/xml/people.xml#xpointer(//name[positio n()=1http://www.ibiblio.org/xml/people.xml#xpointer(//name[positio n()=1]) This URL points to the first name element in the document at http://www.ibiblio.org/xml/people.xml

41 Xpointers in links (continued) Xpointers in Xlinks Xpointers are more frequently used in Xlinks. The following example points to the first book child of the bookcoll child of the testament root element in the document at the relative URL ot.xml: <link xlink:type=“simple” xlink:href=“ot.xml#xpointer(/testament/bookcoll/book[pos ition()=1])”> Genesis

42 Bare Names A bare name Xpointer is similar to an HTML named anchor; it identifies the element it points at by its name. However, an ID attribute of the element being pointed at, rather than a special a element with a name attribute, supplies this name. To link to an element with a bare name, append the usual fragment separator # to the URL, followed by the ID of the element you are linking to.

43 Child Sequences Many xpointers descend exclusively along the child axis, selecting elements by their position relative to their siblings xpointer(/child::*[position()=1]/child::*[position() =2]/child::*[position()=3]) selects the third child element of the second child element of the document's root element.

44 Child Sequences (Continued) Since this is so common, xpointer allows you to abbreviate this syntax by providing only the numbers of the child elements, separated by forward slashes. This abbreviation is called a child sequence. The previous Xpointer could be rewritten as a child sequence in the more compact form /1/2/3. A child sequence should not be enclosed in xpointer() like a normal Xpath expression. For example, it should be: http://…………#1/2/3

45 Points and Ranges Xpaths, bare names, and child sequences let you point only to entire nodes or sets of nodes. Sometimes you may want to point to something that isn’t a node, such as the third word of the second paragraph. Xpointer adds points and ranges to the Xpath syntax to make this possible.

46 Points If the node contains child nodes, then points exist before and after each of its children. If the node does not contain child nodes, then a point is present before and after each character in the node's string value.

47 Points (Continued) Example Eight points are located directly inside the novel element. * Point0 Point1 * The Wonderful Wizard of Oz * Point2 Point3 * L. Frank Baum * Point4 Point5 * 1990 * Point6 Point7*

48 Points (Continued) 1990 Five points are present inside the text node child of the year element: Point 0 between and 1 Point 1 between 1 and 9 Point 2 between 9 and 0 Point 3 between 0 and 0 Point 4 between 0 and

49 Points (Continued) The Wonderful Wizard of Oz L. Frank Baum 1990 xpointer(//title[position( ) =1]/text ( )/point( ) [position ( )=3]) Initially finds the document’s first title element, then it takes its text node child. Within this text node, it selects the point between the third and fourth character. Apply it to this example, it would point to the space after The.

50 Ranges A range is the span of parsed character data between two points. Ranges are created with four functions that XPointer adds to XPath: –range ( ) –range-inside ( ) –range-to ( ) –string-range ( )

51 Ranges (continued) The range ( ) function takes an Xpath expression that returns a location set as an argument. For each node in this location set, the range ( ) function returns a range that covers that node exactly. Example: Xpointer (range (/novel/*)) when applied to the example we just used, it returns three ranges, one covering each of the novel root element’s three child elements.


Download ppt "XLink & XPointer ShengWu. Contents Covered XLink –XLink Versus HTML links –Linking Elements –Simple Links –Link Behavior –Extended Links."

Similar presentations


Ads by Google