YouTip LogoYouTip

Xlink Example

# XLink Example * * * Let’s learn some basic XLink syntax by studying an example. * * * ## XML Example Document Take a look at the following XML document, "bookstore.xml", which is used to present books: As his fifth year at Hogwarts School of Witchcraft and Wizardry approaches, 15-year-old Harry Potter is....... XQuery Kick Start delivers a concise introduction to the XQuery standard....... View the "bookstore.xml" file in your browser: [bookstore.xml](#). In the above example, the XLink namespace declaration (xmlns:xlink="http://www.w3.org/1999/xlink") is declared at the top of the document. This means the document can access XLink attributes and features. xlink:type="simple" creates simple, HTML-like links. You can also define more complex links (multidirectional links), but for now, we’ll only use simple links. The xlink:href attribute specifies the URL to link to, while the xlink:show attribute specifies where the link should open. xlink:show="new" means the link (in this case, an image) will open in a new window. * * * ## XLink - Advanced Learning In the above example, we only demonstrated simple links. XLink becomes more interesting when accessing resources located remotely rather than standalone pages. In the above example, the element's XLink attributes have the value "new" for the show attribute. This means the link should open in a new window. We can set the XLink show attribute's value to "embed". This means the resource should be embedded into the page during processing. You might think of this as another XML document rather than just an imageβ€”you could build an example showing hierarchical structure within an XML document. Using XLink, you can also specify when a resource should be displayed. This is handled by XLink’s actuate attribute. xlink:actuate="onLoad" specifies that the resource file should be loaded and displayed immediately. xlink:actuate="onRequest" means the resource cannot be read or displayed until the link is clicked. This is very convenient for low-bandwidth environments.
← Xpointer ExampleXlink Syntax β†’