Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make SVG content conformance checking informative-only #1365

Merged
merged 3 commits into from
Dec 1, 2022

Conversation

rdeltour
Copy link
Member

@rdeltour rdeltour commented Dec 1, 2022

EPUB 3.3 no longer requires that SVG content conforms to SVG content model requirements,
only that they are well-formed, that ID are uniques, and that they respect some additional
EPUB-specific requirements.

This PR:
* introduces a new permissive RelaxNG schema for SVG, checking only the EPUB-specific
requirements on the title and foreignObject content model
see w3c/epub-specs#1323
* removes checks on the value of the requiredExtensions attribute of foreignObject
see w3c/epub-specs#1087
* adapts the main XHTML to SVG schema driver to the new permissive SVG schema
* adds various tests for EPUB-specific requirements

The PR also introduces two new codes, RSC-024 and RSC-025, to report informative schema checks.

An XMLValidator instance can now be instantiated with a boolean flag to tell if the unerlying schema is normative or not.

If a schema is not normative, the XMLParser uses an informative-only ErrorHandler, that reports warnings as RSC-024 (USAGE), and errors as RSC-025 (USAGE).
Fatal errors are still reported as RSC-016 (FATAL).

SVG schema-based content conformance checking is made informative only:
* new NVDL and RelaxNG schema drivers will only check SVG content, and ignore other
namespaces.
* these informative schemas are enabled for both SVG and XHTML Content Documents
* SVG content conformance, as before, is using RelaxNG schemas from the Nu HTML Checker.

EPUB 3.3 no longer requires that SVG content conforms to SVG content model requirements,
only that they are well-formed, that ID are uniques, and that they respect some additional
EPUB-specific requirements.

This commit:
  * introduces a new permissive RelaxNG schema for SVG, checking only the EPUB-specific
    requirements on the `title` and `foreignObject` content model
    see w3c/epub-specs#1323
  * removes checks on the value of the `requiredExtensions` attribute of `foreignObject`
    see w3c/epub-specs#1087
  * adapts the main XHTML to SVG schema driver to the new permissive SVG schema
  * adds various tests for EPUB-specific requirements
…RSC-025)

An `XMLValidator` instance can now be instantiated with a boolean
flag to tell if the unerlying schema is normative or not.

If a schema is not normative, the `XMLParser` uses an informative-only `ErrorHandler`,
that reports warnings as "RSC-024" (USAGE), and errors as "RSC-025" (USAGE).
Fatal errors are still reported as "RSC-016" (FATAL).
This commit re-enables SVG content conformance checking:
  * new NVDL and RelaxNG schema drivers will only check SVG content, and ignore other
    namespaces.
  * these informative schemas are enabled for both SVG and XHTML Content Documents
  * SVG content conformance, as before, is using RelaxNG schemas from the Nu HTML Checker.
@rdeltour rdeltour added this to the v5.0.0-beta milestone Dec 1, 2022
@rdeltour rdeltour requested a review from mattgarrish December 1, 2022 10:28
@rdeltour rdeltour self-assigned this Dec 1, 2022
@mattgarrish
Copy link
Member

mattgarrish commented Dec 1, 2022

In general this looks great, but why are the following messages being emitted for every SVG document:

USAGE(HTM-010): .\30\sous-le-vent_svg-in-spine.epub/EPUB/Content/pageNum-1.svg(3,186): Namespace uri "http://www.w3.org/2000/svg" was found.

Looking at the source, I believe it comes from this:

   if (!isExpectedNamespace(uri))
    {
      report.message(MessageId.HTM_010,  location, uri);
    }

But wouldn't the svg namespace be expected on an svg document?

It seems to report every namespace declared, as I also get the same message for the xlink namespace when xmlns:xlink="" is declared.

@rdeltour
Copy link
Member Author

rdeltour commented Dec 1, 2022

That's no longer the case in v5.0.0-beta-3, it will be removed in 2c429d0 (big URL refactoring)

Base automatically changed from feat/pakcage-dir-auto to release/v5.0.0 December 1, 2022 21:38
@rdeltour rdeltour merged commit b99b0c5 into release/v5.0.0 Dec 1, 2022
@rdeltour rdeltour deleted the feat/svg-informative branch December 1, 2022 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants