XLink-XPointer Tutorial by doungnapa

VIEWS: 55 PAGES: 20

More Info
									XLink-XPointer



                 1
Content
n What is XLink?
n XLink and XPointer Browser Support
n XLink Syntax
n XLink Example


n What is XPointer?
n XPointer Syntax
n XPointer Example
n Xlink-XPointer Summary
                                       2
What is XLink?
n XLink is short for XML Linking Language
n XLink is used to create hyperlinks in XML
  documents
n Any element in an XML document can
  behave as a link
n XLink supports simple links (like HTML)
  and extended links (for linking multiple
  resources together)

                                              3
What is XLink? (cont.)
n With XLink, the links can be defined
  outside the linked files
n XLink is a W3C Recommendation




                                         4
XLink and XPointer Browser
Support
n The browser support for XLink and
  XPointer is minimal.
n There is some XLink support in Mozilla
  0.98+ and Internet Explorer 6.0+. Earlier
  versions of these browsers have no
  XLinks support at all!



                                              5
XLink Syntax
n   In HTML, we know (and all the browsers
    know!) that the <a> element defines a
    hyperlink. However, this is not how it
    works with XML. In XML documents, you
    can use whatever element names you
    want - therefore it is impossible for
    browsers to predict what hyperlink
    elements will be called in XML documents.


                                                6
XLink Syntax (cont.)
n   The solution for creating links in XML
    documents was to put a marker on
    elements that should act as hyperlinks.




                                              7
XLink Syntax (cont.)
n   Simple XML Document
          version="1.0"?>
    ¨ <?xml
     <homepages >
           <homepage>
                  Visit W3Schools
           </homepage>

           <homepage>
                 Visit W3C
           </homepage>
      </homepages>
                                    8
XLink Syntax (cont.)
n   XML Document with Xlink (ex1/xlink.xml)
    ¨   <?xml version="1.0"?>
        <homepages xmlns:xlink="http://www.w3.org/1999/xlink">
           <homepage xlink:type="simple"
           xlink:href="http://www.w3schools.com">
                 Visit W3Schools
           </homepage>

           <homepage xlink:type="simple"
           xlink:href="http://www.w3.org">
                 Visit W3C
           </homepage>

        </homepages>
                                                                 9
XLink Syntax (cont.)
n   To get access to the XLink attributes and
    features we must declare the XLink
    namespace at the top of the document.
    ¨ The  XLink namespace is:
      "http://www.w3.org/1999/xlink".
n   The xlink:type and the xlink:href attributes in
    the <homepage> elements define that the
    type and href attributes come from the xlink
    namespace.
                                                 10
XLink Example
n   ex2/xlink2.xml

    ¨ xlink:type="simple"   creates a simple "HTML-
      like" link.
    ¨ xlink:href attribute specifies the URL to link to
    ¨ xlink:show="new" means that the link should
      open in a new window.
    ¨ xlink:show=“replace" means that the link should
      open in a same window.

                                                      11
What is XPointer?
n XPointer is short for XML Pointer Language
n XPointer allows the links to point to specific
  parts of an XML document
n XPointer uses XPath expressions to
  navigate in the XML document
n XPointer is a W3C Recommendation




                                              12
XPointer Syntax
n In HTML, we can create a hyperlink that
  either points to an HTML page or to a
  bookmark inside an HTML page (using #).
n If the hyperlink points to an XML document,
  we can add an XPointer part after the URL
  in the xlink:href attribute, to navigate (with
  an XPath expression) to a specific place in
  the document.

                                              13
XPointer Syntax (cont.)
n   For example, in the example below we use
    XPointer to point to the fifth item in a list
    with a unique id of "rock":
    ¨ href="http://www.example.com/cdlist.xml
      #id('rock').child(5,item)"




                                                14
XPointer Example
n   ex3/xpointer.xml




                       15
Xlink-XPointer Summary
n This tutorial has taught you a standard way
  of creating hyperlinks in XML documents.
n You have learned that linking in XML is
  divided into two parts: XLink and XPointer.
n XLink defines a standard way of creating
  hyperlinks in XML documents and XPointer
  allows the hyperlinks to point to more
  specific parts (fragments) in the XML
  document.
                                           16
17
Resources



            18
Resources
n XML: Visual Quick Start Guide (2nd
  Edition)
n Real World XML (2nd Edition)
n http://www.w3schools.com




                                       19
     Questions?

Somjet Thanaphakawat
Email: somjeth@gmail.com

                           20

								
To top