Chapter 7
XLink: Creating Links in XML
Examples
- Example 7-2
- Example 7-3
- Example 7-4
- Example 7-5
- Example 7-6
- Example 7-7
- Example 7-8
- Download all chapter 7 code (chapter7.zip)
XLink is a way to create links in XML; it is much more powerful than linking in HTML. XLink can create links that have multiple starting points and multiple ending points. It can even define links that have both starting and ending points in a different location then the XLink code itself. A simple example:
<contactLink xlink:type="simple" xlink:href="contact.xml"> Contact us! </contactLink>
A more complicated example:
<drugLink xlink:type="extended"> <!-- two local resources --> <chemName xlink:type="resource" xlink:label="chemicalName"> hydrachloroniametahexacyocaine </chemName> <marName xlink:type="resource" xlink:label="marketName"> BreatheEasy </marName> <!-- two remote resources --> <effects xlink:type="locator" xlink:href="http://www.shelleybio.com/effects" xlink:label="effects" /> <sideEffect xlink:type="locator" xlink:href="http://www.shelleybio.com/sides" xlink:label="sideEffects" /> <!-- three traversals --> <link1 xlink:type="arc" xlink:from="chemicalName" xlink:to="effects" xlink:show="replace" xlink:actuate="onRequest" /> <link2 xlink:type="arc" xlink:from="marketName" xlink:to="effects" xlink:show="replace" xlink:actuate="onRequest" /> <link3 xlink:type="arc" xlink:from="chemicalName" xlink:to="sideEffects" xlink:show="replace" xlink:actuate="onRequest" /> </drugLink>