Xlink and Xpointer
Total Page:16
File Type:pdf, Size:1020Kb
1 XLink and XPointer Outline 1 Introduction 2 XML Linking Language (XLink) 2.1 Simple Links 2.2 Extended Links 3 XLink and DTDs 4 XML Pointer Language (XPointer) 5 XInclude 6 XBase 2002 Prentice Hall, Inc. All rights reserved. 2 1 Introduction • XLink – Describing links between resources (e.g., documents) • XPointer – “Pointing” to document contents – “address” nodes, ranges, and points • XInclude – Including existing XML document into another • XBase – Specifies “base” URL for relative URLs • XForms – XML-based form-processing mechanism • SVG (uses XLink) – XML-based graphic rendering 2002 Prentice Hall, Inc. All rights reserved. 3 2 XML Link Language (XLink) • XLink – Links “resources” from XML documents • E.g., link documents, audio, video, database data, etc. – Resources accessed through multiple links – More flexible features than Hyperlinks – Simple links or extended links – HTML, HyTime, and text Encoding Initiative (TEI) are the most influential 2002 Prentice Hall, Inc. All rights reserved. 4 2.1 Simple Links • Simple links – Links one resource to another (similar to HTML Hyperlink), it is an inline link. – Linking elements • Specify linking information <book xlink:type = "simple" xlink:href = "/textbooks/xmlHowToProgram.xml"> • Linking element (book) is local resource • xmlHowToProgram.xml is remote resource – Arc • Markup that specifies how to traverse between resources 2002 Prentice Hall, Inc. All rights reserved. 5 Fig. 1 Illustrating a simple link. document 1 document 2 2002 Prentice Hall, Inc. All rights reserved. 6 An Sample Simple Link DTD <!ELEMENT simple ANY> <!ATTLIST simple xmlns:xlink CDATA #FIXED “http://www.w3.org/1999/xlink” xlink:type CDATA #FIXD “simple” xlink:href CDATA #REQUIRED xlink:role CDATA #IMPLIED xlink:arcrole CDATA #IMPLIED xlink:title CDATA #IMPLIED xlink:show CDATA (new|replace|embed|other|none) #IMPLIED xlink:actuate CDATA (onLoad|onRequest|other|none) #IMPLIED 2002 Prentice Hall, Inc. All rights reserved. 7 1 <?xml version = "1.0"?> Outline 2 3 <!-- Fig. 14.2 : simpleLinks1.xml --> Fig. 2 XML document 4 <!-- XML file that shows simple linking --> with a simple link. 5 6 <contacts xmlns:xlink = "http://www.w3.org/1999/xlink"> Lines 18-25 7 8 Deitel & Associates, Inc. is an internationally recognized 9 corporate training and content creation organization specializing 10 in programming languages, Internet/World Wide Web technology and 11 object technology education. Deitel & Associates, Inc. is a 12 member of the World Wide Web Consortium. The company provides 13 elementary through advanced courses on Java, C++, Visual Basic, 14 C, Perl, Python, XML, Internet and World Wide Web programming, 15 e-business and e-commerce programming and Object Technology. 16 The principals of Deitel & Associates, Inc. are 17 Create simple XLink link in element contact 18 <contact with as remote resource 19 xlink:type = "simple" about.xml 20 xlink:href = "about.xml" 21 xlink:role = "http://www.deitel.com/xlink/contact" 22 xlink:title = "Read about Harvey Deitel"> 23 24 Dr. Harvey Deitel 25 </contact> 26 2002 Prentice Hall, Inc. All rights reserved. 8 27 and Paul J. Deitel. The company's clients include many of Outline 28 the world's largest computer companies, government agencies, 29 branches of the military and business organizations. Through its Fig.2 XML document 30 publishing partnership with Prentice Hall, Deitel & Associates, with a simple link (Part 31 Inc. publishes leading-edge programming textbooks, professional 2). 32 books, interactive CD-ROM-based multimedia Cyber Classrooms, 33 satellite courses and Web-based training courses. 34 </contacts> 2002 Prentice Hall, Inc. All rights reserved. 9 Output from Fig. 2 2002 Prentice Hall, Inc. All rights reserved. 10 Output from Fig. 2 2002 Prentice Hall, Inc. All rights reserved. 11 1 <?xml version = "1.0" ?> Outline 2 3 <!-- Fig. 14.3 : about.xml --> Fig. 3 Listing for 4 <!-- About Harvey Deitel --> . 5 about.xml 6 <about> 7 Dr. Harvey M. Deitel, CEO of Deitel & Associates, Inc., has 8 40 years experience in the computing field including extensive 9 industry and academic experience. He is one of the world's 10 leading computer science instructors and seminar presenters. 11 Dr. Deitel earned B.S. and M.S. degrees from the Massachusetts 12 Institute of Technology and a Ph.D. from Boston University. 13 He worked on the pioneering virtual memory operating systems 14 projects at IBM and MIT that developed techniques widely 15 implemented today in systems like UNIX, Linux and Windows NT. 16 He has 20 years of college teaching experience including earning 17 tenure and serving as the Chairman of the Computer Science 18 Department at Boston College before founding Deitel & 19 Associates, Inc. with Paul J. Deitel. He is author or co-author 20 of several dozen books and multimedia packages and is currently 21 writing many more. With translations published in Japanese, 22 Russian, Spanish, Elementary Chinese, Advanced Chinese, Korean, 23 French, Polish, Portuguese and Italian, Dr. Deitel's texts have 24 earned international recognition. Dr. Deitel has delivered 25 professional seminars internationally to major corporations, 26 government organizations and various branches of the military. 27 </about> 2002 Prentice Hall, Inc. All rights reserved. 12 1 <?xml version = "1.0"?> Outline 2 3 <!-- Fig. 14.4 : simpleLinks2.xml --> Fig. 4 Attributes show 4 <!-- XML file that shows simple linking --> and . 5 actuate 6 <contacts xmlns:xlink = "http://www.w3.org/1999/xlink"> 7 Create simple XLink linkLines in element 8-17 8 <contact contact with as remote resource 9 xlink:type = "simple" about.xml 10 xlink:href = "about.xml" Line 13 11 xlink:role = "http://www.deitel.com/xlink/contact" Attribute specifies Lineshow 14 12 xlink:title = "About Harvey Deitel" how to display resources 13 xlink:show = "new" 14 xlink:actuate = "onRequest"> Attribute 15 actuate specifies when resources 16 Dr. Harvey Deitel should be retrieved 17 </contact> 18 19 </contacts> 2002 Prentice Hall, Inc. All rights reserved. 13 Output from Fig. 4 2002 Prentice Hall, Inc. All rights reserved. 14 Output from Fig. 4 2002 Prentice Hall, Inc. All rights reserved. 15 Attributes of XLink • Type – simple or extended (locator, resource, arc) • Href – remote resource’s URI • Role – URI that references a resource that describes the link (optional) • Title – descriptive title for the link (optional) • Show – new | replace | embed | undefined • Actuate – onLoad | onRequest | undefined 2002 Prentice Hall, Inc. All rights reserved. 16 Attributes of XLink • Show – how to display a resource when it is loaded new -- the resource displayed in a new window <A HREF=http://www.... target=“_blank”> … </A> replace – replacing the current resource embed – combining the current resource with the linked element other, none (undefined) – allowing XLink-aware application to decide how to display • Actuate – when the resource should be retrieved onLoad – document is retrieved as soon as it is loaded onRequest – doc. should not be retrieved until the user requests it other, none (undefined) – XLink-aware application to decide when to load 2002 Prentice Hall, Inc. All rights reserved. 17 2.2 Extended Links • Extended links – Link multiple combinations of local and remote resources – Multidirectional links • Traverse between resources • Can link any number of resources • Unidirectional links may not offer return to local resource or the remote resource has no knowledge of the local resource • Require multiple elements to accomplish Extended links 2002 Prentice Hall, Inc. All rights reserved. 18 Two unidirectional links and Multidirectional links document 1 document 2 document 1 document 2 document 1 document 2 document 3 document 4 2002 Prentice Hall, Inc. All rights reserved. 19 A Sample DTD of [extended] Element <!ELEMENT extended ((title| resource| locator| arc)*)> <!ATTLIST extended xmlns:xlink CDATA #FIXED “http://www.w3.org/1999/xlink” xlink:type CDATA #FIXED “extended” xkink:role CDATA #IMPLIED Xlink:title CDATA #IMPLIED 2002 Prentice Hall, Inc. All rights reserved. 20 A Sample DTD of [resource] Element <!ELEMENT resource ANY> <!ATTLIST resource xlink:type CDATA #FIXED “resource” xkink:role CDATA #IMPLIED xlink:title CDATA #IMPLIED xlink:label NMTOKEN #IMPLIED 2002 Prentice Hall, Inc. All rights reserved. 21 A Sample DTD of [title] Element <!ELEMENT title ANY> <!ATTLIST title xlink:type CDATA #FIXED “title” xml:lang CDATA #IMPLIED 2002 Prentice Hall, Inc. All rights reserved. 22 A Sample DTD of [locator] Element <!ELEMENT locator (title*)> <!ATTLIST locator xlink:type CDATA #FIXED “locator” Xlink:href CDATA #REQUIRED xkink:role CDATA #IMPLIED xlink:title CDATA #IMPLIED xlink:label NMTOKEN #IMPLIED 2002 Prentice Hall, Inc. All rights reserved. 23 A Sample DTD of [arc] Element <!ELEMENT arc (title*)> <!ATTLIST arc xlink:type CDATA #FIXED “arc” Xlink:arcrole CDATA #REQUIRED xlink:title CDATA #IMPLIED xlink:show (new| replace| embed| undefined) #IMPLIED xlink:actuate (onLoad| onRequest| undefined) #IMPLIED xlink:from NMTOKEN #IMPLIED xlink:to NMTOKEN #IMPLIED 2002 Prentice Hall, Inc. All rights reserved. 24 1 <?xml version = "1.0"?> Outline 2 3 <!-- Fig. 14.8 : booklinks.xml --> 4 <!-- XML document containing extended links --> Fig. 8 XML document 5 containing extended 6 <books xmlns:xlink = "http://www.w3.org/1999/xlink" links. 7 xlink:type = "extended" 8 xlink:title = "Book Inventory"> 9 Lines 10-19 10 <author xlink:label = "authorDeitel" Mark up link to book’s