170 likes | 311 Views
XLink. The Wonderful World of Oz example and its DTD are from the excellent book “XML in a Nutshell” by Elliotte Rusty Harold (course text). XLink. XLink is a syntax that allows us to represent directed graphs. The vertices of the graph are documents (or other resources)
E N D
XLink The Wonderful World of Oz example and its DTD are from the excellent book “XML in a Nutshell” by Elliotte Rusty Harold (course text) Internet Technologies
XLink XLink is a syntax that allows us to represent directed graphs. The vertices of the graph are documents (or other resources) and the edges are links between them. The vertices can be local or remote. Different applications may interpret the XLinks in a document differently. The programmer determines the meaning of the connection. For example, a web spider will probably treat the link much differently than a web browser or a publishing program. Internet Technologies
XLink • Simple Links • Define a one-way connection between two resources • One resource is an xml element and the other is remote • This is the only link that looks like the html anchor element • Extended Links • Define a collection of resources and links between them • These may be used to define a directed, labeled graph Internet Technologies
Simple Links <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <novel xmlns:xlink= "http://www.w3.org/1999/xlink" xlink:type = "simple" xlink:href = "ftp://archive.org/pub/etext/my.txt"> <title>The Wonderful Wizard of Oz</title> <author>L. Frank Baum </author> <year>1900</year> </novel> Map some prefix to the xlink URI The xlink prefix is customary but not required. Internet Technologies
Simple Links <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <novel xmlns:xlink= "http://www.w3.org/1999/xlink" xlink:type = "simple" xlink:href = "ftp://archive.org/pub/etext/my.txt"> <title>The Wonderful Wizard of Oz</title> <author>L. Frank Baum </author> <year>1900</year> </novel> The type attribute is required. It has six possible values. The simple type is like HTML’s anchor element. Internet Technologies
Simple Links <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <novel xmlns:xlink= "http://www.w3.org/1999/xlink" xlink:type = "simple" xlink:href = "ftp://archive.org/pub/etext/my.txt"> <title>The Wonderful Wizard of Oz</title> <author>L. Frank Baum </author> <year>1900</year> </novel> The href attribute may be relative or absolute and points to the target resource. Internet Technologies
Simple Links <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <novel xmlns:xlink= "http://www.w3.org/1999/xlink" xlink:type = "simple" xlink:href = "ftp://archive.org/pub/etext/my.txt" xlink:actuate=“onRequest” xlink:show=“replace”> <title>The Wonderful Wizard of Oz</title> <author>L. Frank Baum </author> <year>1900</year> </novel> Many options exist. These are suggestions to the application. Internet Technologies
Simple Xlinks and DTD’s <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE novel SYSTEM "novel.dtd"> <novel xlink:href = "ftp://archive.org/pub/etext/my.txt"> <title>The Wonderful Wizard of Oz</title> <author>L. Frank Baum </author> <year>1900</year> </novel> Some of the syntax can be placed in a DTD. We must define the attributes, the namespace and the type of link. Internet Technologies
Simple Xlinks (DTD) <?xml version="1.0" encoding="UTF-8"?> <!ELEMENT novel (title, author, year) > <!ATTLIST novel xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink" xlink:type (simple) #FIXED 'simple' xlink:href CDATA #REQUIRED> <!ELEMENT title (#PCDATA) > <!ELEMENT author (#PCDATA) > <!ELEMENT year (#PCDATA) > Internet Technologies
Extended Links • Not like the HTML links of old. • More general. • Application dependent. Internet Technologies
Extended Links • Extended links will normally contain the following: • Local resources involved in the connections. • These have type=“resource” • Remote resources involved in the connections. • These have type=“locator” • Descriptions of the connections. • These have type=“arc” Internet Technologies
Extended Links • Extended links will normally contain the following: • Local resources involved in the connections. • These have type=“resource”. • Give a name to a local element. • Remote resources involved in the connections. • These have type=“locator”. • Give a name to a remote place. • Descriptions of the connections. • These have type=“arc”. • State that a directed edge exists between two of the above. Internet Technologies
Extended Links <program xlink:type=“extended”> </program> <course xlink:type=“resource” xlink:label = “LA100”> Linear Algebra <course> <course xlink:type=“resource” xlink:label = “LA200”> Linear Algebra II <course> <prerequisite xlink:type=“arc” xlink:from=“LA100” xlink:to=“LA200” /> Linking resources that are part of the document. Internet Technologies
Extended Links <program xlink:type=“extended”> </program> <course xlink:type=“locator” xlink:label = “LA100” xlink:href=“http://someplace.else”> Linear Algebra <course> <course xlink:type=“locator” xlink:label = “LA200” xlink:href=“http://anotherplace”> Linear Algebra II <course> <prerequisite xlink:type=“arc” xlink:from=“LA100” xlink:to=“LA200” /> Linking remote resources. Internet Technologies
Third Party Links We can now define links between documents that we don’t control. Using Xlink, we can describe vertices and edges across the internet. If the vertices are XML documents, we can use XPointer (which builds on XPath) to establish links from particular places in remote documents to particular places in other documents, neither of which we control. Makes you think! Internet Technologies