Skip to content

Commit

Permalink
feat: remove checks related to deprecated bindings feature
Browse files Browse the repository at this point in the history
The use of the `bindings` element was already reported as a warning (it is deprecated since EPUB 3.2).
Since it is not necessary to report errors for misuse of a long-deprecated feature, this commit removes the following checks:
- `OPF-008` (was reported for handler binding to a core media type)
- `OPF-009` (was reported when a media type was assigned multilpe handlers)
- `OPF-046` (was reported when a media type hander was not declared as scripted)
- a schema warning (`RSC-017`) reported when a handler was not XHTML

See also #881
  • Loading branch information
rdeltour committed Nov 27, 2022
1 parent 38c87d0 commit 7ca1edf
Show file tree
Hide file tree
Showing 26 changed files with 6 additions and 314 deletions.
Expand Up @@ -200,8 +200,8 @@ private void initialize()
severities.put(MessageId.OPF_007, Severity.WARNING);
severities.put(MessageId.OPF_007a, Severity.ERROR);
severities.put(MessageId.OPF_007b, Severity.ERROR);
severities.put(MessageId.OPF_008, Severity.ERROR);
severities.put(MessageId.OPF_009, Severity.ERROR);
severities.put(MessageId.OPF_008, Severity.SUPPRESSED);
severities.put(MessageId.OPF_009, Severity.SUPPRESSED);
severities.put(MessageId.OPF_010, Severity.ERROR);
severities.put(MessageId.OPF_011, Severity.ERROR);
severities.put(MessageId.OPF_012, Severity.ERROR);
Expand Down Expand Up @@ -236,7 +236,7 @@ private void initialize()
severities.put(MessageId.OPF_043, Severity.ERROR);
severities.put(MessageId.OPF_044, Severity.ERROR);
severities.put(MessageId.OPF_045, Severity.ERROR);
severities.put(MessageId.OPF_046, Severity.ERROR);
severities.put(MessageId.OPF_046, Severity.SUPPRESSED);
severities.put(MessageId.OPF_047, Severity.USAGE);
severities.put(MessageId.OPF_048, Severity.ERROR);
severities.put(MessageId.OPF_049, Severity.ERROR);
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/adobe/epubcheck/opf/OPFChecker.java
Expand Up @@ -129,7 +129,6 @@ protected boolean checkPackage()
}

checkGuide();
checkBindings();

// Check items content (publication resources)
for (OPFItem item : items)
Expand All @@ -156,10 +155,6 @@ protected void checkItemAfterResourceValidation(OPFItem item)
{
}

protected void checkBindings()
{
}

protected void checkGuide()
{
int refCount = opfHandler.getReferenceCount();
Expand Down
19 changes: 0 additions & 19 deletions src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java
Expand Up @@ -22,7 +22,6 @@

package com.adobe.epubcheck.opf;

import java.util.Iterator;
import java.util.Set;

import org.w3c.epubcheck.url.URLFragment;
Expand Down Expand Up @@ -218,24 +217,6 @@ else if (!new FallbackChecker().checkItemFallbacks(item, opfHandler, false))
}
}

@Override
protected void checkBindings()
{
Set<String> mimeTypes = context.xrefChecker.get().getBindingsMimeTypes();
Iterator<String> it = mimeTypes.iterator();
String mimeType;
while (it.hasNext())
{
mimeType = it.next();
String handlerId = context.xrefChecker.get().getBindingHandlerId(mimeType);
OPFItem handler = opfHandler.getItemById(handlerId).get();
if (!handler.isScripted())
{
report.message(MessageId.OPF_046, handler.getLocation());
}
}
}

