|
Links in HTML are either passive, like the
A element links that remains inactive until we actually click
on them or the IMG element that inserts the graphic files that is referred.
The link behavior is tied to the particular
element for which the link is provided, and it does not affect the element much.
Xlink enables us to control the link that
is activated and traversed. Besides, it also controls the
action that occurs on traversing the link. The link behavior
is controlled by the show and the actuate attributes.
In HTML, an image is embedded at the point
at which its anchor element (IMG) occurs. Other links simply
jump to new document either in the same window, new window or a new frame.
In Xlink, the show attribute allows to formalize
this behavior for all links instead of depending on a link
with a particular name.
The following are the variations of show attribute.
show="embed" - When the link is traversed,
the resource is embedded at the point of location.
show="new" - When the link is traversed,
the designated resource is displayed in a new context.
show="replace" - When the link is
traversed, the designated resource replaces the resource at
which the traversal started.
| Problem with HTML pointers |
We shall now see about XPointers. But before
that let us see why we use XPointers instead of HTML pointers.
The problems with HTML pointers are that they may not point
to a location in a document if there is no declaration of
the A tag. In HTML, anchor tag A points to the entire target
document. It is not possible to point to a particular part
of the document or an element alone in that document.
We shall now focus on a different type of
locator, the extended pointer (Xpointer). Extended pointers
are described in a separate proposal called the XML Pointer
Language (Xpointer), which used to be part of the common XLL
(XML Link Language). A link resource is actually a pointer
to one or more locations. To resolve a location, we can use
a Web server CGI script or a database query. XML' s extended
pointers enable us to point into XML resources in different ways.
The W3C specification for XML pointers is known as XPointer.
|
|
Xpointer specification
essentially extends another specification, XPath. XPath
is the W3Cs' common mechanism for addressing individual
information items in an XML document. |
|
|
XPointer provides a syntax
for stating address information in a link to an XML document
as well as extending Xpath with a few additional features. |
| Specifying Xpointers in a URI |
When using Xpointers, URIs may contain a
reference to a particular position in an XML document. This
is achieved by appending an Xpointer fragment identifier to
the URI of the document itself.
The pointing mechanism used in URI,
is identified by putting the name of the pointing mechanism,
and a parenthesis around the locator. The representation is
as shown. It will point to the element with the ID book in
the catalog .xml document.
http://www.rox.com/Catalog/catalog.xml#xpointer(book)
An XML document can be viewed as being composed
of trees of elements. The root element is at the top or in
the base, and the other elements branch off from it.
The figure shows a typical XML element tree.
A tree can be constructed for every possible
entry point or a reference point, so we shall use the term
grove instead of tree. A grove comprises of a collection of
trees. It is smaller than forest but it is more than just
a super tree. Each point in a tree is called a node. A node
can be an element or a piece of text within an element.
Consider an element structure declared as
follows. This is a typical mixed content element. It can contain
both raw data and elements (title and para).
<!ELEMENT section (#PCDATA | title | para )>
Here, we have a section element that includes
one title and two para and elements.
<section><title> This
is an example of C++ pointers </title> <para>
Hello </para> <para> Today
is going to be a very special day</para> </section>
The figure shows one section element containing
a title element, a node of character data, a para element,
an intervening character data node or even depending on the
underlying operating system and last para element.
There are two types of location terms namely
absolute terms and relative terms.
Absolute terms are much like the location
pointers that point directly to specific elements.
Relative terms are easier to appreciate and much more powerful
than absolute terms because they are with reference to the
current path and hence complete path need not be specified.
Xpointers use the following absolute terms.
The term root() states that the location source for the location
term is the root element of the current document.
The function origin states that the location
source for the location term is the link resource at which
traversal started. The term id(name) states that the location
source for the location term is the element that has an attribute
declared as being an ID class with name as the value of that attribute.
html(name-value) specifies that the location
source for the first location term is the first element of
type A that has a name attribute with a value of name-value.
The location terms in the URI need not necessarily
have the complete path. They can be specified relative to
the current location. The ultimate goal of an extended pointer
is to direct or point to the exact location within an XML
document. This is similar to that of a person trying to locate
the path to be traveled to reach the destination. This may
involve several steps. Each step depends upon the previous
step being followed. If one step is missed, the path may be
lost. Extended pointers work exactly in the same way.
In extended pointers, there is a sequence
of location terms, which are either absolute or relative,
wherein each location is relative to the previous one.
Using element number 4 as the location source,
we shall see the relative terms with respect to the figure shown.
The term Child refers to the elements 6,7
and 8 (the immediate children but not 11 and 12).
The term Descendant refers to the elements
6,7,8,11 and 12 (the immediate children and their children).
The term Ancestor refers to the elements
1 and 2 (the elements that contain element 4).
The term Preceding refers to the elements
1,2 and 3 (all the elements that appear before the location source).
The term Following refers to the elements
6,7,8,11,12,5,9 and 10 (all the elements that appear after the location source).
The term Psibling refers to the element
3 (the elements at the same level of hierarchy or generation that come before the location source).
The term Fsibling refers to the element
5 (the elements at the same level of hierarchy or generation that come before the location source).
Extended pointers offer several ways to select elements.
In this method, by specifying a number,
we can select a particular element instance for example, child(2)
selects the child element. Specifying a negative number counts
from the last instance backwards. For example, (-1,PARA) selects
the last <PARA> element.
In addition to selecting a resource by number,
we can specify a particular type of node, the instance is
followed by a comma and a node type, which can be one of the
following values: name, #element, #pi, #comment, #text, #cdata and #all.
The element type, if specified can be qualified
by an attribute by using the attr keyword. The string location
term actually allow us to look inside an element and select
text located within it. String locators are extremely useful
when linking into non-XML data that contains large blocks of text.
A resource location may contain a single
extended pointer or two extended pointers separated by a span
keyword. If it has two extended pointers, the location is
assumed to be everything from the start of the target of the
first extended pointer to the end of the second one.
Copyrights : Layout Galaxy All Rights Reserved
No part of this tutorial may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, electrostatic, magnetic tape, mechanical or otherwise, without prior permission in writing from Layout Galaxy.
|
|