Skip to content

Commit 7ca1edf

Browse files
committed
feat: remove checks related to deprecated bindings feature
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
1 parent 38c87d0 commit 7ca1edf

File tree

26 files changed

+6
-314
lines changed

26 files changed

+6
-314
lines changed

src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ private void initialize()
200200
severities.put(MessageId.OPF_007, Severity.WARNING);
201201
severities.put(MessageId.OPF_007a, Severity.ERROR);
202202
severities.put(MessageId.OPF_007b, Severity.ERROR);
203-
severities.put(MessageId.OPF_008, Severity.ERROR);
204-
severities.put(MessageId.OPF_009, Severity.ERROR);
203+
severities.put(MessageId.OPF_008, Severity.SUPPRESSED);
204+
severities.put(MessageId.OPF_009, Severity.SUPPRESSED);
205205
severities.put(MessageId.OPF_010, Severity.ERROR);
206206
severities.put(MessageId.OPF_011, Severity.ERROR);
207207
severities.put(MessageId.OPF_012, Severity.ERROR);
@@ -236,7 +236,7 @@ private void initialize()
236236
severities.put(MessageId.OPF_043, Severity.ERROR);
237237
severities.put(MessageId.OPF_044, Severity.ERROR);
238238
severities.put(MessageId.OPF_045, Severity.ERROR);
239-
severities.put(MessageId.OPF_046, Severity.ERROR);
239+
severities.put(MessageId.OPF_046, Severity.SUPPRESSED);
240240
severities.put(MessageId.OPF_047, Severity.USAGE);
241241
severities.put(MessageId.OPF_048, Severity.ERROR);
242242
severities.put(MessageId.OPF_049, Severity.ERROR);

src/main/java/com/adobe/epubcheck/opf/OPFChecker.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ protected boolean checkPackage()
129129
}
130130

131131
checkGuide();
132-
checkBindings();
133132

134133
// Check items content (publication resources)
135134
for (OPFItem item : items)
@@ -156,10 +155,6 @@ protected void checkItemAfterResourceValidation(OPFItem item)
156155
{
157156
}
158157

159-
protected void checkBindings()
160-
{
161-
}
162-
163158
protected void checkGuide()
164159
{
165160
int refCount = opfHandler.getReferenceCount();

src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
package com.adobe.epubcheck.opf;
2424

25-
import java.util.Iterator;
2625
import java.util.Set;
2726

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

221-
@Override
222-
protected void checkBindings()
223-
{
224-
Set<String> mimeTypes = context.xrefChecker.get().getBindingsMimeTypes();
225-
Iterator<String> it = mimeTypes.iterator();
226-
String mimeType;
227-
while (it.hasNext())
228-
{
229-
mimeType = it.next();
230-
String handlerId = context.xrefChecker.get().getBindingHandlerId(mimeType);
231-
OPFItem handler = opfHandler.getItemById(handlerId).get();
232-
if (!handler.isScripted())
233-
{
234-
report.message(MessageId.OPF_046, handler.getLocation());
235-
}
236-
}
237-
}
238-
239220
// protected boolean checkItemFallbacks(OPFItem item, OPFHandler opfHandler) {
240221
// String fallback = item.getFallback();
241222
// if (fallback != null) {

src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,6 @@ else if (name.equals("itemref"))
233233
processItemrefProperties(itemBuilder, e.getAttribute("properties"));
234234
}
235235
}
236-
else if (name.equals("mediaType"))
237-
{
238-
processBinding();
239-
}
240236
else if (name.equals("collection"))
241237
{
242238
collectionBuilders.addFirst(
@@ -371,34 +367,6 @@ public ResourceCollections getCollections()
371367
return (collections == null) ? ResourceCollections.builder().build() : collections;
372368
}
373369

374-
private void processBinding()
375-
{
376-
String mimeType = currentElement().getAttribute("media-type");
377-
String handlerId = currentElement().getAttribute("handler");
378-
379-
if ((mimeType != null) && (handlerId != null))
380-
{
381-
if (OPFChecker30.isCoreMediaType(mimeType))
382-
{
383-
report.message(MessageId.OPF_008, location(), mimeType);
384-
return;
385-
}
386-
387-
if (context.xrefChecker.isPresent()
388-
&& context.xrefChecker.get().getBindingHandlerId(mimeType) != null)
389-
{
390-
report.message(MessageId.OPF_009, location(), mimeType,
391-
context.xrefChecker.get().getBindingHandlerId(mimeType));
392-
return;
393-
}
394-
395-
if (itemBuilders.containsKey(handlerId) && context.xrefChecker.isPresent())
396-
{
397-
context.xrefChecker.get().registerBinding(mimeType, handlerId);
398-
}
399-
}
400-
}
401-
402370
private List<String> processCollectionRole(String roleAtt)
403371
{
404372
ImmutableList.Builder<String> rolesBuilder = ImmutableList.builder();

src/main/java/com/adobe/epubcheck/opf/XRefChecker.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import com.adobe.epubcheck.ocf.OCFContainer;
4545
import com.adobe.epubcheck.util.EPUBVersion;
4646
import com.adobe.epubcheck.util.FeatureEnum;
47-
import com.adobe.epubcheck.vocab.PackageVocabs;
4847
import com.google.common.base.Optional;
4948
import com.google.common.base.Preconditions;
5049
import com.google.common.collect.ImmutableSet;
@@ -246,8 +245,6 @@ public boolean isInSpine()
246245

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

249-
private final Map<String, String> bindings = new HashMap<String, String>();
250-
251248
private final Report report;
252249

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

307-
// FIXME 2022 move binding registration to OPFHandler
308-
public Set<String> getBindingsMimeTypes()
309-
{
310-
return bindings.keySet();
311-
}
312-
313-
public String getBindingHandlerId(String mimeType)
314-
{
315-
return bindings.get(mimeType);
316-
}
317-
318-
public void registerBinding(String mimeType, String handlerId)
319-
{
320-
bindings.put(mimeType, handlerId);
321-
}
322-
323304
public void registerResource(URL url, String mimetype)
324305
{
325306
Preconditions.checkArgument(url != null);

src/main/java/com/adobe/epubcheck/ops/OPSHandler30.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -684,12 +684,6 @@ protected void processObject()
684684
{
685685
return;
686686
}
687-
// check bindings
688-
if (xrefChecker.isPresent() && type != null
689-
&& xrefChecker.get().getBindingHandlerId(type) != null)
690-
{
691-
hasValidFallback = true;
692-
}
693687
}
694688
}
695689
}

