XLink Example
- Previous Page XLink Syntax
- Next Page XPointer Example
让我们通过研究一个实例来学习一些基础的 XLink 语法
XML 实例文档
请看下面的 XML 文档,"bookstore.xml",它用来呈现书籍:
<?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"> 在他上霍格沃茨魔法学校的第五年时, 巫术临近,15岁的哈利·波特...... </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>
View the "bookstore.xml" file in your browser
In the above example, the XLink document namespace is declared at the top of the document:
xmlns:xlink="http://www.w3.org/1999/xlink"
This means that the document is accessible to the attributes and features of XLink.
xlink:type="simple" can create simple links similar to HTML. You can also specify more complex links (multi-directional links), but currently, we only use simple links.
The xlink:href attribute specifies the URL to be linked, while the xlink:show attribute specifies where the link should be opened. xlink:show="new" means that the link (in this case, an image) will open in a new window.
- Previous Page XLink Syntax
- Next Page XPointer Example