530 likes | 821 Views
Introduction to XML Linking Language (XLink). Cheng-Chia Chen. XLink, XPointer, XPath, Xinclude and XML Base. XLink :December 20, 2000 Proposed Recommendation a generalization of the HTML link concept higher abstraction level (intended for general XML - not just hypertext)
E N D
Introduction to XML Linking Language (XLink) Cheng-Chia Chen
XLink, XPointer, XPath, Xinclude and XML Base • XLink :December 20, 2000 Proposed Recommendation • a generalization of the HTML link concept • higher abstraction level (intended for general XML - not just hypertext) • more expressive power (multiple destinations, special behaviours, out-of-line links, ...) • uses XPointer to locate resources • XPointer : January 8, 2001 2nd Last Call Working Draft • an extension of XPath suited for linking • specifies connection between XPath expressions and URIs • XPath: November 16, 1999 1.0 Specification • a declarative language for locating nodes and fragments in XML trees • used in both XPointer (for addressing) and XSL (for pattern matching) • XInclude :: October 26, 2000 Working Draft • embeds a document identified by a URI inside an XML document. • XMLBase:December 20, 2000 Proposed Recommendation • defines the URI against which relative URIs are resolved
XML Base • A URI identifies a resource: • http://somewhere/somefile.xml is an absolute URI • somefile.xml is a relative URI • Inspired by the <base href="..."> mechanism in HTML, XML Base provides a uniform way of resolving relative URIs. • In the following example: <... xml:base="http://www.daimi.au.dk/"> <... href="~mis/mn/index.html" .../></...> the value of href attribute can be interpreted as the absolute URI http://www.daimi.au.dk/~mis/mn/index.html. • the xml namespace prefix is hardwired by the Namespace specification • xml:base has lexical scope (as namespace declarations) • the URI used to access the document is used as default URI base • Future XML parsers will support Namespaces, XInclude, and XML Base.
An XInclude example • A document containing: <foo xmlns:xi="http://www.w3.org/2001/XInclude"><xi:include href="somewhere.xml"/></foo> where somewhere.xml contains: <bar>...</bar> is equivalent to: <foo xmlns:xi="http://www.w3.org/2001/XInclude"><bar>...</bar></foo> • http://www.w3.org/2001/XInclude is the official XInclude namespace • the include element name in that namespace is an inclusion directive • right after parsing and before other processing, an XInclude processor performs the inclusion (tree substitution) • the original and the resulting document should be considered equivalent • it is an error to have cyclic includes
source destination link The HTML link model • The HTML link model: <A href=“http://xml.cs.nccu.edu.tw/courses#aia2001”> a hyperlink to the aia2001 anchor of the course URI </A> characteristic: • binary, unidirectional • link definition = link source.
Problems of HTML link model • Link syntax and semantics is not defined separately from rest of HTML: • In HTML, links are recognized by element names (A, IMG, ..) - we want a generic XML solution. - we want link to be defined at places other than A,IMG. • The "semantics" of a link is completely defined in the higher-level specification - we want control of general semantic features, e.g. of link actuation. • HTML links are too simple: • All Links are binary (one source and one destination) - we want links with multiple sources and destinations. • The traversal rule is unidirectional. (dead link problem) - we want multi-directional links possible.
Problems with HTML links (cont’d) 2. • support outbound link(link definition is also the link source) only - We need inbound and third-party links("link databases"). • Links are anonymous • we want human-readablelabels. • An anchor must be placed at every link destination (problem with read-only documents) : • <A name=“aDestination” /> - we want to express relative locations(XPointer!). • Only individual nodes can be linked to - we want links to whole tree fragments.
The XLink linking model • The world wide web is composed of a lot of resources. • Each is identified (URN) or addressed (URL) by a string called its URI (reference). • There are a lot of relationships existing among these resources, which we need to make explicit in order for • applications to make use of them. • Ex: family, • course : Teacher, TAs, • students, newsgroup, • course web pages, • … resource resource resource resource
resource resource Link resource resource XML linking model • U (the universe) =def the collection of all resources. • a relation R (not restricted to binary or fixed arity relation) • is any subset of Uk>0 Uk . • A link asserts(or declares) the existence of a member tuple • (r1,r2,…, rk) of • a relation.
arc remote resource remote resource Link arc arc remote resource local resource XML linking model • Resource which is a link or a child of a link is called the local resource of the link. • other resources are remote resources.
arc remote resource remote resource Link arc arc remote resource local resource XML linking model • traversal: Using or following a link for any purpose. • always binary, from one starting source to one ending resource of an arc. • An arc identify a possible (or allowable) set of traversals.
Information associated with a link • structural information: • participating local/remote sources. • traversal (behavior) information • used arcs • semantic information • title : human readable information about the (meaning of the ) link • role : an URI uniquely identifying the relation the link belongs to. • Ex: http://relations.org/family, • http://relations.org/employee
information associated with a resource • structural information: • location (URI) of the resource • (needed for remote source only) • semantic information: • title : human readable description about the meaning ? of the resource. • Note: it is unclear from the spec that the title information should describe either the set the resource is a member of or the property the resource plays in the link. • role: a RUI reference uniquely identifying the property the resource play in the link. • ex: http://relation.org/family/father • v.s. http://relation.org/person • Auxiliary information: • label: identifying a group the resource belong to.
information associated with an arc • structural information • from : a label identifying all staring resources • to: a label identifying all ending resources • semantic information: • title: human readable information about the meaning of the arc. • arcrole: a URI reference identifying a resource which describe the intended property (meaning or relation) of the arc. • ex: an arc from TA students’ homeworks may have a arcrole value of http://relation.org/courses/grading. • behavior information: • show : what the system should behave when the arc is traversed ? • possibe values: new | replace | embed | none | other • actuate: when should the arc be traversed ? • possible values: onLoad | onRequest | none | other
How Xlink describe links in an XML document • Entities that needed to be represented: link ( simple# / extended#) : • title#!, role!, • resource ( local# / resource# ) • title#!, role!, location!, label! • arc! • title#!, arcrole!, from!, to!, show!, actuate! Notes: • 1. # means represented by element • 2. ! means represented by global attributes • 3. Any element asserting existence of a link in XLink is called an [XLink] linking element. there are 2 link elements • 4. Any elements related to XLink is called a Xlink element. • 5. There are 6 Xlink elements, two linking elements, two for resource, one for title and one for arc.
How Xlink describe links in an XML document • Adopt the XML namespace approach instead of HTML’s approach. • no elements invented simply for the need of Xlink. • (cf. A and IMG in HTML) • Define a set of 10 global attributes under the Xlink namespace with URI: http://www.w3.org/1999/xlink • x:type : simple | extended | locator | resource |title | role • each identify a different kind of xlink elements. • x:href : a URI reference identifying a resource • x:role, x:arcrole : URI reference • x:title : strings (CDATA) • x:show, x:actuate : • x:from, x:to : a label defined in a resource • x:label: NCName
How Xlink describe links in an XML document 3. use the value of the global attribute x:type to identifying an xlink (related) element and its kind. ex: < … xmlns:x = “http://www.w3.org/1999/xlink” … > … <e1 x:type=“extended”…>… </e1> <e2 x:type=“xxx” … > … </e2> Then : • anyElement is an extended-type link, and in general • we call e2 an xxx-type element, where xxx is any possible value of x:type : • simple | extended | locator | resource | title | role Note: 1. e1 and e2 can has its own attributes and contents. 2. Xlink behaves more like interface than class in java in the sense that it can be embeded on all existing elements.
How Xlink related information is represented 4. entity type representation • link • simple link simple-type element • extended linkextended-type element • resource • local resource resource-type element • remote resourcelocator-type element • arc arc-type element • title [link, resource, arc] x:title, title-type element • role [link and resource] x:role • arcrole x:arcrole • starting resources x:from • ending resources x:to • arc target x:label
Notes: • Each information item associated with an entity (i.e., link or resource or arc) is represented either as one of its attributes or as one of its child elements. • Title information can be represented by the attribute x:title and/or by multiple child title-type elements. Ex: <link1x:type=“extended”x:title=“aboutLink1” x:role=“aRUI” > <remoteResource1x:type=“locator” x:title=“AboutRemoteResource1”/> <localResource1 x:type=“resource” …> … </localResource1> <title1x:type=“title” xml:lang=“en”> English description about link1 </title1> <title2x:type=“title” xml:lang=“zh_TW”>Link1 的中文說明 </title2> <title3>This is not a title of link1 since it is not a title-type element</title3> <book> <title4x:type=“simple” x:href=“aURL” x:title=“not a title of link1”/> …</book> … Note:Neither title3 nor x:titleof title4 is a title of link1.
Required and optional attributes in an xlink element R: required O: optional
possible children and attributes of an Xlink Element Note: * :zero or more; ?: zero or one ; otherwise: exactly once.
Basic XLink terminology • Resource: any addressable unit of information or service [RFC2396]. (i.e., have an URI) • Examples: files, images, documents, programs, and query results. • Link: Explicit relationship between two or more resources. • Linking element: An XML element that asserts the existence and describes the characteristics of a link. • A local resource comes from the linking element's own content or is the linking element itself. • Locator: An identification of a remote resource that is participating in the link. - one linking element defines a set of traversable arcs between some resources. • Out-of-line link: link with no local resource. • Inline link: link with local resource.
Example • The XLink namespace : http://www.w3.org/1999/xlink • The use of XLink elements and attributes requires declaration of the XLink namesapce: <myElement xmlns:x="http://www.w3.org/1999/xlink"> ... </myElement>
Example1: a simple link <my:crossReference xmlns:my="http://example.com/" xmlns:x="http://www.w3.org/1999/xlink" x:type="simple" x:href="students.xml" x:role="studentlist" x:title="Student List" x:show="new“ x:actuate="onRequest"> Current List of Students </my:crossReference> Note: Simple link is Xlink’s analog of the A element of HTML. It serves at the same time as a binary link, a remote resource, a local resource (itself) and an outbound arc.
Examle2: an example of crossreference with non XLink attributes <my:crossReference xlink:href="students.xml" xlink:role="studentlist" xlink:title="Student List"> Current List of Students </my:crossReference> <my:crossReference xmlns:my="http://example.com/" my:lastEdited="2000-06-10" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="students.xml"> Current List of Students </my:crossReference>
Example3: an extended-type element and its subelements • The DTDs • <!ELEMENT courseload ((tooltip|person|course|gpa|go)*)> • <!ATTLIST courseload • xmlns:xlink CDATA #FIXED http://www.w3.org/1999/xlink • xlink:type (extended) #FIXED "extended" • xlink:role CDATA #IMPLIED • xlink:title CDATA #IMPLIED> • <!ELEMENT tooltip ANY> • <!ATTLIST tooltip • xlink:type (title) #FIXED "title" • xml:lang CDATA #IMPLIED> Notes: 1. 3 & 4 means courseload is an extended link by default and hence need not specify these attributes explicitly in document instances. 2. Similarly, tooltip is a title-type element.
Example3: (the DTDs continued) • <!ELEMENT person EMPTY> • <!ATTLIST person<!-- a remote resource --> • xlink:type (locator) #FIXED "locator" • xlink:href CDATA #REQUIRED • xlink:role CDATA #IMPLIED • xlink:title CDATA #IMPLIED • xlink:label NMTOKEN #IMPLIED> • <!ELEMENT course EMPTY> • <!ATTLIST course<!-- a remote resource --> • xlink:type (locator) #FIXED "locator" • xlink:href CDATA #REQUIRED • xlink:role CDATA #FIXED "http://www.example.com/linkprops/course" • xlink:title CDATA #IMPLIED • xlink:label NMTOKEN #IMPLIED> Note: Both person and course are remote resources.
Example3: (the DTDs continued) • <!ELEMENT gpa ANY > • <!ATTLIST gpa<!-- a local resource of courseload --> • xlink:type (resource) #FIXED "resource" • xlink:role CDATA #FIXED • "http://www.example.com/linkprops/gpa" • xlink:title CDATA #IMPLIED • xlink:label NMTOKEN #IMPLIED> • <!ELEMENT go EMPTY> • <!ATTLIST go<!-- an arc of courseload --> • xlink:type (arc) #FIXED "arc" • xlink:arcrole CDATA #IMPLIED • xlink:title CDATA #IMPLIED • xlink:show (new |replace |embed |other |none) #IMPLIED • xlink:actuate (onLoad |onRequest |other |none) #IMPLIED • xlink:from NMTOKEN #IMPLIED • xlink:to NMTOKEN #IMPLIED>
Examle3 : an instance courseload element • <courseload> <!-- a link --> • <tooltip>Course Load for Pat Jones</tooltip> <!-- a title --> • <person xlink:href="students/patjones62.xml“ • xlink:label="student62“<!-- a remote resource --> • xlink:role=“http://www.example.com/linkprops/student” • xlink:title="Pat Jones" /> • <person xlink:href="profs/jaysmith7.xml“ • xlink:label="prof7“<!-- a remote resource --> • xlink:role=“http://www.example.com/linkprops/professor” • xlink:title="Dr. Jay Smith" /> • <!-- more remote resources for professors, teaching assistants, etc. --> • <course xlink:href="courses/cs101.xml" • xlink:label="CS-101" • xlink:title="Computer Science 101" /> • <!-- more remote resources for courses,seminars,etc.--> • <gpa xlink:label="PatJonesGPA">3.5</gpa> <!--ocal resource-->
Examle3 : an instance courseload element • <go xlink:from="student62" xlink:to="PatJonesGPA" • xlink:show="new" xlink:actuate="onRequest" • xlink:title="Pat Jones's GPA" /> • <go xlink:from="CS-101“ xlink:to="student62" • xlink:arcrole=http://www.example.com/linkprops/auditor • xlink:show="replace" xlink:actuate="onRequest" • xlink:title="Pat Jones, auditing the course" /> • <go xlink:from="student62“ xlink:to="prof7" • xlink:arcrole=http://www.example.com/linkprops/advisor • xlink:show="replace" xlink:actuate="onRequest" • xlink:title="Dr. Jay Smith, advisor" /> • </courseload>
Example4: Sample resource-Type Element Declarations and Instance • DTD • <!ELEMENT gpa ANY> • <!ATTLIST gpa • xlink:type (resource) #FIXED "resource“ • xlink:role CDATA #FIXED • http://www.example.com/linkprops/gpa • xlink:title CDATA #IMPLIED • xlink:label NMTOKEN #IMPLIED> • Instance • <gpa xlink:label="PatJonesGPA">3.5</gpa>
Example5: Sample locator-Type Element Declarations and Instance • DTDs • <!ELEMENT person EMPTY> • <!ATTLIST person • xlink:type (locator) #FIXED "locator“ • xlink:href CDATA #REQUIRED • xlink:role CDATA #IMPLIED • xlink:title CDATA #IMPLIED • xlink:label NMTOKEN #IMPLIED> • <!ELEMENT course EMPTY> • <!ATTLIST course • xlink:type (locator) #FIXED "locator“ • xlink:href CDATA #REQUIRED • xlink:role CDATA #FIXED • "http://www.example.com/linkprops/course" • xlink:title CDATA #IMPLIED • xlink:label NMTOKEN #IMPLIED>
Example5: Sample locator-Type Element Declarations and Instance • Instances • <person • xlink:href="students/patjones62.xml“ • xlink:label="student62“ • xlink:role = • "http://www.example.com/linkprops/student" • xlink:title="Pat Jones" /> • <person xlink:href="profs/jaysmith7.xml“ • xlink:label="prof7“ • xlink:role= • "http://www.example.com/linkprops/professor" xlink:title="Dr. Jay Smith" /> • <course xlink:href="courses/cs101.xml“ • xlink:label="CS-101" • xlink:title="Computer Science 101" />
label, from and to attributes • label attributes declared at locator or resources can be used to identify the starting (from) or ending(to) resource of an arc. • Ex: <go xlink:type="arc" xlink:from="A" xlink:to="B" /> <go xlink:type="arc" xlink:from="C" xlink:to="B" /> Note: Both from and to are optional attributes of arc element. If omitted, it means all resources are starting (or ending) resources.
Example6: <extendedlink xlink:type="extended"> <loc xlink:type="locator" xlink:href="..." xlink:label="parent" xlink:title="p1" /> <loc xlink:type="locator" xlink:href="..." xlink:label="parent" xlink:title="p2" /> <loc xlink:type="locator" xlink:href="..." xlink:label="child" xlink:title="c1" /> <loc xlink:type="locator" xlink:href="..." xlink:label="child" xlink:title="c2" /> <loc xlink:type="locator" xlink:href="..." xlink:label="child" xlink:title="c3" /> ... <!-- arc-type elements would go here --> </extendedlink> • <go xlink:type="arc" xlink:from="parent“ xlink:to="child" /> • included traversals: {p1,p2} {c1,c2,c3}, i.e., • p1c1, p1c2, p1c3, p2c1, p2c2, and p2c3:
Examle6 (continued) • <go xlink:type="arc" xlink:to="child" /> from omitted => {p1, p2, c1,c2, c3} {c1, c2, c3} • <go xlink:type=“arc” /> from and to omitted => {p1,p2,c1,c2,c3} {p1,p2,c1,c2,c3}
Example 7: Sample arc-Type Element Declarations and Instance • DTDs • <!ELEMENT go EMPTY> • <!ATTLIST go • xlink:type (arc) #FIXED "arc" • xlink:arcrole CDATA #IMPLIED • xlink:title CDATA #IMPLIED • xlink:show • (new |replace |embed |other |none) #IMPLIED • xlink:actuate • (onLoad |onRequest |other |none) #IMPLIED • xlink:from NMTOKEN #IMPLIED • xlink:to NMTOKEN #IMPLIED>
Example 7: Sample arc-Type Element Declarations and Instance • Instances • <go xlink:from="student62“ xlink:to="PatJonesGPA" • xlink:show="new“ xlink:actuate="onRequest“ • xlink:title="Pat Jones's GPA" /> • <go xlink:from="CS-101“ xlink:to="student62" • xlink:show="replace" xlink:actuate="onRequest" xlink:title="Pat Jones, auditing the course" /> • xlink:arcrole="http://www.example.com/linkprops/auditor" • <go xlink:from="student62“ xlink:to="prof7" • xlink:show="replace" xlink:actuate="onRequest" • xlink:arcrole="http://www.example.com/linkprops/advisor" • xlink:title="Dr. Jay Smith, advisor" />
Example 8: Sample title-Type Element Declarations and Instance • the DTDs <!ELEMENT advisorname (name)> <!ATTLIST advisorname xlink:type (title) #FIXED "title" xml:lang CDATA #IMPLIED> <!ELEMENT name (honorific?, given, family)> <!-- Further subelement declarations for names --> • A instance <advisor xlink:href="profs/jaysmith7.xml"...> <advisorname xml:lang="en"> <name><honorific>Dr.</honorific> <given>Jay</given> <family>Smith</family> </name></advisorname></advisor>
Linkbases • Types of arcs: outbound arcs, inbound arcs, third-party arcs • Examples of outbound arc: HTML A and IMG elements. • Typically, a link contains only one kind of arc, and might be referred to as an inbound, outbound, or third-party link. • Documents containing collections of inbound and third-party links are called link databases, or linkbases. Note: Linkbase behaves like index in database.
Locating Linkbases (Special Arc Role) • The problem: to traverse an arc, we need to locate the staring resource and the link. • Not a problem for outbound arcs since the starting resource is either the linking element itself or a child of the linking element. • But how could the XLink application find both pieces for inbound and third-party arcs ? • Solution: • Collect related inbound and third-party linking elements into many related linkbases. • A document that need traverse may declare special linkbase arcs (whose arcrole is predefined by Xlink to be http://http://www.w3.org/1999/xlink/properties/linkbase )linking to potential linkbasesof which the document or contents of it is a string resource of an arc. • When the document is loaded (or on request) the xlink application can traverse linkbase arcs and retrieve all potential links in advance.
Example 9: Annotating a Specification • The DTDs : an extended link that specializes in providing linkbase arcs: • <!ELEMENT basesloaded ((startrsrc|linkbase|load)*)> • <!ATTLIST basesloaded <!– a link --> • xlink:type (extended) #FIXED "extended"> • <!ELEMENT startrsrc EMPTY> • <!ATTLIST startrsrc <!– a resource --> • xlink:type (locator) #FIXED "locator“ • xlink:href CDATA #REQUIRED • xlink:label NMTOKEN #IMPLIED> • <!ELEMENT linkbase EMPTY> • <!ATTLIST linkbase<!– the linkbase resource --> • xlink:type (locator) #FIXED "locator" • xlink:href CDATA #REQUIRED • xlink:label NMTOKEN #IMPLIED>
The DTDs (continued) • <!ELEMENT load EMPTY> • <!ATTLIST load <!– linkbase arc --> • xlink:type (arc) #FIXED "arc" • xlink:arcrole CDATA #FIXED • "http://www.w3.org/1999/xlink/properties/linkbase" • xlink:actuate (onLoad |onRequest |other |none) #IMPLIED • xlink:from NMTOKEN #IMPLIED • xlink:to NMTOKEN #IMPLIED> Note: for linkbase arc, the show attribute has no effect since its default behavior is, according to the spec, that the XLink application should extract links from the linkbase.
Example 9: Annotating a Specification Usage 1: • <basesloaded> • <startrsrc xlink:label="spec“ • xlink:href="spec.xml" /> • <linkbase xlink:label="linkbase“ • xlink:href="linkbase.xml" /> • <load xlink:from="spec" • xlink:to="linkbase" • actuate="onLoad" /> • </basesloaded> Note:This link indicate that when spec.xml is loaded, linkbase.xml should automatically be loaded as well, possibly necessitating re-rendering of the entire specification document to reveal any regions within it that serve as starting resources in the links found in the linkbase.
Usage 2: • <basesloaded> • <startrsrc xlink:label="spec“ • xlink:href="spec.xml#string-range(//*, • 'Click here to reveal annotations.')" /> • <linkbase xlink:label="linkbase" xlink:href="linkbase.xml" /> • <load xlink:from="spec" xlink:to="linkbase" • actuate="onRequest" /> • </basesloaded> Notes: • The remote resource is not spec.xml but a portion of it. • linkbase.xml would be loaded only on request (possibly a click on the remote resource: 'Click here to reveal annotations.'.
basesloaded spec.xml: <words> this is a … <word>word1</word1> .. normal text … <word>word2</word> … </words> linkbase.xml: <annotations> <annotation x:type=“extended”> <source x:href=http:///spec.xml#xpointer(//word[1]” x:label=“word”/> <meaning x:type=“resource” x:label=“meaning”> word1 means … </meaning> <arc x:from=“word” x:to=“meaning” x:show=“…” x:actuate=“…” /> </annotation> … </annotations> Relation among basesloaded, spec.xml and linkebase.xml load
Simple Links (simple-Type Element) • A simple link is a link that associates exactly two resources, one local and one remote, with an arc going from the local to the remote. • simple link is always an outbound link.
Simple Links (simple-Type Element) • A simple link combines all the features above (except for the types and labels) into a single element. • The features missing from simple links: • Supplying arbitrary numbers of local and remote resources • Specifying an arc from its remote resource to its local resource • title of the earc • role or title of the local resource • role or title of the link • Meaning of attributes in a simple link: • x:href : URI ref of remote resource • x:role, x:title : role and title of remote resource • x:arctitle, x:show, x:actuate: … of the arc
Example 10: simple link • dtds: • <!ELEMENT studentlink ANY> • <!ATTLIST studentlink • xlink:type (simple) #FIXED "simple" • xlink:href CDATA #IMPLIED • xlink:role NMTOKEN #FIXED • “http://www.example.com/linkprops/student” • xlink:arcrole CDATA #IMPLIED • xlink:title CDATA #IMPLIED • xlink:show (new|replace|embed|other|none) #IMPLIED • xlink:actuate(onLoad|onRequest|other|none) #IMPLIED> • instance: …<studentlink xlink:href="students/patjones62.xml">Pat Jones</studentlink> is popular around the student union.