【问题标题】:'nxml-mode' validation error with 'usemap' attribute带有“usemap”属性的“nxml-mode”验证错误
【发布时间】:2014-09-09 15:31:30
【问题描述】:

在我的 XHTML 文档中,nxml-mode(通过其包含的 XHTML Relax NG 紧凑模式)将 usemap 属性的值标记为错误 @ 987654324@.

<img src="sample_image.png"
     usemap="#sample_image_map"
     alt="Sample Image"
     border="0" />

问题似乎是usemap 属性的值中存在前导# 字符。如果我删除 # 字符,nxml-mode 表示该值有效。但是前导 # 字符通常应出现在 usemap 的值中,这通常用于引用文件中其他位置的 map 定义。

nxml-mode 是否在usemap 的值上错误地引发了验证错误?

(请注意,我使用的是 Emacs 24.2.1 及其包含的 nxml-mode 版本。)


这是一个完整的 XHTML 示例,在 the W3C validator 验证:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>nxml-mode Validation Problem</title>
  </head>
  <body>
    <!--  The '#' is OK here. -->
    <a href="#sample_link">Sample Link</a>

    <map id="sample_image_map">
      <area shape="poly" coords="100,0, 200,0, 200,50, 100,50"
            alt="Sample Area"/>
    </map>

    <!--
        * For the value of the 'usemap' attribute, 'nxml-mode'
        * issues the error 'Attribute value invalid'.
        *
        * However, if the '#' is removed from the value
        * '#sample_image_map', 'nxml-mode' indicates the value
        * is valid.
    -->
    <img src="sample_image.png"
         usemap="#sample_image_map"
         alt="Sample Image"
         border="0" />

  </body>
</html>

【问题讨论】:

    标签: xml validation emacs xhtml relaxng


    【解决方案1】:

    [这是我的研究结果...当然欢迎其他答案。]

    在我看来,nxml-mode 可能不正确地将usemap 属性映射到IDREF。这是 etc/schemas/xhtml-csismap.rncRelax NG 紧凑模式文件)中 usemap 的定义:

    usemap.attlist = attribute usemap { IDREF.datatype }?
    

    当我将定义更改为将usemap 映射到URI 时,nxml-mode 很高兴:

    usemap.attlist = attribute usemap { URI.datatype }?
    

    现在,这是一个合法的变化吗?

    根据维基百科,XHTML derives from HTML 4.01。我在XHTML 1.0 standard 中找不到usemap 的任何具体指导。但是,the HTML 4.01 standard 确实表明 usemap 属性是一个 URI:

    usemap = uri [CT]

    此外,HTMLHelp.com 上的HTML 4.01 documentation for the IMG tag 说:

    USEMAP 属性与客户端图像映射一起使用,以提供 地图定义的位置。虽然这个值可能是 full URI--允许将单个地图定义应用于多个 页面——许多浏览器只会在同一个文件中找到地图定义, 有效地将 USEMAP 值限制为片段标识符,例如 “#map”

    最后,请注意在this answer 中包含&lt;img usemap=url&gt; 到问题COMPLETE list of HTML tag attributes which have a URL value?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-11
      • 1970-01-01
      • 2011-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多