XLink Example
Let's try to learn some basic XLink syntax by looking at an example.
The XML Example Document
Look at the following XML document, "bookstore.xml", that represents a few 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> |
View the "bookstore.xml" file in your browser
In the example above the XLink namespace is declared at the top of the
document (xmlns:xlink="http://www.w3.org/1999/xlink"). This means that
the document has access to the XLink attributes and features.
The xlink:type="simple" creates a simple "HTML-like" link. You can also specify more complex links
(multidirectional links), but for now, we will only use simple links.
The xlink:href attribute specifies the URL to link to, and the xlink:show
attribute specifies where to open the link. xlink:show="new" means that the link
(in this case, an image) should open in a new window.
XLink - Going Further
In the example above we have only demonstrated simple links. XLink is getting more
interesting when we want to access remote locations as resources, instead of
standalone pages. The <description> element in the example
above sets the value of the xlink:show attribute to "new". This means that
the link should open in a new window. We could have set the value of the xlink:show
attribute to "embed". This means that the resource should be processed inline
within the page. When you consider that this could be
another XML document and not just an image, you could, for example, build a hierarchy of XML documents.
With XLink, you can also specify WHEN the resource should appear. This is handled by
the xlink:actuate attribute. xlink:actuate="onLoad" specifies that the resource should be loaded
and shown when the document loads. However, xlink:actuate="onRequest" means that
the resource is not read or shown before the link is clicked. This is very handy
for low-bandwidth settings.
Make your web applications look like a million bucks
|
|
Most web applications today use boring methods to present data to their viewers using grids or simple HTML tables. FusionCharts induces "life" into the web applications by converting monotonous data into lively charts, gauges & maps.
FusionCharts works with all technologies like ASP, ASP.NET, PHP, ColdFusion, Ruby on Rails, JSP, HTML pages etc.
and connects to any database to render animated & interactive charts. It takes less than 15 minutes and no expertise
whatsoever to build your first chart and just a glance of it to captivate your audience. This fact is endorsed by our
12,000 customers and 150,000 users which include a majority of the Fortune 500 companies.
And yeah, your applications could look like a million bucks by spending just $69.
So go ahead, download your
copy of FusionCharts and start "wow-ing" your customers now!
|
 |
W3Schools' Online Certification Program
The perfect solution for professionals who need to balance work, family, and career building.
More than 4000 certificates already issued!
|
The HTML Certificate documents your knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
|