Presentation is loading. Please wait.

Presentation is loading. Please wait.

 2002 Prentice Hall, Inc. All rights reserved. 1 XLink and XPointer Outline 1Introduction 2XML Linking Language (XLink) 2.1 Simple Links 2.2 Extended.

Similar presentations


Presentation on theme: " 2002 Prentice Hall, Inc. All rights reserved. 1 XLink and XPointer Outline 1Introduction 2XML Linking Language (XLink) 2.1 Simple Links 2.2 Extended."— Presentation transcript:

1  2002 Prentice Hall, Inc. All rights reserved. 1 XLink and XPointer Outline 1Introduction 2XML Linking Language (XLink) 2.1 Simple Links 2.2 Extended Links 3XLink and DTDs 4XML Pointer Language (XPointer) 5 XInclude 6 XBase

2  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

3  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

4  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

5  2002 Prentice Hall, Inc. All rights reserved. 5 Fig. 1 Illustrating a simple link.

6  2002 Prentice Hall, Inc. All rights reserved. 6 An Sample DTD of [Simple] Element <!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

7  2002 Prentice Hall, Inc. All rights reserved. Outline 7 Fig. 2 XML document with a simple link. Lines 18-25 1 2 3 4 5 6 7 8Deitel & Associates, Inc. is an internationally recognized 9corporate training and content creation organization specializing 10in programming languages, Internet/World Wide Web technology and 11object technology education. Deitel & Associates, Inc. is a 12member of the World Wide Web Consortium. The company provides 13elementary through advanced courses on Java, C++, Visual Basic, 14C, Perl, Python, XML, Internet and World Wide Web programming, 15e-business and e-commerce programming and Object Technology. 16The principals of Deitel & Associates, Inc. are 17 18 <contact 19 xlink:type = "simple" 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 26 Create simple XLink link in element contact with about.xml as remote resource

8  2002 Prentice Hall, Inc. All rights reserved. Outline 8 Fig.2 XML document with a simple link (Part 2). 27 and Paul J. Deitel. The company&apos;s clients include many of 28 the world&apos;s largest computer companies, government agencies, 29 branches of the military and business organizations. Through its 30 publishing partnership with Prentice Hall, Deitel & Associates, 31 Inc. publishes leading-edge programming textbooks, professional 32 books, interactive CD-ROM-based multimedia Cyber Classrooms, 33 satellite courses and Web-based training courses. 34

9  2002 Prentice Hall, Inc. All rights reserved. 9 Output from Fig. 2

10  2002 Prentice Hall, Inc. All rights reserved. 10 Output from Fig. 2

11  2002 Prentice Hall, Inc. All rights reserved. Outline 11 Fig. 3 Listing for about.xml. 1 2 3 4 5 6 7Dr. Harvey M. Deitel, CEO of Deitel & Associates, Inc., has 840 years experience in the computing field including extensive 9industry and academic experience. He is one of the world&apos;s 10leading computer science instructors and seminar presenters. 11Dr. Deitel earned B.S. and M.S. degrees from the Massachusetts 12Institute of Technology and a Ph.D. from Boston University. 13He worked on the pioneering virtual memory operating systems 14projects at IBM and MIT that developed techniques widely 15implemented today in systems like UNIX, Linux and Windows NT. 16He has 20 years of college teaching experience including earning 17tenure and serving as the Chairman of the Computer Science 18Department at Boston College before founding Deitel & 19Associates, Inc. with Paul J. Deitel. He is author or co-author 20of several dozen books and multimedia packages and is currently 21writing many more. With translations published in Japanese, 22Russian, Spanish, Elementary Chinese, Advanced Chinese, Korean, 23French, Polish, Portuguese and Italian, Dr. Deitel&apos;s texts have 24earned international recognition. Dr. Deitel has delivered 25professional seminars internationally to major corporations, 26government organizations and various branches of the military. 27

12  2002 Prentice Hall, Inc. All rights reserved. Outline 12 Fig. 4 Attributes show and actuate. Lines 8-17 Line 13 Line 14 1 2 3 4 5 6 7 8 <contact 9 xlink:type = "simple" 10 xlink:href = "about.xml" 11 xlink:role = "http://www.deitel.com/xlink/contact" 12 xlink:title = "About Harvey Deitel" 13 xlink:show = "new" 14 xlink:actuate = "onRequest"> 15 16 Dr. Harvey Deitel 17 18 19 Create simple XLink link in element contact with about.xml as remote resource Attribute show specifies how to display resources Attribute actuate specifies when resources should be retrieved

