02.06.2013 Views

XML Demystified

XML Demystified

XML Demystified

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

70<br />

An Inside Look at XLink<br />

<strong>XML</strong> Demystifi ed<br />

XLink is <strong>XML</strong>’s way of linking a resource to a specific behavior. This might sound<br />

new to you, but it shouldn’t if you’re familiar with the way HTML links resources.<br />

XLink is basically a generalization of the HTML link.<br />

Before seeing how XLink works, let’s take a step back and review how HTML<br />

links are used; this will give you a foundation for understanding how to use XLink.<br />

An HTML link is an attribute within an anchor tag, such as the href attribute, that’s<br />

used to define a hyperlink, as we show here. The anchor tag can link to a resource<br />

such as this HTML page or to a location within the same page, which is called a<br />

relative link.<br />

<br />

Another common link is used in the img tag to link the src attribute to an image<br />

file, as we show here. The image file is an external resource to the web page and<br />

gets pulled into the current document. The browser loads the HTML page, parses it,<br />

and finds the image tag, then makes the request to the server for this resource.<br />

<br />

Tags that are associated with links exhibit a certain behavior based on a given<br />

link’s attribute. For example, the href attribute enables the anchor tag to jump to<br />

another page or to a different location on the same page. If the target attribute is<br />

used within the anchor tag, then the other page is displayed in a new browser<br />

window, as we show here.<br />

click here<br />

HTML tags that use links are specific. That is, you must define the link each and<br />

every time that you link an HTML tag. So, if all your images are located in the<br />

images directory on your server, you’ll need to reference the images directory each<br />

time that you link to an image; for example:<br />

<br />

In contrast, XLink enables you to generalize. For example, you can define a base<br />

as the images directory. The base is then referenced each time you link to an image.<br />

You don’t need to repeat the directory name in the link.<br />

HTML links are limited to a one-to-one relationship between the source and<br />

destination. That is, the src attribute can reference one image file. XLink enables<br />

you to specify multiple sources with multiple destinations.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!