XLink 实例
- 上一页 XLink 语法
- 下一页 XPointer 实例
Hayaan natin makapag-aral ng mga pangunahing tagubilin ng XLink sa pamamagitan ng pag-aaral ng isang halimbawa
XML halimbawa na dokumento
Mangyaring tingnan ang sumusunod na XML dokumento, "bookstore.xml" na ginagamit upang ipakita ang mga libro:
<?xml version="1.0" encoding="ISO-8859-1"?> <bookstore xmlns:xlink="http://www.w3.org/1999/xlink"> <book title="Harry Potter"> <description xlink:type="simple" xlink:href="http://book.com/images/HPotter.gif" xlink:show="new"> Sa kanyang panglimang taon sa Hogwarts School of Witchcraft and Siya'y lumalapit ang magikang, ang 15-taong gulang na si Harry Potter ay..... </description> </book> <book title="XQuery Kick Start"> <description xlink:type="simple" xlink:href="http://book.com/images/XQuery.gif" xlink:show="new"> XQuery Kick Start delivers a concise introduction to the XQuery standard...... </description> </book> </bookstore>
在上面的例子中,XLink 文档命名空间被声明于文档的顶部:
xmlns:xlink="http://www.w3.org/1999/xlink"
这意味着文档可访问 XLink 的属性和特性。
xlink:type="simple" 可创建简单的类似 HTML 的链接。您也可以规定更多的复杂的链接(多方向链接),但是目前,我们仅使用简易链接。
xlink:href 属性规定了要链接的 URL,而 xlink:show 属性规定了在何处打开链接。xlink:show="new" 意味着链接(在此例中,是一幅图像)会在新窗口打开。
- 上一页 XLink 语法
- 下一页 XPointer 实例