feat: improve fallback detection checks #1436
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates fallback-related checks and refactors the code used
for checking references to publication resources.
The following checks are introduced or updated:
RSC-032
(new): reports foreign resources with no fallback used incontent documents. Replaces
MED-001
,MED-002
, andCSS-010
MED-003
now reports when animg
element child of apicture
elementis not a core media type.
MED-001
is suppressed. It was used to report a videoposter
attributedid not reference a core image media type. It is now reported as
RSC-032
.MED-002
is suppressed. It was used to report HTML elements referencingforeign resources without fallback. It is now reported as
RSC-032
.CSS-010
is suppressed. It was used to report references to foreignstylesheets with no fallback. It is now reported as
RSC-032
.OPF_040
is now reported when thefallback
attribute of a packagedocument
item
element does not points to an existing ID. This waspreviously implemented as a Schematron check (
RSC-005
) in EPUB 3.x.OPF-013
is now a warning. It is reported when a MIME type declaredinline in content (for instance with an HTML
type
attribute) doesnot match the MIME type declared in the package document.
The code is refactored as follows:
XRefChecker
class is extracted to new top-level classes in the (new) package
org.w3c.epubcheck.references
.Resource
represents a publication resourceResourceRegistry
is a registry ofResource
instancesReference
represents a reference (URL) used anywhere in contentReferenceRegistry
is a registry ofReference
instancesXRefChecker
is renamed toResourceReferencesChecker
.ValidationContext
contains optional references toResourceRegistry
and
ReferenceRegistry
.FallbackChainResolver
class, when building
OPFItem
instances from the builders createdwhen parsing the package document.
XMLHandler
has convenience methods used to register referencesto the
ReferenceRegistry
.Fix #1304, Fix #1298.