// protected boolean checkItemFallbacks(OPFItem item, OPFHandler opfHandler) {
// String fallback = item.getFallback();
// if (fallback != null) {
Expand Down
32 changes: 0 additions & 32 deletions src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java
Expand Up @@ -233,10 +233,6 @@ else if (name.equals("itemref"))
processItemrefProperties(itemBuilder, e.getAttribute("properties"));
}
}
else if (name.equals("mediaType"))
{
processBinding();
}
else if (name.equals("collection"))
{
collectionBuilders.addFirst(
Expand Down Expand Up @@ -371,34 +367,6 @@ public ResourceCollections getCollections()
return (collections == null) ? ResourceCollections.builder().build() : collections;
}

private void processBinding()
{
String mimeType = currentElement().getAttribute("media-type");
String handlerId = currentElement().getAttribute("handler");

if ((mimeType != null) && (handlerId != null))
{
if (OPFChecker30.isCoreMediaType(mimeType))
{
report.message(MessageId.OPF_008, location(), mimeType);
return;
}

if (context.xrefChecker.isPresent()
&& context.xrefChecker.get().getBindingHandlerId(mimeType) != null)
{
report.message(MessageId.OPF_009, location(), mimeType,
context.xrefChecker.get().getBindingHandlerId(mimeType));
return;
}

if (itemBuilders.containsKey(handlerId) && context.xrefChecker.isPresent())
{
context.xrefChecker.get().registerBinding(mimeType, handlerId);
}
}
}

private List<String> processCollectionRole(String roleAtt)
{
ImmutableList.Builder<String> rolesBuilder = ImmutableList.builder();
Expand Down
19 changes: 0 additions & 19 deletions src/main/java/com/adobe/epubcheck/opf/XRefChecker.java
Expand Up @@ -44,7 +44,6 @@
import com.adobe.epubcheck.ocf.OCFContainer;
import com.adobe.epubcheck.util.EPUBVersion;
import com.adobe.epubcheck.util.FeatureEnum;
import com.adobe.epubcheck.vocab.PackageVocabs;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -246,8 +245,6 @@ public boolean isInSpine()

private final List<URLReference> references = new LinkedList<URLReference>();

private final Map<String, String> bindings = new HashMap<String, String>();

private final Report report;

private final OCFContainer container;
Expand Down Expand Up @@ -304,22 +301,6 @@ public Set<Type> getTypes(URL resource)
return types.build();
}

// FIXME 2022 move binding registration to OPFHandler
public Set<String> getBindingsMimeTypes()
{
return bindings.keySet();
}

public String getBindingHandlerId(String mimeType)
{
return bindings.get(mimeType);
}

public void registerBinding(String mimeType, String handlerId)
{
bindings.put(mimeType, handlerId);
}

public void registerResource(URL url, String mimetype)
{
Preconditions.checkArgument(url != null);
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/com/adobe/epubcheck/ops/OPSHandler30.java
Expand Up @@ -684,12 +684,6 @@ protected void processObject()
{
return;
}
// check bindings
if (xrefChecker.isPresent() && type != null
&& xrefChecker.get().getBindingHandlerId(type) != null)
{
hasValidFallback = true;
}
}
}
}
Expand Down
Expand Up @@ -186,8 +186,8 @@ OPF_006=Invalid prefix declaration: URI "%1$s" is not a valid URI.
OPF_007=Re-declaration of reserved prefix "%1$s".
OPF_007a=Invalid prefix mapping: prefix "_" must not be declared.
OPF_007b=Invalid prefix mapping: default vocabulary "%1$s" must not be re-declared.
OPF_008=Handler binding for core Media-type "%1$s" is not allowed.
OPF_009=The media-type "%1$s" has already been assigned a handler, with ID "%2$s".
OPF_008=
OPF_009=
OPF_010=Error resolving reference: "%1$s".
OPF_011=itemref can’t have both page-spread-right and page-spread-left properties.
OPF_012=Item property "%1$s" is not defined for media type "%2$s".
Expand Down Expand Up @@ -224,7 +224,7 @@ OPF_042="%1$s" is not a permissible spine media-type.
OPF_043=Spine item with non-standard media-type "%1$s" has no fallback.
OPF_044=Spine item with non-standard media-type "%1$s" has a fallback to non-standard media-type.
OPF_045=Encountered circular reference in fallback chain.
OPF_046=Scripted property is not set on mediaType handler.
OPF_046=
OPF_047=OPF file is using OEBPS 1.2 syntax allowing backwards compatibility.
OPF_048=Package tag is missing its required unique-identifier attribute and value.
OPF_049=Item id "%1$s" was not found in the manifest.
Expand Down
12 changes: 0 additions & 12 deletions src/main/resources/com/adobe/epubcheck/schema/30/package-30.sch
Expand Up @@ -197,18 +197,6 @@
</rule>
</pattern>

<pattern id="opf.bindings.handler">
<rule context="opf:bindings/opf:mediaType">
<let name="ref" value="./normalize-space(@handler)"/>
<let name="item" value="//opf:manifest/opf:item[normalize-space(@id) = $ref]"/>
<let name="item-media-type" value="normalize-space($item/@media-type)"/>
<assert test="$item-media-type = 'application/xhtml+xml'">manifest items referenced from
the handler attribute of a bindings mediaType element must be of the
"application/xhtml+xml" type (given type was "<value-of select="$item-media-type"
/>")</assert>
</rule>
</pattern>

<pattern id="opf.toc.ncx">
<rule context="opf:spine[@toc]">
<let name="ref" value="./normalize-space(@toc)"/>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 7ca1edf

Please sign in to comment.