Ejemplo n.º 1
0
  @Override
  protected void checkItem(OPFItem item, OPFHandler opfHandler) {
    String mimeType = item.getMimeType();
    String fallback = item.getFallback();
    if (mimeType == null || mimeType.equals("")) {
      // report.error(path, item.getLineNumber(), item.getColumnNumber(),
      // "empty media-type attribute");
      return;
    }

    if (!mimeType.matches("[a-zA-Z0-9!#$&+-^_]+/[a-zA-Z0-9!#$&+-^_]+")) {
      // report.error(path, item.getLineNumber(), item.getColumnNumber(),
      // "invalid content for media-type attribute");
      return;
    }

    if ("application/xhtml+xml".equals(mimeType)
        && !"xhtml".equals(Files.getFileExtension(item.getPath()))) {
      report.message(
          MessageId.HTM_014a,
          new MessageLocation(path, item.getLineNumber(), item.getColumnNumber()),
          item.getPath());
    }

    if (fallback != null) {
      OPFItem fallbackItem = opfHandler.getItemById(fallback);
      if (fallbackItem == null) {
        report.message(
            MessageId.OPF_040,
            new MessageLocation(path, item.getLineNumber(), item.getColumnNumber()));
      }
    }
  }
Ejemplo n.º 2
0
  @Override
  protected void checkSpineItem(OPFItem item, OPFHandler opfHandler) {

    String mimeType = item.getMimeType();
    if (mimeType == null) {
      return;
    }

    if (isBlessedItemType(mimeType, version)) {
      return;
    }

    if (item.getFallback() == null) {
      report.message(
          MessageId.OPF_043,
          new MessageLocation(path, item.getLineNumber(), item.getColumnNumber()),
          mimeType);
    } else if (!new FallbackChecker().checkItemFallbacks(item, opfHandler, false)) {
      report.message(
          MessageId.OPF_044,
          new MessageLocation(path, item.getLineNumber(), item.getColumnNumber()),
          mimeType);
    }
  }