有人可以解释XHTML5中xml:base属性的用途吗? [英] Can someone explain what the xml:base attribute is used for in XHTML5?
问题描述
我想知道xml:base属性做了什么以及它在XHTML5中的值是什么。并且xml:base属性是否有任何限制?
I was wondering what does the xml:base attribute do and what are it's values in XHTML5. and does the xml:base attribute have any restrictions?
推荐答案
xml:base的文档
可以在这里找到。它允许重新定义子元素中相对地址使用的基址。
Documentation for the xml:base
can be found here. It allows a redefinition of the base address used by relative addresses in child elements.
这是该源的示例,
<?xml version="1.0"?>
<doc xml:base="http://example.org/today/"
xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
<title>Virtual Library</title>
</head>
<body>
<paragraph>See <link xlink:type="simple" xlink:href="new.xml">what's
new</link>!</paragraph>
<paragraph>Check out the hot picks of the day!</paragraph>
<olist xml:base="/hotpicks/">
<item>
<link xlink:type="simple" xlink:href="pick1.xml">Hot Pick #1</link>
</item>
<item>
<link xlink:type="simple" xlink:href="pick2.xml">Hot Pick #2</link>
</item>
<item>
<link xlink:type="simple" xlink:href="pick3.xml">Hot Pick #3</link>
</item>
</olist>
</body>
</doc>
在这种情况下,What's new链接指向 http:// example.org/today/new.xml
,这是 doc
元素的 xml:base
绝对地址加上 xlink:href
属性的相对地址。
In this case the "What's new" link points to http://example.org/today/new.xml
, which is the doc
element's xml:base
absolute address plus the xlink:href
attribute's relative address.
olist
元素的 xml:base
地址使用 doc
的域<$重新定义基址c $ c> xml:base 但更改路径。所以后续链接是相对于 http://example.org/hotpicks/
。
The olist
element's xml:base
address redefines the base address, using the domain of doc
's xml:base
but changing the path. So the subsequent links are relative to http://example.org/hotpicks/
.
这篇关于有人可以解释XHTML5中xml:base属性的用途吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!