Link markup

All XLink features are provided using reserved attributes. The most significant of these specifies what kind of link to make. The Namespaces standard (see Chapter 10) is used to identify the elements and attributes that contribute to the creation of links. The namespace URL reserved for this purpose is 'http://www.w3.org/1999/xlink'. As in the standard itself, the prefix 'xlink' is used in the following examples, but, as usual, a document author may choose any legal prefix. Note that, for the sake of brevity, most of the following example document fragments do not involve a namespace declaration, but it should be assumed that one is present on an unseen root element.

Types

The Type attribute is used to identify what XLink role a particular element type in the document is to take. For example, an element called 'simpleLink' could be assigned to the role of a 'simple' XLink link:

See <simpleLink xlink:type="simple" ... >book
9</simpleLink> for details.

Note

It is not relevant to refer to specific element names in this chapter, yet it is necessary to discuss elements that adopt specific XLink roles. The convention in the draft standard, and in this chapter, is to refer to 'role-type' elements, such as 'simple-type', with the understanding that the actual element name could be 'simple', 'link', 'A' or any other valid XML element name.


The Type attribute can take the value 'simple' (as shown above) or 'extended', and within extended links there can be 'locator', 'arc', 'resource' or 'title' constructs, which are also identified using this attribute.

A prefix, such as 'xlink:', is always required on this XLink attribute (and on all other XLink attributes). The Namespaces standard makes it clear that attributes without a prefix do not belong to the default namespace, and it is generally understood that such attributes belong to the namespace of the elements they are attached to. The XLink namespace does not include any element definitions, so an XLink attribute can never belong to the same namespace as the element it is attached to.

Resource identifiers

The XLink standard uses the URL scheme (see Chapter 30), the XPointer scheme (see Chapter 28), or a combination of the two, to locate the target resource. The URL is held in the Href attribute:

See <simpleLink xlink:type="simple"
                xlink:href="file://book9.xml">book
9</simpleLink> for details.

DTDs

When a DTD or XML Schema document is available to validate documents that will contain XLink constructs, it is highly desirable to update the model to take account of the XLink standard. Elements should be added to the model, if existing elements cannot be adapted to take XLink roles, and these new or existing elements can then be mapped to specific roles using fixed attributes. This simplifies document creation and maintenance by hiding unnecessary complications from the document authors.

While the names of the elements are not constrained in any way (beyond the usual constraints dictated by the XML standard itself), typically the DTD or XML Schema author would choose to name new elements after the XLink roles they are supporting. For example, an element called 'simpleLink' could be defined, and given an XLink Type attribute with a fixed value of 'simple':

<!ELEMENT simpleLink  (#PCDATA)>
<!ATTLIST simpleLink  xlink:type CDATA #FIXED "simple"
                      ... >

Document authors do not then need to know or care about the Type attribute, and can focus on the purpose of the element it is assigned to instead. In the following example, the document author simply adds a URL to the SimpleLink element:

See <simpleLink xlink:href="..." >book 9</simpleLink>
for details.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.120.109