13  2002 Prentice Hall, Inc. All rights reserved. 13 Output from Fig. 4

14  2002 Prentice Hall, Inc. All rights reserved. 14 Output from Fig. 4

15  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

16  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 … http://www.... 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

17  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

18  2002 Prentice Hall, Inc. All rights reserved. 18 Two unidirectional links and Multidirectional links

19  2002 Prentice Hall, Inc. All rights reserved. 19 A Sample DTD of [extended] Element <!ATTLIST extended xmlns:xlink CDATA #FIXED “http://www.w3.org/1999/xlink”“http://www.w3.org/1999/xlink xlink:type CDATA #FIXED “extended” xkink:role CDATA #IMPLIED Xlink:title CDATA #IMPLIED

20  2002 Prentice Hall, Inc. All rights reserved. 20 A Sample DTD of [resource] Element <!ATTLIST resource xlink:type CDATA #FIXED “resource” xkink:role CDATA #IMPLIED xlink:title CDATA #IMPLIED xlink:label NMTOKEN #IMPLIED

21  2002 Prentice Hall, Inc. All rights reserved. 21 A Sample DTD of [title] Element <!ATTLIST title xlink:type CDATA #FIXED “title” xml:lang CDATA #IMPLIED

22  2002 Prentice Hall, Inc. All rights reserved. 22 A Sample DTD of [locator] Element <!ATTLIST locator xlink:type CDATA #FIXED “locator” Xlink:href CDATA #REQUIRED xkink:role CDATA #IMPLIED xlink:title CDATA #IMPLIED xlink:label NMTOKEN #IMPLIED

23  2002 Prentice Hall, Inc. All rights reserved. 23 A Sample DTD of [arc] Element <!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

24  2002 Prentice Hall, Inc. All rights reserved. Outline 24 Fig. 8 XML document containing extended links. Lines 10-19 Lines 21-25 Lines 27-31 1 2 3 4 5 6<books xmlns:xlink = "http://www.w3.org/1999/xlink" 7 xlink:type = "extended" 8 xlink:title = "Book Inventory"> 9 10 <author xlink:label = "authorDeitel" 11 xlink:type = "locator" 12 xlink:href = "#authors" 13 xlink:role = "http://deitel.com/xlink/author" 14 xlink:title = "Deitel & Associates, Inc."> 15 16 Deitel, Harvey 17 Deitel, Paul 18 19 20 21 <publisher xlink:label = "publisherPrenticeHall" 22 xlink:type = "locator" 23 xlink:href = "/publisher/prenticehall.xml" 24 xlink:role = "http://deitel.com/xlink/publisher" 25 xlink:title = "Prentice Hall"/> 26 27 <warehouse xlink:label = "warehouseXYZ" 28 xlink:type = "locator" 29 xlink:href = "/warehouse/xyz.xml" 30 xlink:role = "http://deitel.com/xlink/warehouse" 31 xlink:title = "X.Y.Z. Books"/> Mark up link to book’s authorsMark up link to publisherMark up link to warehouse

25  2002 Prentice Hall, Inc. All rights reserved. Outline 25 Fig. 8 XML document containing extended links (Part 2). Lines 33-38 Lines 40-46 Lines 48-54 Lines 56-62 32 33 <book xlink:label = "JavaBook" 34 xlink:type = "resource" 35 xlink:role = "http://deitel.com/xlink/author" 36 xlink:title = "Textbook on Java"> 37 Java How to Program: Third edition 38 39 40 <arcElement xlink:type = "arc" 41 xlink:from = "JavaBook" 42 xlink:arcrole = "http://deitel.com/xlink/info" 43 xlink:to = "authorDeitel" 44 xlink:show = "new" 45 xlink:actuate = "onRequest" 46 xlink:title = "About the author"/> 47 48 <arcElement xlink:type = "arc" 49 xlink:from = "JavaBook" 50 xlink:arcrole = "http://deitel.com/xlink/info" 51 xlink:to = "publisherPrenticeHall" 52 xlink:show = "new" 53 xlink:actuate = "onRequest" 54 xlink:title = "About the publisher"/> 55 56 <arcElement xlink:type = "arc" 57 xlink:from = "warehouseXYZ" 58 xlink:arcrole = "http://deitel.com/xlink/info" 59 xlink:to = "JavaBook" 60 xlink:show = "new" 61 xlink:actuate = "onRequest" 62 xlink:title = "Information about this book"/> 63 Create local resource JavaBook, which links to (or from) an author or publisher Create outbound arc that links to arcrole when user requests it Create outbound arc between book local resource and publisher local resource Create inbound arc that has starting remote reference ( warehouseXYZ ) and ending local resource ( JavaBook )

