Package com.adobe.epubcheck.messages

Examples of com.adobe.epubcheck.messages.MessageLocation


        AnchorTagHandler h = new AnchorTagHandler();

        ZipEntry entry = epack.getZip().getEntry(fileToParse);
        if (entry == null)
        {
          report.message(MessageId.RSC_001, new MessageLocation(epack.getFileName(), -1, -1), fileToParse);
          continue;
        }

        parser.parseDoc(fileToParse, h);
        Vector<AnchorTagHandler.DocTagContent> v = h.getHrefAttributesValues();

        for (int e = 0; e < v.size(); e++)
        {
          AnchorTagHandler.DocTagContent value = v.elementAt(e);
          searchInsideValue(value, tsd, fileToParse);
          String type = value.getType();
          if ("img".compareToIgnoreCase(type) == 0 || "altimg".compareToIgnoreCase(type) == 0)
          {
            // ensure that this image is in the manifest
            String imageFile = value.getValue();
            if (imageFile.matches("^[^:/?#]+://.*"))
            {
              report.message(MessageId.RSC_006, new MessageLocation(fileToParse, value.getLine(), value.getColumn(), value.getContext()), value.getValue());
              continue;
            }

            imageFile = PathUtil.resolveRelativeReference(fileToParse, imageFile, null);
            int index = imageFile.lastIndexOf("#");
            if (index > 0)
            {
              imageFile = imageFile.substring(0, index);
            }

            ZipEntry imgentry = epack.getZip().getEntry(imageFile);
            if (imgentry == null)
            {
              MessageId id = "img".compareToIgnoreCase(type) == 0 ? MessageId.RSC_001 : MessageId.RSC_018;
              report.message(id, new MessageLocation(fileToParse, value.getLine(), value.getColumn(), value.getContext()), value.getValue());
            }
          }
        }
      }
    }
View Full Code Here


      }
      opfParser.process();
    }
    catch (IOException e)
    {
      report.message(MessageId.PKG_008, new MessageLocation(path, 0, 0), path);
    }
    finally
    {
      try
      {
        if (in != null)
        {
          in.close();
        }
      }
      catch (Exception ignored)
      {
        // eat the error
      }
    }


    int itemCount = opfHandler.getItemCount();
    for (int i = 0; i < itemCount; i++)
    {
      OPFItem item = opfHandler.getItem(i);
     
      // only check Filename CompatiblyEscaped when in "-mode opf"
      // this is when 'xrefChecker' Object is null which is an indicator for single file validation
      // (Had no better possibility in mind since "mode" isn't available in OPFChecker.java)
      //
      // bugfix for issue 239
      if(xrefChecker == null) {
      OCFFilenameChecker.checkCompatiblyEscaped(item.getPath(), report, version);
      }
      checkItem(item, opfHandler);
    }

    int spineItemCount = opfHandler.getSpineItemCount();
    int nonLinearCount = 0;
    for (int i = 0; i < spineItemCount; i++)
    {
      OPFItem item = opfHandler.getSpineItem(i);
      checkSpineItem(item, opfHandler);
      if (!item.getSpineLinear())
      {
        nonLinearCount++;
      }
      report.info(item.getPath(), FeatureEnum.SPINE_INDEX, Integer.toString(i));
    }
    if (nonLinearCount == spineItemCount && spineItemCount > 0)
    {
      //test > 0 to not trigger this when opf is malformed etc
      report.message(MessageId.OPF_033, new MessageLocation(path, -1, -1));
    }

    if (version == EPUBVersion.VERSION_2)
    {
      // check for >1 itemrefs to any given spine item
      // http://code.google.com/p/epubcheck/issues/detail?id=182
      List<OPFItem> seen = new ArrayList<OPFItem>();
      for (int i = 0; i < opfHandler.getSpineItemCount(); i++)
      {
        OPFItem item = opfHandler.getSpineItem(i);
        if (seen.contains(item))
        {
          report.message(MessageId.OPF_034,
              new MessageLocation(path, item.getLineNumber(), item.getLineNumber()),
              item.getId());
        }
        else
        {
          seen.add(item);
View Full Code Here

      Matcher matcher = p.matcher(entry.getValue());
      int position = 0;
      while (matcher.find(position))
      {
        position = matcher.end();
        report.message(messageCode, new MessageLocation(file, entry.getLine(), entry.getColumn(), entry.getValue()));
      }
    }
  }
View Full Code Here

        || isDeprecatedBlessedStyleType(mimeType))
    {
      if (opfHandler.getOpf20PackageFile()
          && mimeType.equals("text/html"))
      {
        report.message(MessageId.OPF_035, new MessageLocation(path, item.getLineNumber(), item.getColumnNumber(), item.getId()));
      }
      else if (opfHandler.getOpf12PackageFile()
          && mimeType.equals("text/html"))
      {
        report.message(MessageId.OPF_038, new MessageLocation(path, item.getLineNumber(), item.getColumnNumber(), item.getId()), mimeType);
      }
      else if (opfHandler.getOpf20PackageFile())
      {
        report.message(MessageId.OPF_037,
            new MessageLocation(path, item.getLineNumber(), item.getColumnNumber(), item.getId()),
            mimeType);
      }
    }
    if (opfHandler.getOpf12PackageFile() && fallback == null)
    {
      if (isBlessedItemType(mimeType, version))
      {
        report.message(MessageId.OPF_038,
            new MessageLocation(path, item.getLineNumber(), item.getColumnNumber(), item.getId()),
            mimeType);
      }
      else if (isBlessedStyleType(mimeType))
      {
        report.message(MessageId.OPF_039,
            new MessageLocation(path, item.getLineNumber(), item.getColumnNumber(), item.getId()),
            mimeType);
      }
    }
    if (fallback != null)
    {
      OPFItem fallbackItem = opfHandler.getItemById(fallback);
      if (fallbackItem == null)
      {
        report.message(MessageId.OPF_040,
            new MessageLocation(path, item.getLineNumber(), item.getColumnNumber(), item.getId()));
      }
    }
   
    String fallbackStyle = item.getFallbackStyle();
    if (fallbackStyle != null)
    {
      OPFItem fallbackStyleItem = opfHandler.getItemById(fallbackStyle);
      if (fallbackStyleItem == null)
      {
        report.message(MessageId.OPF_041,
            new MessageLocation(path, item.getLineNumber(), item.getColumnNumber(), item.getId()));
      }
    }
  }
