Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2003 Pearson Education, Inc. Slide 6-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.

Similar presentations


Presentation on theme: "Copyright © 2003 Pearson Education, Inc. Slide 6-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide."— Presentation transcript:

1

2 Copyright © 2003 Pearson Education, Inc. Slide 6-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide to XML by Cheryl M. Hughes

3 Copyright © 2003 Pearson Education, Inc. Slide 6-2 CHAPTER 5 Links in XML

4 Copyright © 2003 Pearson Education, Inc. Slide 6-3 Overview of Hyperlinks A hyperlink in a web page is an object that a user can click on that will redirect the browser to another web page, file or position within the page Hyperlinks in HTML make the web interactive Links in XML are similar in syntax to links in the HTML language XML Linking Language (XLink) is the XML specification for linking The resource being linked to is called the target resource

5 Copyright © 2003 Pearson Education, Inc. Slide 6-4 Linking in HTML The anchor element Require the user to take an action – usually by clicking on the link, which can consist of images or text The target of the link can be an absolute or relative URL The element Does not require user intervention – resource loads automatically when page loads. Usually used for graphics in HTML

6 Copyright © 2003 Pearson Education, Inc. Slide 6-5 HTML Link Example: HTML file 1 2 3 Link Examples in HTML 4 5 6 Here are some examples of links in HTML: 7 8 This is an absolute link to a new page 9 10 11 This is a relative link to a new page 12 13 14 <img src=button.gif alt=This image is a clickable button> 15 16 17 This is link that launches an email message 18 19 20

7 Copyright © 2003 Pearson Education, Inc. Slide 6-6 HTML Link Example: Browser

8 Copyright © 2003 Pearson Education, Inc. Slide 6-7 HTML Link Limitations Can only point to one target resource Links are unidirectional – once the link is followed, there is no path back to the original document Only certain HTML elements can be used for providing linking functionality

9 Copyright © 2003 Pearson Education, Inc. Slide 6-8 XLink Overview The XLink specification was released by the W3C in July 2001 Benefits over HTML links: Supports multi-directional links, which allows the target resource to link back to the originating document Can contain multiple destinations Any XML element can be a linking element XML link behavior can be programmed XLink specification defines two types of links Simple links Extended links

10 Copyright © 2003 Pearson Education, Inc. Slide 6-9 Simple XLink Links Syntax is similar to HTML links Simple links are: Unidirectional Can only link to one target resource Can be defined on any XML element Defined as a namespace: http://www.w3c.org/1999/xlink Required attributes: href and type

11 Copyright © 2003 Pearson Education, Inc. Slide 6-10 Simple Links: Attributes type : Determines the type of link – for simple, the value is always simple href : Defines the URL of the target resource show : Defines the behavior of the link after it is activated actuate : Defines when the link will be activated role : Describes the resource being linked to title : Used to describe the link arcrole : Describes the relationship between the source and target documents

12 Copyright © 2003 Pearson Education, Inc. Slide 6-11 Simple XLink Example 1 2<map 3xmlns:xlink=http://www.w3.org/1999/xlink 4xlink:type=simple 5xlink:href=mapimage.gif 6xlink:actuate=onRequest 7xlink:show=replace 8xlink:role=image 9xlink:title=A map image> 10Link to Map image 11

13 Copyright © 2003 Pearson Education, Inc. Slide 6-12 Simple XLink Example with DTD 1 2<!DOCTYPE map [ 3 4<!ATTLIST map 5xmlns:xlinkCDATA#FIXED http://www.w3.org/1999/xlink 6xlink:typeCDATA#FIXED simple 7xlink:hrefCDATA#REQUIRED> 8]> 9 Link to Map image Attributes that are defined as #FIXED in the DTD do not have to be included in the XLink element

14 Copyright © 2003 Pearson Education, Inc. Slide 6-13 XLink Extended Links Extended links provide much greater functionality than simple links Extended links: Can link to multiple target resources Are multi-direction Extended links can be any of the following types: extended, resource, locator, arc or title

15 Copyright © 2003 Pearson Education, Inc. Slide 6-14 Extended XLink Example 1<courses xmlns:xlink=http://www.w3.org/1999/xlink 2 xlink:type=extended> 3<locator xlink:type=locator 4 xlink:href=courses/xml101.xml 5 xlink:title=XML 101/> 6<locator xlink:type=locator 7 xlink:href=courses/advxml.xml 8 xlink:title=Advanced XML/> 9<locator xlink:type=locator 10 xlink:href=courses/bw.xml 11 xlink:title=Basket Weaving/> 12Link to Course 13

16 Copyright © 2003 Pearson Education, Inc. Slide 6-15 Extended XLink Example with DTD 1 2<!DOCTYPE map [ 3 4<!ATTLIST courses 5xmlns:xlinkCDATA#FIXED http://www.w3.org/1999/xlink 6xlink:typeCDATA#FIXED extended> 7 8<!ATTLIST locator 9xlink:hrefCDATA#REQUIRED 10xlink:titleCDATA#IMPLIED> 11]> 12<courses xmlns:xlink=http://www.w3.org/1999/xlink 13 xlink:type=extended> 14<locator xlink:type=locator 15 xlink:href=courses/xml101.xml 16 xlink:title=XML 101/> 17<locator xlink:type=locator 18 xlink:href=courses/advxml.xml 19 xlink:title=Advanced XML/> 20<locator xlink:type=locator 21 xlink:href=courses/bw.xml 22 xlink:title=Basket Weaving/> 23


Download ppt "Copyright © 2003 Pearson Education, Inc. Slide 6-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide."

Similar presentations


Ads by Google