Hyperlinks in XML
Saturday, 17. September 2005, 13:52:10
More then six years passed since W3C introduced XML 1.0 but we still don't have reasonable linking mechanism. The question is very simple: how to add simple hyperlink like
to XML page?
I must confess that I know no reasonable answer. Any suggestions?
W3C suggests to use XLink 1.0 and to code our simple link as follows
Hard to imagine more awkward solution. The more interesting is that, according to XLink 1.0 recomendation, xlink:type attribute is required (otherwise link is not processed) while xlink:href attribute is optional. For example this is valid XLink 1.0
and this is invalid one:
Everything this is so stupid that in a few years even W3C realised that one has to "make XLink easier to use" and released XLink 1.1 WD that "solves" the problem by specifying default value for xlink:type attribute. So in near future when XLink 1.1 will be approved one will be able to use compact markup like
Very well, but how about those who have nonstandard view on notion of compactness?
Those can omit xlink:actuate and xlink:show attributes like:
however now it is hard to say how XLink processor will handle link as attributes xlink:actuate and xlink:show have no default values (let's hope that after several years W3C will issue XLink 1.2 that supplies default values) and according to XLink 1.1 WD "the behavior of an application traversing to the ending resource is unconstrained by this specification." So still no joy. Let us leave XXXLink developers alone and see what else can be done.
There are CSS linking extensions used by Opera and Prince formatter that provide flexible control over linking via CSS style sheets. With linking extensions we would be able to use arbitrary markup like
and define behaviour via CSS like
However W3C CSS WG did not standardize them as (allegedly) it does not fit well in general scope of current web standards or maybe because unlike XLink it does not reveal full power of human stupidity.
Thus we are left with XHTML hyperlinks module that in fact can be used in any XML document.
However there still is the price that one have to pay: XHTML namespace declaration must be placed in internal DTD subset (otherwise using namespace prefixes or putting namespace declaration on each link would be inevitable). It looks like
and allows to use XHTML hyperlinks in XML without adding xmlns attribute to each link explicitly, like in old lovely times, before people invented namespaces
Looks much better, but how about those who prefers not to pollute internal DTD subset? Any ideas?
<a href="http://www.w3.org">W3C</a>
to XML page?
I must confess that I know no reasonable answer. Any suggestions?
W3C suggests to use XLink 1.0 and to code our simple link as follows
<a xlink:type="simple" xlink:href="http://www.w3.org" xlink:actuate="onRequest" xlink:show="replace" xmlns:xlink="http://www.w3.org/1999/xlink">W3C</a>
Hard to imagine more awkward solution. The more interesting is that, according to XLink 1.0 recomendation, xlink:type attribute is required (otherwise link is not processed) while xlink:href attribute is optional. For example this is valid XLink 1.0
<a xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink">W3C</a>
and this is invalid one:
<a xlink:href="http://www.w3.org" xmlns:xlink="http://www.w3.org/1999/xlink">W3C</a>
Everything this is so stupid that in a few years even W3C realised that one has to "make XLink easier to use" and released XLink 1.1 WD that "solves" the problem by specifying default value for xlink:type attribute. So in near future when XLink 1.1 will be approved one will be able to use compact markup like
<a xlink:href="http://www.w3.org" xlink:actuate="onRequest" xlink:show="replace" xmlns:xlink="http://www.w3.org/1999/xlink">W3C</a>
Very well, but how about those who have nonstandard view on notion of compactness?
Those can omit xlink:actuate and xlink:show attributes like:
<a xlink:href="http://www.w3.org" xmlns:xlink="http://www.w3.org/1999/xlink">W3C</a>
however now it is hard to say how XLink processor will handle link as attributes xlink:actuate and xlink:show have no default values (let's hope that after several years W3C will issue XLink 1.2 that supplies default values) and according to XLink 1.1 WD "the behavior of an application traversing to the ending resource is unconstrained by this specification." So still no joy. Let us leave XXXLink developers alone and see what else can be done.
There are CSS linking extensions used by Opera and Prince formatter that provide flexible control over linking via CSS style sheets. With linking extensions we would be able to use arbitrary markup like
<go to="http://www.w3.org">W3C</go>
and define behaviour via CSS like
go[to] {prince-link:attr(to)}
However W3C CSS WG did not standardize them as (allegedly) it does not fit well in general scope of current web standards or maybe because unlike XLink it does not reveal full power of human stupidity.
Thus we are left with XHTML hyperlinks module that in fact can be used in any XML document.
However there still is the price that one have to pay: XHTML namespace declaration must be placed in internal DTD subset (otherwise using namespace prefixes or putting namespace declaration on each link would be inevitable). It looks like
<!ATTLIST a xmlns CDATA "http://www.w3.org/1999/xhtml">
and allows to use XHTML hyperlinks in XML without adding xmlns attribute to each link explicitly, like in old lovely times, before people invented namespaces
<a href="http://www.w3.org">W3C</a>
Looks much better, but how about those who prefers not to pollute internal DTD subset? Any ideas?