Latest web development tutorials

XLink examples

Let's study an example to learn some basic XLink syntax.


XML instance documents

Consider the following XML document, "bookstore.xml", which is used to render Books:

<?xml version="1.0" encoding="ISO-8859-1"?>

<bookstore xmlns:xlink="http://www.w3.org/1999/xlink">

<book title="Harry Potter">
<description
xlink:type="simple"
xlink:href="http://book.com/images/HPotter.gif"
xlink:show="new">
As his fifth year at Hogwarts School of Witchcraft and
Wizardry approaches, 15-year-old Harry Potter is.......
</description>
</book>

<book title="XQuery Kick Start">
<description
xlink:type="simple"
xlink:href="http://book.com/images/XQuery.gif"
xlink:show="new">
XQuery Kick Start delivers a concise introduction
to the XQuery standard.......
</description>
</book>

</bookstore>

See "bookstore.xml" in your browser bookstore.xml file.

In the above example, XLink namespace document (xmlns: xlink = "http://www.w3.org/1999/xlink") is declared at the top of the document. This means that the document can access the properties and characteristics of the XLink.

xlink: type = "simple" to create a simple HTML-like links. You can also specify more complex links (multi-directional links), but for now, we only use simple links.

xlink: href attribute specifies a link to the URL, and the xlink: show attribute specifies where to open the link. xlink: show = "new" means that the link (in this case, is an image) will open in a new window.


XLink - depth study

In the above example, we only show a simple link. When we want to access the remote location of the resource, rather than a separate page, XLink is more interesting. In the above example <description> XLINK attribute set of elements is displayed: "new". This means that the link should open in a new window. We can set the value XLINK: Display Properties "embed". This means that the resource should be embedded in the page processing. Do you think this could be another XML document, rather than just an image, you can create an example of an XML document hierarchy.

Use XLink, you can also specify if the resource is displayed. This is handled by the XLink actuate attributes. XLINK: actuate "=" onLoad "specifies the resource files to be loaded and displayed .XLINK: actuate =". OnRequest "can not read or display the resource link is clicked before mean this to set low bandwidth is very convenient.