src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ OPF_006=Invalid prefix declaration: URI "%1$s" is not a valid URI.
186186
OPF_007=Re-declaration of reserved prefix "%1$s".
187187
OPF_007a=Invalid prefix mapping: prefix "_" must not be declared.
188188
OPF_007b=Invalid prefix mapping: default vocabulary "%1$s" must not be re-declared.
189-
OPF_008=Handler binding for core Media-type "%1$s" is not allowed.
190-
OPF_009=The media-type "%1$s" has already been assigned a handler, with ID "%2$s".
189+
OPF_008=
190+
OPF_009=
191191
OPF_010=Error resolving reference: "%1$s".
192192
OPF_011=itemref can’t have both page-spread-right and page-spread-left properties.
193193
OPF_012=Item property "%1$s" is not defined for media type "%2$s".
@@ -224,7 +224,7 @@ OPF_042="%1$s" is not a permissible spine media-type.
224224
OPF_043=Spine item with non-standard media-type "%1$s" has no fallback.
225225
OPF_044=Spine item with non-standard media-type "%1$s" has a fallback to non-standard media-type.
226226
OPF_045=Encountered circular reference in fallback chain.
227-
OPF_046=Scripted property is not set on mediaType handler.
227+
OPF_046=
228228
OPF_047=OPF file is using OEBPS 1.2 syntax allowing backwards compatibility.
229229
OPF_048=Package tag is missing its required unique-identifier attribute and value.
230230
OPF_049=Item id "%1$s" was not found in the manifest.

src/main/resources/com/adobe/epubcheck/schema/30/package-30.sch

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,6 @@
197197
</rule>
198198
</pattern>
199199

200-
<pattern id="opf.bindings.handler">
201-
<rule context="opf:bindings/opf:mediaType">
202-
<let name="ref" value="./normalize-space(@handler)"/>
203-
<let name="item" value="//opf:manifest/opf:item[normalize-space(@id) = $ref]"/>
204-
<let name="item-media-type" value="normalize-space($item/@media-type)"/>
205-
<assert test="$item-media-type = 'application/xhtml+xml'">manifest items referenced from
206-
the handler attribute of a bindings mediaType element must be of the
207-
"application/xhtml+xml" type (given type was "<value-of select="$item-media-type"
208-
/>")</assert>
209-
</rule>
210-
</pattern>
211-
212200
<pattern id="opf.toc.ncx">
213201
<rule context="opf:spine[@toc]">
214202
<let name="ref" value="./normalize-space(@toc)"/>

src/test/resources/epub3/05-package-document/files/bindings-for-image-error.opf

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/test/resources/epub3/05-package-document/files/bindings-handler-not-xhtml-error.opf

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)