daisy / ace

Ace by DAISY, an Accessibility Checker for EPUB
MIT License
74 stars 22 forks source link

EPUB2 can't satisfy package language requirement #376

Open bswest opened 2 years ago

bswest commented 2 years ago

With 1.2.7, it looks like it's now impossible to create an EPUB2 file that can satisfy both ace and epubcheck.

1.2.7 raises an issue if language isn't declared in the package declaration (see #371).

But epubcheck doesn't allow this in EPUB2. If I try to include xml:lang in the package declaration of an EPUB2 file, epubcheck raises an error:

ERROR(RSC-005): File.epub/OEBPS/content.opf(1,102): Error while parsing file: attribute "xml:lang" not allowed here; expected attribute "id", "unique-identifier" or "version"

Should the language requirement only apply to EPUB3?

danielweck commented 2 years ago

That's a good point, I'm not sure what the answer is. @rdeltour @mattgarrish do you know if EPUB2 package.opf supports xml:lang?

On a general note: Ace doesn't handle EPUB2 properly yet. From the top of my head: NCX parsing is missing IIRC ... but there may be other compatibility gaps (there is an issue in this GitHub tracker about this already).

danielweck commented 2 years ago

EPUB2 incomplete support: https://github.com/daisy/ace/issues/21

bswest commented 2 years ago

OK, that's good to know about EPUB2 gaps. While we've primarily used ace with EPUB3, we have historically run EPUB2 files through ace as well, just to ensure they're as good as they can be (within EPUB2 limitations). We'll keep in mind that EPUB2 files may be under-checked, but it would still be nice to check what we can. Thanks.

mattgarrish commented 2 years ago

You can't make a language declaration on the package element in EPUB 2, but you can declare it on all the metadata elements. That would be the ideal equivalent. Is Ace checking that a language is in scope for each metadata element, or only checking that it's declared on the package root?

Changilainen commented 8 months ago

I have recently encountered this same problem (https://github.com/w3c/epubcheck/issues/1553) and hope this will be fixed asap so ACE wouldn't give false errors.

msgannon commented 3 months ago

I have the same problem. I DID add it to the metadata elements. For some of the elements Epub Checker didn't like it, so removed those. ACE didn't pick up that it was on the individual elements. I've decided to leave it in the package tag and see if anyone complains...

msgannon commented 3 months ago

Epub 2 booted out with lang in the package element so just including it in the individual ones.

gregoriopellegrino commented 2 months ago

Thank you for your work on ACE. As the original reporter mentioned, specifying the xml:lang attribute on each individual metadata element should satisfy the language requirement, even if it's not on the parent package or metadata element. For example:

<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
    <meta xml:lang="it" name="generator" content="Adobe InDesign 19.3" />
    <meta name="cover" content="copertina.jpg" />
    <dc:title xml:lang="it">Il mio libro</dc:title>
    <dc:creator xml:lang="it">Gregorio Pellegrino</dc:creator>
    <dc:publisher xml:lang="it">Fondazione LIA</dc:publisher>
    <dc:date>2024</dc:date>
    <dc:rights xml:lang="it">© Fondazione LIA</dc:rights>
    <dc:language>it-IT</dc:language>
    <dc:identifier id="bookid">9788800000000</dc:identifier>
</metadata>

With this metadata, Ace still reports an error. It seems that Ace only checks if the xml:lang attribute is present on package or metadata, but not on individual elements.

Would it be possible to update ACE to check where the xml:lang attribute for each metadata supporting it (taking into account the inheritance system)? This would unblock the affected workflows and should work both with EPUB 2 and EPUB 3. Providing this flexibility for EPUB 2, especially as the transition to EPUB 3 is ongoing, would be greatly appreciated.

Thank you for considering this request. I'm happy to provide any additional details or test files that could help reproduce and resolve this issue.

Do you have a timeline for this development? It is blocking some workflows for us.