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: improve fallback detection checks #1436

Merged
merged 2 commits into from
Dec 6, 2022

Commits on Nov 27, 2022

  1. refactor: make XMLElement private data a map

    This allows private data to store information for different purposes without risks of conflicts.
    rdeltour committed Nov 27, 2022
    Configuration menu
    Copy the full SHA
    fdf9b22 View commit details
    Browse the repository at this point in the history

Commits on Nov 28, 2022

  1. feat: improve fallback detection check

    This commit 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 in
      content documents. Replaces `MED-001`, `MED-002`, and `CSS-010`
    - `MED-003` now reports when an `img` element child of a `picture` element
      is not a core media type.
    - `MED-001` is suppressed. It was used to report a video `poster` attribute
      did 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 referencing
      foreign resources without fallback. It is now reported as `RSC-032`.
    - `CSS-010` is suppressed. It was used to report references to foreign
      stylesheets with no fallback. It is now reported as `RSC-032`.
    - `OPF_040` is now reported when the `fallback` attribute of a package
      document `item` element does not points to an existing ID. This was
      previously implemented as a Schematron check (`RSC-005`) in EPUB 3.x.
    - `OPF-013` is now a warning. It is reported when a MIME type declared
      inline in content (for instance with an HTML `type` attribute) does
      not match the MIME type declared in the package document.
    
    The code is refactored as follows:
    - the reference/resource registry functionality of the `XRefChecker`
      class is extracted to new top-level classes in the (new) package
      `org.w3c.epubcheck.references`.
      - `Resource` represents a publication resource
      - `ResourceRegistry` is a registry of `Resource` instances
      - `Reference` represents a reference (URL) used anywhere in content
      - `ReferenceRegistry` is a registry of `Reference` instances
      - `XRefChecker` is renamed to `ResourceReferencesChecker`.
      - `ValidationContext` contains optional references to `ResourceRegistry`
        and `ReferenceRegistry`.
      - fallback chain resolution is now done in a new `FallbackChainResolver`
        class, when building `OPFItem` instances from the builders created
        when parsing the package document.
      - `XMLHandler` has convenience methods used to register references
        to the `ReferenceRegistry`.
    
    Fix #1304, Fix #1298.
    rdeltour committed Nov 28, 2022
    Configuration menu
    Copy the full SHA
    545b7f7 View commit details
    Browse the repository at this point in the history