26  2002 Prentice Hall, Inc. All rights reserved. Outline 26 Fig. 8 XML document containing extended links (Part 3). Lines 64-70 64 <arcElement xlink:type = "arc"65 xlink:from = "publisherPrenticeHall" 66 xlink:arcrole = "http://deitel.com/xlink/stock" 67 xlink:to = "warehouseXYZ" 68 xlink:show = "embed" 69 xlink:actuate = "onLoad" 70 xlink:title = "Publisher&apos;s inventory"/> 71 72 Create third-party arc that has both starting and ending remote references ( publisherPrenticeHall and warehouseXYZ )

27  2002 Prentice Hall, Inc. All rights reserved. 27 Fig. 9 XLink tree browser rendering of booklinks.xml ©Fujitsu Laboratories Ltd.

28  2002 Prentice Hall, Inc. All rights reserved. 28 Fig. 10 Traversing an outbound link. ©Fujitsu Laboratories Ltd.

29  2002 Prentice Hall, Inc. All rights reserved. 29 Fig. 11 Traversing an outbound link. ©Fujitsu Laboratories Ltd.

30  2002 Prentice Hall, Inc. All rights reserved. 30 Fig. 12 Ending resource shown in a new window. ©Fujitsu Laboratories Ltd.

31  2002 Prentice Hall, Inc. All rights reserved. 31 Types of Extended Links locator –Specifies a remote resource resource –Specifies a local resource arc –Outbound arc using attributes from (local) and to (remote) –Inbound arc (starting resource remote and ending resource local) –Third-party arc (both starting and ending resources are remote)

32  2002 Prentice Hall, Inc. All rights reserved. 32 3 XLink and DTDs DTDs are often used with documents that use XLink for: –Validation –Reduce the number of XLink attributes in XML document <car xmlns:xlink = "http://www.w3.org/1999/xlink" xlink:type = "simple" xlink:role = "MT4606" xlink:title = "The Latest Model"> –Provide default values in DTD, and rewrite as:

33  2002 Prentice Hall, Inc. All rights reserved. Outline 33 Fig. 13 DTD for extended XLink example. Lines 4-9 Line 7 Lines 11-16 Line 13 Lines 18-24 Line 20 Lines 26-32 Line 28 1 2 3 4 5<!ATTLIST books 6 xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink" 7 xlink:type (extended) #FIXED "extended" 8 xlink:role CDATA #IMPLIED 9 xlink:title CDATA #IMPLIED> 10 11 12<!ATTLIST book 13 xlink:type (resource) #FIXED "resource" 14 xlink:role CDATA #FIXED "http://deitel.com/xlink/book" 15 xlink:title CDATA #IMPLIED 16 xlink:label NMTOKEN #IMPLIED> 17 18 19<!ATTLIST author 20 xlink:type (locator) #FIXED "locator" 21 xlink:href CDATA #REQUIRED 22 xlink:role CDATA #FIXED "http://deitel.com/xlink/author" 23 xlink:title CDATA #IMPLIED 24 xlink:label NMTOKEN #IMPLIED> 25 26 27<!ATTLIST publisher 28 xlink:type (locator) #FIXED "locator" 29 xlink:href CDATA #REQUIRED 30 xlink:role CDATA #FIXED "http://deitel.com/xlink/publisher" Define element books and its attributes Define element book and its attributes Specify extended link Specify local resource Define element author and its attributes Specify remote resource Define element publisher and its attributes Specify remote resource

