在我的文档中,nxml模式(通过其包含的XHTML紧凑模式)使用错误Attribute value invalid标记usemap属性的值。
<img src="sample_image.png"
usemap="#sample_image_map"
alt="Sample Image"
border="0" />问题似乎是在#属性值中出现了主要的usemap字符。如果删除#字符,则nxml模式表示该值有效。但是主要的#字符通常被期望在usemap的值中,该值通常用于引用文件中其他地方的map定义。
是nxml模式的错误地引发了usemap值的验证错误吗?
(请注意,我使用的是Emacs 24.2.1和它包含的nxml模式的版本。)
下面是一个完整的XHTML示例,它在W3C验证器上进行验证
<!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>发布于 2014-09-09 15:31:30
这是我的research...other回答的结果,当然欢迎。
在我看来,nxml模式的可能不恰当地将usemap属性映射到IDREF。下面是etc/schemas/xhtml-csismap.rnc (一个放松NG紧凑模式文件)中usemap的定义:
usemap.attlist = attribute usemap { IDREF.datatype }?当我将定义更改为将usemap映射到URI时,nxml模式很高兴:
usemap.attlist = attribute usemap { URI.datatype }?现在,这是一个合法的改变吗?
根据维基百科的说法,XHTML派生自HTML4.01。我在usemap中找不到任何关于XHTML1.0标准的具体指导。但是,HTML 4.01标准确实表明usemap属性是一个URI:
usemap = http://www.w3.org/TR/html401/types.html#type-uri [CT]
此外,标签 at HTMLHelp.com说:
USEMAP属性与客户端图像映射一起使用,以给出映射定义的位置。虽然这个值可能是一个完整的URI--allowing --适用于多个页面的单个映射定义--但许多浏览器只会在同一个文件中找到地图定义,从而有效地将USEMAP值限制为一个片段标识符,例如"# map "。
最后,注意到<img usemap=url>在这个答案中包含了问题有URL值的HTML标记属性的完整列表?。
https://stackoverflow.com/questions/25748582
复制相似问题