Title: XML-Linking
1XML-Linking
- XPath, XPointer
- XLink
- XSL (a taste)
2HTML linking
- Trivial syntax
- lta href"http//foo.net/x.html"gt
- Trivial to implement
- Some ability to go to specific targets (ID only)
- lta href"http//foo.net/x.htmlsec2"gt
- Embedded markup lets source anchors move with
editing - (unlike, say, byte offsets)
3HTML linking limitations
- 1 Two elements A and IMG
- 2 One link behavior for A, one for IMG
- 3 No real link type system
- 4 URLs as pointing mechanism
- 5 Privileged end lives inline in origin document
- 6 Destination is a whole document
- 7 One destination No aggregate destinations
- 8 One way A or IMG to somewhere
4A family of technologies
XML
Structuring Documents
5Linking in XML
- Needs to overcome three things
- How do I address an anchor point in both the
SOURCE node and the TARGET node (rather than a
whole target resource with a Uniform Resource
Identifier) ? - How do I introduce link types?
- How do I manage external/multi-ended links?
6XPointer
- Provides addressing into XML document structure
attaching the links end(s)
d
o
c
t
i
t
l
e
d
e
s
c
r
i
p
A pointer identifies a point, node, or range in
a document
s
t
a
t
u
s
t
r
e
v
i
s
i
o
n
c
o
d
e
c
o
d
e
7XLink
- Provides the connection where/what is the line
between? - add behaviors to links
- without using Javascript
A link groups data portions anddescribes their
relationships
8URLs as pointers
- Very prone to breakage
- Fundamentally point to copies, not objects
- Like a bibliography that cites shelf position
instead of author, title, and date - URLs presume retrieving whole documents
- Therefore, people break non-trivial documents
into bits - But, since theres no typing, you cant tell
which links mean reassemble - Therefore, indexers cant reassemble or detect
whole documents, just pages - Therefore, you cant have automatic assemble and
retrieve/print/search - Guess why theres not very much literature on the
Web?
9Addressing in HTML
- ltpgtFor information about the XPointer language
that lta title"Must, May, etc."
href"dt-must"gtmaylt/agt be used with XLink, see
lta href"xptr"gtXPTRlt/agt.lt/pgt - ltdt class"label"gtlta name"xptr"gtlt/agtXPTRlt/dtgtltddgt
Ron Daniel, Steve DeRose, and Eve Maler,
editors.ltcitegt XML Pointer Language (XPointer)
V1.0lt/citegt. Metacode Technologies, Brown
University, and Sun Microsystems. - Burlington, Seekonk, et al. World Wide Web
Consortium, 1998. (See lta href"http//www.w3.org
/TR/xptr"gthttp//www.w3.org/TR/xptrlt/agt.)lt/ddgt
10Addressing in XML
- ltmessagesgt
- ltnote ID"501"gt
- lttogtTovelt/togt
- ltfromgtJanilt/fromgt
- ltheadinggtReminderlt/headinggt
- ltbodygtDon't forget me this weekend!lt/bodygt
- lt/notegt
- ltnote ID"502"gt
- lttogtJanilt/togt
- ltfromgtTovelt/fromgt
- ltheadinggtRe Reminderlt/headinggt
- ltbodygtI will not!lt/bodygt
- lt/notegt
- lt/messagesgt
Addressing elements (like the note element)
http//www.ex.org/mgesid(501)
11Destination is a whole document
- Exception can scroll to ID if it existsltA
HREF"http//xyz.com/foo.htmlid(37)"gt - No way to point to anything but an element
- Author controls what others can reference
- Imagine on paper You can only quote or footnote
paragraphs 1, 12, 17, or 20. - Since documents are fragmented to make pages,
the whole document isnt anyway - You cant link to a whole play/novel/etc on the
Web, since it wont be there as a whole (or if it
is, you cant read it feasibly with browsers)
12XPath and XPointer
- How do I address an anchor point in both the
SOURCE node and the TARGET node? - XPath
- Expression language that addresses parts of an
XML document - Basic facilities for string, number and boolean
manipulation - Operates on the abstract, logical tree structure
of an XML document - Uses the XML regular structure as guideposts in
the expressions - Gets its name from the use of a path notation
navigating through the hierarchical structure of
an XML document - BUT it only addresses XML nodes (elements,
attributes, text). - XPointer
- Addresses freely any fragments of an XML document
- Spans across XML chunks
13XPath Components (1)
- An XPath expression operates over
- CONTEXTS to create NODE
SETS
root
/
book
abstract
title
chapter
chapter
chapter
ID 'intro'
ID'summary'
ID'concepts'
section
section
para
title
para
para
Attribute
list
...
ID'p37'
a
xref
Element
namecarole'
href'id(intro)'
14XPath Components (2)
- The context for an XPath expression is the node
in the source XML document currently being
processed. - E.g. "/", means that we are in the context of the
root of the XML document. - The location path sets the context of the node
that you're trying to find. - A location path expression is an expression used
for selecting a node set by following a path of
locations steps. - Each location step is made up of the combination
of - an axis
- a node test
- zero or more predicates
15XPath Components (3)
- An axis returns a list of nodes, based on the
context of the original node, corresponding to
the relationships in ordered trees - E.g. child axis locates the set of all the
current context node direct sub elements. - A node test specifies the type of a node,
including general types like comment() or
specific types - E.g. childbook, selects all the book elements
that are children of the current context node - A predicate filters the node list located by the
axis and the node-test - E.g. childselfauthor or selfreviewer
- selects all children of the current node that are
either of element type author or reviewer - Childchapterchildabstract selects chapter
children of the context node that have abstracts
16XPath Components (4)
- Expressions return a node-set selected by the
operators, path locations and filters used in the
XPath expression. - chapterauthor"Jones" or author"Scott"
- returns chapter nodes where the author is Jones
or Scott
17XPath Examples
- childpara selects the para element children
- child selects the element children
- /descendantpara all the para elements of the
document - /book/chapter5/section2 the second section of
the fifth chapter of the book elements under the
document root - /descendantpposition()last() the last p in
document order - //note_at_type"warning" all note elements that
has a type attribute with value warning
18XPointer Usage
- How do I address an arbitrary anchor point in the
node? - XPointer is the fragment identifier portion of
any URI reference. So it encapsulates an XPath
expression in a URI reference . - Could be bare names just like html
- Intro
- Or could embed the expression
- xpointer(id(intro))
19XPointer extensions to XPath
- Initialization of the XPath context
- XPath Node concept is extended to a location
node, point or range - A location-set is a generalization of XPath's
node-set - XPointer generates an ordered list of nodes,
points or ranges within the document, not just
nodes (like XPath did)
20XPointer Examples
- xpointer(//local-name()'y' and
namespace-uri()'http//www.foo.com/bar') - locates all the y elements from the namespace
whose URI is http//www.foo.com/bar - xpointer(id("sec2.1")//p2 range_to
id("sec2.2")//plast()) - selects the range from the second p child of
sec2.1 to the end of the last p in sec2.2 - string-range(//title,"XPointer")
- returns the set of ranges containing "XPointer"
strings when they occur within title elements
21XPointer
- locate the range from the start-point for the
element with ID "chap1" to the end-point for the
element with ID"chap2". - xpointer(id("chap1")/range-to(id("chap2")))
- select, for each revision, a range starting at
the beginning of the REVST element and ending at
the end of the next REVEND element - pointer(descendantREVST/range-to(followingREVE
ND1))
22XPointer extensions to XPath
- A string-range() function to address within node
content - The functions start-point() and end-point() to
address beginning and ending of locations. - The unique() function to detect absence or
multiple return values. - The functions here() and origin() to refer to the
XPointer expression location and hypertext
traversal
23The here() function example
- here function appears inside an XPointer that is
in an attribute node. The XPointer as a whole
returns the slide element just preceding the
slide element that most directly contains the
attribute node in question. - ltbutton
- xlinktype"simple
- xlinkhref"xpointer(here()/ancestorslide1/pr
ecedingslide1)"gt - Previous
- lt/buttongt
24XPointer Summary
- So, extensions to XPath allow XPointer to
- Address points and ranges as well as whole nodes
- Locate information by string matching
- Use addressing expressions in URI references as
fragment identifiers - Extends XPath types and add specific operations
25Linking in XML
- Needs to overcome three things
- How do I address an anchor point in the SOURCE
and TARGET node (rather than a whole target
resource with a Uniform Resource Identifier) ? - How do I introduce link types?
- How do I manage external/multi-ended links or
more generally, how do I control link behaviour?
?
26XLink Linking Model (1)
- XLink a way to gather locations to make links
- Link elements (anchors)
- Element being connected by a link
- Locator
- Addresses remote resource
- Arc
- Information about how to traverse a pair of
resources, including the direction of traversal
and possibly application behavior - Link
- Aggregates the above into a set of a given
link-type. - May include multiple locators and arcs to present
multi-ended links.
27XML Link Model (2)
- Remote resources
- If the resource is addressed by its URI reference
- I.e. specified by reference
- Local resource
- If the resource participates in the link by
virtue of being a link element or its parent
being a link element - Specified by value
- Outbound links
- Local start, remote end
- Inbound links
- Remote start, local end
- Third party
- Remote start, remote end
- Linkbases
- Documents containing collections of inbound and
third-party links
28XLink Simple Example
- ltmycrossReference
- xmlnsmy"http//example.com/"
- xmlnsxlink"http//www.w3.org/1999/xlink"
- xlinktype"simple"
- xlinkhref"students.xml"
- xlinkrole"studentlist"
- xlinktitle"Student List"
- xlinkshow"new"
- xlinkactuate"onRequest"gt
- Current List of Students
- lt/mycrossReferencegt
Link type
Link location
Link metadata
Link traversal behaviour
29XLink Identifying link elements
- linking element, which is an XLink-conforming XML
element that asserts the existence of a link. - There are two types of linking element
- Simple
- Extended
- Four types of link metadata elements
- Arc
- Locator
- Title
- Resource
30XLink Elements
- Simple Links
- an outbound link with exactly two participating
resources (just like HTML-style A and IMG links
fall). Little functionality, no special internal
structure. - Extended links offer full XLink functionality,
- such as inbound and third-party arcs
- links that have arbitrary numbers of
participating resources - Their structure can be fairly complex, including
elements for - Pointing to remote resources,
- Containing local resources,
- Specifying arc traversal rules,
- Specifying human-readable resource and arc titles
- special ways of finding linkbases
Locator to remote resource
Locator to remote resource
Locator to remote resource
extended
Local resource
Locator to remote resource
Locator to remote resource
31Extended Links
- Containers for explicit locators and arc
subelements - Traversal rules govern directionality and
behaviour - Locator attributes
- href - XPointer
- Semantic attributes
- Role a property the entire link has
- Arcrole a property the arc has
- Title human readable description of the entire
link - Traversal Attributes
- Label a way for an arc to refer to the link
- From labelled source of the link
- To labelled the destination of the link
- Link behaviours
- Show - replace, new, embed, other, none
- Actuate onLoad, onRequest, other, none
32Example
- ltcourseloadgt xlinktypeextended"
- lttooltipgtxlinktypetitle Course Load for Pat
Joneslt/tooltipgt - ltperson
- xlinktypelocator"
- xlinkhref"students/patjones62.xml"
- xlinklabel"student62
- xlinkrole"http//www.example.com/linkprops/s
tudent - xlinktitlePat Jones /gt
- ltcourse
- xlinktypelocator"
- xlinkhref"courses/cs101.xml"
- xlinklabel"CS-101"
- xlinktitle"Computer Science 101" /gt
- ltgpa xlinktyperesource xlinklabel"PatJonesG
PA"gt3.5lt/gpagt - ltgo
- xlinktypearc"
- xlinkfrom"student62"
- xlinkto"PatJonesGPA"
- xlinkshowreplace"
Link type
Link metadata
Link location
Traversal attributes
Link traversal behaviour
33XML-Linking goals end user
- Dynamic updates and patches
- Push updates without re-sending whole docs
- Highlighter annotations
- Shareable annotations
- Links from un-writable documents
- Which is most of the Web, for any person
- Large sets of managed links
- An entirely new market for links per se
- Anyone can sell their commentary on other data
34XML Linkbases
- lt!ELEMENT basesloaded ((startrsrclinkbaseload))
gt - lt!ATTLIST basesloaded
- xlinktype (extended) FIXED "extended"gt
- lt!ELEMENT startrsrc EMPTYgt
- lt!ATTLIST startrsrc
- xlinktype (locator) FIXED "locator"
- xlinkhref CDATA REQUIRED
- xlinklabel NMTOKEN IMPLIEDgt
- lt!ELEMENT linkbase EMPTYgt
- lt!ATTLIST linkbase
- xlinktype (locator) FIXED "locator"
- xlinkhref CDATA REQUIRED
- xlinklabel NMTOKEN IMPLIEDgt
- lt!ELEMENT load EMPTYgt
- lt!ATTLIST go
- xlinktype (arc) FIXED "arc"
- xlinkarcrole CDATA FIXED
"http//www.w3.org/1999/xlink/properties/linkbase"
- xlinkactuate (onLoadonRequestothernone)
IMPLIED - xlinkfrom NMTOKEN IMPLIED
- ltbasesloadedgt
- ltstartrsrc xlinklabel"spec"
xlinkhref"spec.xml" /gt - ltlinkbase xlinklabel"linkbase"
xlinkhref"linkbase.xml" /gt - ltload xlinkfrom"spec" xlinkto"linkbase"
actuate"onLoad" /gt - lt/basesloadedgt
35Processing XML
- An XML file only has
- data semantics
- The remainder
- presentation semantics
- user interface semantics
- behavioural semantics
- must be mapped on somehow.
- Processing XML
- High level - XSL
- Medium Level - DOM / JavaScript
- Low Level - SAX / Java
- XSL is a language that can
- transform XML into HTML,
- filter and sort XML data,
- address parts of an XML document,
- format XML data based on the data value
- output XML data to different devices, like screen
or voice
36XSL - The Style Sheet of XML
- XSL provides
- an XML vocabulary for specifying formatting
semantics - a language for transforming XML data
- XSL consists of three parts
- a language for transforming XML documents XSLT
- a language for defining XML parts and patterns
XPath - a language for formatting XML documents
Formatting Objects DTD - XSL uses
- templates
- match an element in the original document
- specify the new content to replace the element by
- specify the template matches using XPath
37XSL Processing
Web page
Printed document
mydoc .xml
mydoc .dtd
WAP page
style .xsl
XSLT processor
XSL processor
FOdoc .xml
FO .dtd
FO .xsl
38XML-gtXSL-gtpretty picture
- lt?xml version'1.0'?gt ltxslstylesheet
xmlnsxsl"http//www.w3.org/TR/WD-xsl"gt - ltxsltemplate match"/"gt
- lthtmlgt ltbodygt
- lttable border"1"gt lttrgt
- ltthgtTitlelt/thgt
- ltthgtArtistlt/thgt lt/trgt
- lttrgt lttdgt
- ltxslvalue-of select"CATALOG/CD/TITLE"/gtlt/tdgt
lttdgt - ltxslvalue-of select"CATALOG/CD/ARTIST"/gtlt/tdgt
lt/trgt lt/tablegt lt/bodygt lt/htmlgt - lt/xsltemplategt
- lt/xslstylesheetgt
- lt?xml version"1.0"?gt
- lt?xml-stylesheet type"text/xsl"
href"cd_catalog.xsl"?gt - ltCATALOGgt
- ltCDgt
- ltTITLEgtEmpire Burlesquelt/TITLEgt
- ltARTISTgtBob Dylanlt/ARTISTgt
- ltCOUNTRYgtUSAlt/COUNTRYgt
- ltCOMPANYgtColumbialt/COMPANYgt
- ltPRICEgt10.90lt/PRICEgt
- ltYEARgt1985lt/YEARgt
- lt/CDgt
- .
- lt/CATALOGgt
39Further Reading Tutorials
- www.W3Schools.com
- www.zvon.org
- www.xml.com