有人可以解释XHTML5中xml:base属性的用途吗?

are*_*ea1 8 xml html5

我想知道xml:base属性做了什么以及它在XHTML5中的值是什么.并且xml:base属性有任何限制吗?

Wel*_*bog 10

有关的文档xml:base可以在这里找到.它允许重新定义子元素中相对地址使用的基址.

这是该来源的示例,

<?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>
Run Code Online (Sandbox Code Playgroud)

在这种情况下,"What's new"链接指向http://example.org/today/new.xml,即doc元素的xml:base绝对地址加上xlink:href属性的相对地址.

olist元素的xml:base地址重新定义的基地址,使用的域docxml:base,但改变的路径.所以后续链接是相对的http://example.org/hotpicks/.