{
if(ref.refResource.matches("^[^:/?#]+://.*")
&& !(version == EPUBVersion.VERSION_3 && (ref.type == RT_AUDIO || ref.type == RT_VIDEO)))
{
report.message(MessageId.RSC_006,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource));
}
else if (!ocf.hasEntry(ref.refResource) && !ref.refResource.matches("^[^:/?#]+://.*"))
{
report.message(MessageId.RSC_007,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource));
}
else if (!undeclared.contains(ref.refResource))
{
undeclared.add(ref.refResource);
report.message(MessageId.RSC_008,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource));
}
return;
}
if (ref.fragment == null)
{
switch (ref.type)
{
case RT_SVG_PAINT:
case RT_SVG_CLIP_PATH:
case RT_SVG_SYMBOL:
report.message(MessageId.RSC_015,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource));
break;
case RT_HYPERLINK:
// if mimeType is null, we should have reported an error already
if (res.mimeType != null
&& !OPFChecker.isBlessedItemType(res.mimeType, version)
&& !OPFChecker
.isDeprecatedBlessedItemType(res.mimeType)
&& !res.hasValidItemFallback)
{
report.message(MessageId.RSC_010,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource));
}
if (/* !res.mimeType.equals("font/opentype") && */!res.inSpine)
{
report.message(MessageId.RSC_011,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource));
}
break;
case RT_IMAGE:
// if mimeType is null, we should have reported an error already
if (res.mimeType != null
&& !OPFChecker.isBlessedImageType(res.mimeType)
&& !res.hasValidImageFallback)
{
report.message(MessageId.MED_003,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber),
res.mimeType);
}
break;
case RT_STYLESHEET:
// if mimeType is null, we should have reported an error already
// Implementations are allowed to process any stylesheet
// language they desire; so this is an
// error only if no fallback is available.
// See also:
// https://code.google.com/p/epubcheck/issues/detail?id=244
if (res.mimeType != null
&& !OPFChecker.isBlessedStyleType(res.mimeType)
&& !OPFChecker
.isDeprecatedBlessedStyleType(res.mimeType)
&& !res.hasValidItemFallback)
{
report.message(MessageId.CSS_010,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber),
res.mimeType);
}
break;
}
}
else
{ //if (ref.fragment == null) {
if (ref.fragment.startsWith("epubcfi("))
{
//Issue 150
return;
}
switch (ref.type)
{
case RT_HYPERLINK:
// if mimeType is null, we should have reported an error already
if (res.mimeType != null
&& !OPFChecker.isBlessedItemType(res.mimeType, version)
&& !OPFChecker
.isDeprecatedBlessedItemType(res.mimeType)
&& !res.hasValidItemFallback)
{
report.message(MessageId.RSC_010,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource + "#" + ref.fragment));
}
if (!res.inSpine)
{
report.message(MessageId.RSC_011,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource + "#" + ref.fragment));
}
break;
case RT_IMAGE:
report.message(MessageId.RSC_009,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource + "#" + ref.fragment));
break;
case RT_STYLESHEET:
report.message(MessageId.RSC_013,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource + "#" + ref.fragment));
break;
}
Anchor anchor = res.anchors.get(ref.fragment);
if (anchor == null)
{
report.message(MessageId.RSC_012,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource + "#" + ref.fragment));
}
else
{
switch (ref.type)
{
case RT_SVG_PAINT:
case RT_SVG_CLIP_PATH:
if (anchor.type != ref.type)
{
report.message(MessageId.RSC_014,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource + "#" + ref.fragment));
}
break;
case RT_SVG_SYMBOL:
case RT_HYPERLINK:
if (anchor.type != ref.type && anchor.type != RT_GENERIC)
{
report.message(MessageId.RSC_014,
new MessageLocation(ref.resource, ref.lineNumber, ref.columnNumber, ref.refResource + "#" + ref.fragment));
}
break;
}
}
}