Previous | Table of Contents | Next |
In XML, all these links are called simple in-line links. Links connect resourcesanything which happens to be reachable by the use of a locator in some linking element. (Resources include documents, but they also include graphics and other files.) The locator is a URL, defined the same way as URLs for HTML, and equally capable of using fragment identifiers. For in-line links, the element defining the link counts as one of those resources, and the target is the other. The classic HTML HREF link is an in-line link because it points only one direction: from the element that provides the link to the target location. (The Back button doesnt count, in this example, as providing two-way linking.) The action taken when a link is actuated is called traversing, even if the link doesnt take the actuator (which may be a user or a program) any place new.
A simple link in XML carries all its linking information in the linking element. There is no need in a simple link for the application to search out other elements carrying information about the locatorsall the locator information is provided in the HREF attribute.
Building a true XML link isnt exactly simple, however; it takes more than an HREF attribute for an element to be a link. A sample declaration for an element using simple links (taken from the 7/31/97 XML-Link Working Draft) follows:
<!ELEMENT SIMPLE ANY> <!ATTLIST SIMPLE XML-LINK CDATA #FIXED "SIMPLE" ROLE CDATA #IMPLIED HREF CDATA #REQUIRED TITLE CDATA #IMPLIED INLINE (TRUE|FALSE) "TRUE" CONTENT-ROLE CDATA #IMPLIED CONTENT-TITLE CDATA #IMPLIED SHOW (EMBED|REPLACE|NEW) "REPLACE" ACTUATE (AUTO|USER) "USER" BEHAVIOR CDATA #IMPLIED >
Link elements dont have to be called SIMPLEany element can be a link element. The SIMPLE element declaration is used, both here and in the Working Draft, only for illustration. In fact, any element can be a linkthere is no need to create separate elements like the HTML A that exist solely to implement simple links. |
The familiar HREF attribute is still there and works the same way as it did in HTML, although, as well see later, it too has been extended. The rest of the attributes are new. The first link, XML-LINK, announces to the processing application that this element is in fact a linking element and that it is a simple link. The XML-LINK attribute is required for all links; defining it with a fixed value in the DTD is usually a better solution than spelling out this attribute in every single instance of the element.
Avoid the temptation to create documents and DTDs that use an HREF attribute without declaring XML-LINK. Even though they might work in HTML browsers, XML-LINK compliant processing applications will ignore the HREF attribute if the XML-LINK attribute is missing. |
The ROLE attribute is optional (as are all the attributes marked #IMPLIED or provided with a default value here), allowing the link to specify the meaning of the link to the application processing the link. The ROLE attribute is intended for use only by machine processorsinformation meant for humans to read should be kept in the TITLE attribute. The HREF attribute provides the link with a locator, a URL as already described. The TITLE attribute, also optional, includes information that could, for example, pop up as the user rolls the mouse over a link much as the ALT tags for clickable images appear during rollovers in the latest versions of the Netscape and Microsoft browsers.
The TITLE attribute in XML has nothing to do with the TITLE element in HTML; its just an unfortunate overlap in name. |
Previous | Table of Contents | Next |