23
Introducing XLink and XPointer ©NIIT eXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: Identify the types of links in XML documents Identify the need for XPointer for referencing specific sections within an XML document

Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Embed Size (px)

Citation preview

Page 1: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 1 of 23

Objectives

In this lesson, you will learn to:

Identify the types of links in XML documents

Identify the need for XPointer for referencing specific sections within an XML document

Page 2: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 2 of 23

Use of Hyperlinks

A hyperlink or link is an association between a source document and a target document, or between a piece of text and an object, such as an image.

When clicked, hyperlinks enable you to move from one page to another or from one location to another location on the same page.

Page 3: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 3 of 23

Use of Hyperlinks (Contd.)

Hyperlinks in HTML have the following limitations:

Using hyperlinks in HTML, you can point at only a single document.

Links are one way. The linking document knows to what it is linking, but the target document does not know how it is linked.

To overcome these limitations of hyperlinks in HTML, W3C recommends the use of two new types of linking mechanisms in XML. These are called XLink and XPointer.

Page 4: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 4 of 23

Introduction to XLink

XLink stands for XML Linking Language. It is a specification for enhanced and improved linking capabilities that are designed for use with XML documents.

XLink allows XML documents to establish a linking relationship between more than one document and create linking documents that reside in a separate location from the linked documents.

In XML, any element can become a source of a link. An element that contains a link is called a linking element.

Page 5: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 5 of 23

Introduction to Xlink (Contd.)

XLinks are of two types:

Simple links

Extended links

Page 6: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 6 of 23

Simple Links

A simple link is similar to the link created in HTML using the ANCHOR element. It connects an element in a source document to a target document.

Simple links are inline links. An inline link is a part of the element and can connect in one direction.

A simple link can have only one resource identifier or locator that contains data about the link.

Simple links have attributes that suggest how a browser or a processor should display and traverse the link. For example, the xlink:show attribute describes how a browser should display the remote resource.

Page 7: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 7 of 23

Simple Links (Contd.)

Simple links allow you to specify whether the remote resource should be displayed in the same browser window, a new window, or within the current document.

Page 8: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 8 of 23

Extended Links

An extended link can point to several resources at a time. It can be used to create links to other documents from your documents, even though you have no write privileges in the other documents.

Extended links associate an XML element to multiple links.

Page 9: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 9 of 23

Extended Links (Contd.)

Extended links are of two types:

Out-of-line links

A link that is described by a resource but which is not one of the links in the resource is called an out‑of‑line link.

An example is a catalog document that describes all the links in a Web site without actually participating in any of the links.

Page 10: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 10 of 23

Extended Links (Contd.)

Multi-directional links

An extended link may also be a multi-directional link that joins several documents in a single link, which can be traversed from any one of its resources. Extended links enable you to specify multiple links from one source.

For example, you might want to provide multiple links to various topics, such as information about Michelangelo and Leonardo da Vinci from a single category named Artists.

Page 11: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 11 of 23

Behaviour of XLink

XLink uses the following attributes for creating simple or extended links:

href

role

title

show

actuate

type

Page 12: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 12 of 23

Behaviour of Xlink (Contd.)

The href attribute

A linking element must have a resource locator, that is, the resource targeted by the link.

The href attribute of XLink is used to specify the target of the link.

The role attribute

The role attribute is a means of providing applications with additional information about a link.

Applications that use XLink can get the information about the role of a link by referring to the value of the role attribute.

Page 13: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 13 of 23

Behaviour of Xlink (Contd.)

The title attribute

The title attribute allows you to specify a label to provide information to the user.

While the role attribute is meant for the system and the application, the title attribute is meant for providing supplementary information to the user.

Page 14: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 14 of 23

Behaviour of Xlink (Contd.)

The show attribute

The show attribute can take any one of the three values, namely, embed, replace, or new.

The behaviors represented by these values are described in the table below:

Value Behavior

embed If this value is specified, the contents of the linked object will appear embedded within the document from which this link was activated.

replace If this value is specified, the content of the linked object will replace the document from which the link was activated. This is the default behavior of HTML links.

new If this value is specified, the content of the linked object will appear separate from the document from which the link was activated, such as in a new browser window.

Page 15: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 15 of 23

Behaviour of Xlink (Contd.)

The actuate attribute

The actuate attribute allows you to specify the timing of the link.

The actuate attribute can take one of the following predefined values:

Value Behavior

OnRequest This specifies that the link should be traversed only when the user requests it by clicking on the linking element.

OnLoad The link is traversed once the link is loaded. For example, you may set the actuate attribute to OnLoad for an image that is to be embedded in the linking document. The link will be traversed after the image is loaded.

Page 16: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 16 of 23

Behaviour of Xlink (Contd.) The type attribute

The type attribute is used to specify the type of the link that is to be created for an element.

The value of this attribute can be set to simple, extended, resource, locator, or arc.

simple A simple link is similar to an HTML hyperlink. It

connects an element in a source document to a target document.

This means that the link can only be used in one direction, from the source document to the target document.

Page 17: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 17 of 23

Behaviour of Xlink (Contd.) extended

When you set the value of the type attribute to extended, it allows you to create multi-directional links between many documents.

resource XML allows you to create multi-directional links in

which you can have an element that can be both the source as well as the target of a link.

The source and the target have been given the generic name resource.

A resource can be either local or remote. A local resource is contained inside the extended link element.

Page 18: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 18 of 23

Behaviour of Xlink (Contd.)

locator

This link type is used to represent remote resources.

A remote resource exists outside the extended link element.

arc

An arc describes a traversal path between two links.

Page 19: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 19 of 23

Introduction to Xpointer

XPointer, the XML Pointer Language, defines an addressing scheme for the individual parts of an XML document.

It can be used by any application that needs to identify a part or a location of an XML document.

XPointer is a new specification designed to link to portions of a document without having to link to the entire document.

XPointer is a proposal at the W3C that concerns addressing links to specific points within documents.

Page 20: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 20 of 23

Just a Minute…

Which of the following elements cannot be displayed as a link?

Buttons

Text

Menu Items

List Items

Page 21: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 21 of 23

Just a Minute…

Which of the following is a type of extended link?

In-line link

Straight-line link

Out-of-line link

One-line link

Page 22: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 22 of 23

Summary

In this lesson, you learned that:

XLink stands for XML Linking Language. It is a specification for enhanced linking capabilities designed for use with XML documents.

XLinks are of two types. These are:

Simple links

Extended links

Page 23: Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types

Introducing XLink and XPointer

©NIIT eXtensible Markup Language/Lesson 10/Slide 23 of 23

Summary (Contd.)

The following attributes can be used to specify the behavior of simple or extended links:

href

role

title

show

actuate

type

XPointer, the XML Pointer Language, defines an addressing scheme for accessing individual parts of an XML document.