验证epubcheck中的epub时出错
在rails中生成book.epub并验证epubcheck工具中的book.epub。我收到了很多错误,修复了除了以下错误之外的所有内容:
错误:/book.epub/section.xhtml(14,85):此处不允许使用属性“data-align”;预期属性“dir”,“id”,“lang”,“style”,“title”或“xml:lang”
错误:/book.epub/section.xhtml(15,8):element“br”这里不允许;预期元素结束标记或元素“address”,“blockquote”,“del”,“div”,“dl”,“h1”,“h2”,“h3”,“h4”,“h5”,“h6 “,”hr“,”ins“,”noscript“,”ns:svg“,”ol“,”p“,”pre“,”脚本“,”表“或”ul“(带有xmlns:ns = http://www.w3.org/2000/svg“)验证epubcheck中的epub时出错
如果我打开并保存在sigil编辑器中的文件,div或br相关的错误得到解决。但是我想要解决它而不需要在任何编辑中打开它。
下面的代码是XHTML的部分:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>File 1: H1</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="stylesheet.css" type="text/css" rel="stylesheet"/>
<link href="page_styles.css" type="text/css" rel="stylesheet"/>
</head>
<body class="publitory">
<h1 id="File_1_5008715178345834">H1</h1>
<h2 id="File_1_1188526892007714">H2</h2>
<h3 id="File_1_4556759710045751">H3</h3>
<h4 id="File_1_6171405939859093">H4</h4>
<h2 id="File_1_410970362765287">H2</h2>
<p>
<div style="margin: 0px auto; width: 35%;" data-align="Middle" class="image_content">
<img src="bookf779ea3e8163a8345602bc3e0c2ce04d9bffb24d.jpeg" width="100%" alt="Book Content Book Content Book Content Book Content Book Content Book Content Book Content Book Content "/>
<div class="caption" style="clear:both;">Book Content Book Content Book Content Book Content Book Content Book Content Book Content Book Content</div>
</div>
</p>
<p>
<br/>
</p>
<h3 id="File_1_3792181513523657">H3</h3>
</body>
</html>
帮我解决这个问题。提前致谢。
第二个错误似乎已经解决了,但它仍然不清楚问题是什么(<br/>
和<br></br>
在XHTML中是等效的)。
第一个错误仅仅是由于data-align
属性造成的,该属性在XHTML 1.1中无效。它似乎被用来标记一个元素,它应该通过CSS以某种方式与中间对齐。修复取决于CSS代码。您应该替换任何CSS规则,以使用不同的选择器。最自然的方法是添加一个类的元素:
<div style="margin: 0px auto; width: 35%;" class="Middle image_content">
,并通过选择.Middle
在CSS代码替换选择像[data-align="Middle"]
。
请显示实际触发这些错误的标记。看起来使用的验证器不支持HTML5'data- *'属性。第二个错误可能是由于一些主要的结构性错误导致的,例如在使用XHTML 1.1时尝试使用'
'作为'body'的子项。 –
更新的标记。请检查它。那么我想用HTML5 data- *属性来做什么呢? – user2138489
是的,我将
标记更改为
并且该错误也解决了。数据对齐属性错误? – user2138489