View Full Code Here

      if (isBlessedStyleType(mimeType)
          || isDeprecatedBlessedStyleType(mimeType)
          || isBlessedImageType(mimeType))
      {
        report.message(MessageId.OPF_042,
            new MessageLocation(path, item.getLineNumber(), item.getColumnNumber()),
            mimeType);
      }
      else if (!isBlessedItemType(mimeType, version)
          && !isDeprecatedBlessedItemType(mimeType)
          && item.getFallback() == null)
      {
        report.message(MessageId.OPF_043,
            new MessageLocation(path, item.getLineNumber(), item.getColumnNumber()),
            mimeType);
      }
      else if (!isBlessedItemType(mimeType, version)
          && !isDeprecatedBlessedItemType(mimeType)
          && !new FallbackChecker().checkItemFallbacks(item, opfHandler, true))
      {
        report.message(MessageId.OPF_044,
            new MessageLocation(path, item.getLineNumber(), item.getColumnNumber()),
            mimeType);
      }
    }
  }
View Full Code Here

      {
        fallback = fallback.trim();
        if (checked.contains(fallback))
        {
          report.message(MessageId.OPF_045,
              new MessageLocation(path, item.getLineNumber(), item.getColumnNumber()));
          return false;
        }
        else
        {
          checked.add(fallback);
View Full Code Here

      {
        fallback = fallback.trim();
        if (checked.contains(fallback))
        {
          report.message(MessageId.OPF_045,
              new MessageLocation(path, item.getLineNumber(), item.getColumnNumber()));
          return false;
        }
        else
        {
          checked.add(fallback);
View Full Code Here

        String fileToParse = epack.getManifestItemFileName(itemEntry);

        ZipEntry entry = epack.getZip().getEntry(fileToParse);
        if (entry == null)
        {
          report.message(MessageId.RSC_001, new MessageLocation(epack.getFileName(), -1, -1), fileToParse);
          continue;
        }

        SpineItem si = spineItems.get(itemEntry.getId());
        boolean itemIsFixedFormat = isGlobalFixed;
View Full Code Here

    {
      Element svgElement = (Element) n.item(i);
      String viewport = svgElement.getAttributeNS(svgNS, "viewBox");
      if (viewport == null || viewport.length() == 0)
      {
        report.message(MessageId.HTM_048, new MessageLocation(svgDocEntry, XmlDocParser.getElementLineNumber(svgElement), XmlDocParser.getElementColumnNumber(svgElement)));
      }
    }
  }
View Full Code Here

      String href = svgElement.getAttributeNS(xlinkNS, "href");
      if (href != null && href.length() > 0)
      {
        if (!href.startsWith("data:image"))
        {
          report.message(MessageId.MED_006, new MessageLocation(svgDocEntry, XmlDocParser.getElementLineNumber(svgElement), XmlDocParser.getElementColumnNumber(svgElement)));
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.adobe.epubcheck.messages.MessageLocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.