0

Generating book.epub in rails and validating book.epub in epubcheck tool. I got many errors, fixed everything except following errors:

ERROR: /book.epub/section.xhtml(14,85): attribute "data-align" not allowed here; expected attribute "dir", "id", "lang", "style", "title" or "xml:lang"

ERROR: /book.epub/section.xhtml(15,8): element "br" not allowed here; expected the element end-tag or element "address", "blockquote", "del", "div", "dl", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "ins", "noscript", "ns:svg", "ol", "p", "pre", "script", "table" or "ul" (with xmlns:ns="http://www.w3.org/2000/svg")

If I open and save the file in sigil editor, div or br related errors getting solved. But I want to solve it without opening it in any of the editors.

Below code is the part of 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>

Help me to solve this. Thanks in advance.

user2138489
  • 69
  • 2
  • 9
  • 1
    Please show the markup that actually triggers these errors. It seems that the validator used just does not allow the HTML5 `data-*` attributes. The second error is probably caused by some major structural error, like trying use `
    ` as a child of `body` when using XHTML 1.1.
    – Jukka K. Korpela Mar 27 '14 at 09:18
  • Updated markup. Kindly check it. Then what I want to do with HTML5 data-* attributes? – user2138489 Mar 27 '14 at 09:26
  • Yes I changed
    tag to
    and that error also solved. data-align attribute error?
    – user2138489 Mar 27 '14 at 09:32

1 Answers1

2

The second error seems to have been solved, though it remains unclear what the problem was (<br/> and <br></br> are equivalent in XHTML).

The first error is simply caused by the data-align attribute, which is not valid in XHTML 1.1. It seems to be used to mark an element that shall be somehow aligned to the middle, via CSS. The fix depends on the CSS code. You should replace whatever CSS rule does the alignment to use a different selector. The most natural approach is to add a class to the element:

  <div style="margin: 0px auto; width: 35%;" class="Middle image_content">

and to replace a selector like [data-align="Middle"] in CSS code by the selector .Middle.

Jukka K. Korpela
  • 178,198
  • 33
  • 241
  • 350