34  2002 Prentice Hall, Inc. All rights reserved. Outline 34 Fig. 13 DTD for extended XLink example (Part 2). Lines 34-40 Line 36 Lines 42-50 31 xlink:title CDATA #IMPLIED 32 xlink:label NMTOKEN #IMPLIED> 33 34 35<!ATTLIST warehouse 36 xlink:type (locator) #FIXED "locator" 37 xlink:href CDATA #REQUIRED 38 xlink:role CDATA #FIXED "http://deitel.com/xlink/warehouse" 39 xlink:title CDATA #IMPLIED 40 xlink:label NMTOKEN #IMPLIED> 41 42 43<!ATTLIST arcElement 44 xlink:type (arc) #FIXED "arc" 45 xlink:arcrole CDATA #IMPLIED 46 xlink:title CDATA #IMPLIED 47 xlink:from NMTOKEN #IMPLIED 48 xlink:to NMTOKEN #IMPLIED 49 xlink:show (new | replace | embed | undefined) #IMPLIED 50 xlink:actuate (onLoad | onRequest | undefined) #IMPLIED> 51 52 53 54 55 Define element warehouse and its attributes Specify remote resource Define element arcElement and its attributes for specifying traversal information

35  2002 Prentice Hall, Inc. All rights reserved. 35 4 XML Pointer Language (XPointer) XPointer –References fragments of XML document via a URI Link to specific part of resource, instead of linking to entire resource Link to specific locations (i.e., XPath tree nodes) Link to ranges of locations –Uses XPath to reference XML document nodes –Also used for searching XML documents via string matching

36  2002 Prentice Hall, Inc. All rights reserved. Outline 36 Fig. 14 Example contact list. Lines 5-9 1 2 3 4 5 6 Deitel, Harvey 7 Deitel, Paul 8 Nieto, Tem 9 Mark up contact list that contains ids for three authors

37  2002 Prentice Hall, Inc. All rights reserved. 37 XPointer (cont.) In Figure 14 –Assume contact list has relative URI /contacts.xml XLink references entire contact list with URI xlink:href = "/contacts.xml" XPointer references specific part: –Element contact with id of author02 xlink:href = "/contacts.xml#xpointer( //contact[@id = ‘author02]’)" The name xpointer, called a scheme, expresses the full XPoint form. By using unique attribute id, the expression can be simplified by: xlink:href = "/contacts.xml#xpointer(id = ‘author02’)" which can be further simplified by xlink:href = "/contacts.xml#author02"

38  2002 Prentice Hall, Inc. All rights reserved. 38 XPointer is used in 4 MIME-Type: text/xml application/xml text/xml-external-parsed-entity application/xml-external-parsed-entity

39  2002 Prentice Hall, Inc. All rights reserved. 39 XPointer and XLink XLink and XPointer –XLink links to a designated XML document –XPointer links to internal node or range –XPointer can’t point to different XML document As an example xlink:type=“simple” xlink:href=“../chapter15/15-1.xml #xpointer(/purchaseOrder/customer/person[2])” xlink:title=… Point to the second person element of customer

40  2002 Prentice Hall, Inc. All rights reserved. 40 XPointer and XPath XPointer as an extension of XPath –Node location ( 節點 ) –Point location ( 點 ) –Range location ( 範圍 ) Location set xpointer(/AAA/BBB[1]) xpointer(//BBB/DDD[2]) string-range(loc,string,index,length) e.g. xpointer( string-range(//*,’element’,2,4) ) start-point(location-set) e.g. xpointer(start-point(string-range(//*,’element’,1,1)[1]))

41  2002 Prentice Hall, Inc. All rights reserved. 41 Range and Point in XPointer string-range() start-point() end-point() range-to() range() For example, 1. xpointer(start-point(string-range(//*.’element’,1,1)[1]) 2. xpointer(start-point(string-range(//*,’third’))) 3. xpointer(start-point(/)) 4. xpointer(start-point(//AAA)) Then, change “start” to “end”, point the location in the example XML file.

42  2002 Prentice Hall, Inc. All rights reserved. 42 Sample XML Document first element BBB. second element BBB. element CCC.

43  2002 Prentice Hall, Inc. All rights reserved. 43 5 XML Inclusions (XInclude) XInclude –Reuse XML documents –Include XML documents within others –Use xinclude element

44  2002 Prentice Hall, Inc. All rights reserved. 44 6 XML Base (XBase) XBase –Provide base URIs for relative links Similar to HTML element base Uses attribute xml:base to provide the base URI http://deitel.net/ for attribute href. The complete URI reference by href is: http://deitel.net/ http://deitel.net/authors/author01biography.xml


Download ppt " 2002 Prentice Hall, Inc. All rights reserved. 1 XLink and XPointer Outline 1Introduction 2XML Linking Language (XLink) 2.1 Simple Links 2.2 Extended."

Similar presentations


Ads by Google