Package com.adobe.epubcheck.xml

Examples of com.adobe.epubcheck.xml.XMLParser


    InputStream in = null;
    try
    {
      in = resourceProvider.getInputStream(path);
      opfParser = new XMLParser(ocf, new BufferedInputStream(
          in), path, "opf",
          report, version);
      initHandler();
      opfParser.addXMLHandler(opfHandler);
      for (XMLValidator validator : opfValidators)
View Full Code Here


    InputStream in = null;
    OPSHandler opsHandler;
    try
    {
      in = resourceProvider.getInputStream(path);
      XMLParser opsParser = new XMLParser( ocf,
          in, path, mimeType, report,
          version);

      if (version == EPUBVersion.VERSION_2)
      {
        opsHandler = new OPSHandler(ocf, path, xrefChecker, opsParser, report, version);
      }
      else
      {
        opsHandler = new OPSHandler30(ocf, path, mimeType, properties,
            xrefChecker, opsParser, report, version, pubTypes);
      }

      opsParser.addXMLHandler(opsHandler);
     
      for (XMLValidator validator : validators)
      {
        opsParser.addValidator(validator);
      }

      opsParser.process();
    }
    finally
    {
      try
      {
View Full Code Here

    InputStream in = null;
    OverlayHandler overlayHandler;
    try
    {
      in = resourceProvider.getInputStream(path);
      XMLParser overlayParser = new XMLParser( ocf,
          in, path,
          "application/smil+xml", report, version);
      overlayHandler = new OverlayHandler(path, xrefChecker,
          overlayParser, report);
      overlayParser.addValidator(XMLValidators.MO_30_RNC.get());
      overlayParser.addValidator(XMLValidators.MO_30_SCH.get());
      overlayParser.addXMLHandler(overlayHandler);
      overlayParser.process();
    }
    catch (IOException e)
    {
      report.message(MessageId.RSC_001, new MessageLocation(this.ocf.getName(), -1, -1), path);
    }
View Full Code Here

  }

  boolean validate(EPUBVersion version)
  {
    XMLParser parser;
    InputStream in = null;
    try
    {
      // validate container
      in = ocf.getInputStream(OCFData.containerEntry);
      parser = new XMLParser(ocf, in, OCFData.containerEntry, "xml", getReport(), version);
      XMLHandler handler = new OCFHandler(parser);
      parser.addXMLHandler(handler);
      parser.addValidator(xmlValidatorMap.get(new OPSType(OCFData.containerEntry, version)));
      parser.process();
      try
      {
        if (in != null)
        {
          in.close();
          in = null;
        }
      }
      catch (IOException ignored)
      {
        // eat it
      }

      // Validate encryption.xml
      if (ocf.hasEntry(OCFData.encryptionEntry))
      {
        in = ocf.getInputStream(OCFData.encryptionEntry);
        parser = new XMLParser(ocf, in, OCFData.encryptionEntry, "xml", getReport(), version);
        handler = new EncryptionHandler(ocf, parser);
        parser.addXMLHandler(handler);
        parser.addValidator(xmlValidatorMap.get(new OPSType(OCFData.encryptionEntry, version)));
        parser.process();
        try
        {
          if (in != null)
          {
            in.close();
            in = null;
          }
        }
        catch (IOException ignored)
        {
          // eat it
        }
        getReport().info(null, FeatureEnum.HAS_ENCRYPTION, OCFData.encryptionEntry);
      }

      // validate signatures.xml
      if (ocf.hasEntry(OCFData.signatureEntry))
      {
        in = ocf.getInputStream(OCFData.signatureEntry);
        parser = new XMLParser(ocf, in, OCFData.signatureEntry, "xml", getReport(), version);
        handler = new OCFHandler(parser);
        parser.addXMLHandler(handler);
        parser.addValidator(xmlValidatorMap.get(new OPSType(OCFData.signatureEntry, version)));
        parser.process();
        try
        {
          in.close();
        }
        catch (Exception ignored)
View Full Code Here

    {
      report.message(MessageId.RSC_004, new MessageLocation(this.ocf.getName(), 0, 0), path);
    }
    else
    {
      XMLParser dtbookParser;
      InputStream in = null;
      try
      {
        in = ocf.getInputStream(path);
        dtbookParser = new XMLParser(ocf, in, path,
            "application/x-dtbook+xml", report, version);
        dtbookParser.addValidator(XMLValidators.DTBOOK_RNG.get());
        DTBookHandler dtbookHandler = new DTBookHandler(dtbookParser, path,
            xrefChecker);
        dtbookParser.addXMLHandler(dtbookHandler);
        dtbookParser.process();
      }
      catch (IOException e)
      {
        throw new RuntimeException(e);
      }
View Full Code Here

    int warnings = report.getWarningCount();
    InputStream in = null;
    try
    {
      in = resourceProvider.getInputStream(path);
      XMLParser navParser = new XMLParser(ocf, in, path,
          "application/xhtml+xml", report, version);

      XMLHandler navHandler = new OPSHandler30(ocf, path, mimeType,
          properties, xrefChecker, navParser, report, version, pubTypes);
      navParser.addXMLHandler(navHandler);
      navParser.addValidator(XMLValidators.NAV_30_RNC.get());
      navParser.addValidator(XMLValidators.XHTML_30_SCH.get());
      navParser.addValidator(XMLValidators.NAV_30_SCH.get());
      navParser.process();
    }
    catch (IOException e)
    {
      report.message(MessageId.PKG_008, new MessageLocation(path, -1, -1), path);
    }
View Full Code Here

      report.message(MessageId.RSC_004, new MessageLocation(this.ocf.getName(), 0, 0), path);
    }
    else
    {
      // relaxng
      XMLParser ncxParser;
      NCXHandler ncxHandler;
      InputStream in;
      try
      {
        in = ocf.getInputStream(path);
      }
      catch (IOException e)
      {
        in = null;
      }
      if (in == null)
      {
        return;
      }

      ncxParser = new XMLParser(ocf, in, path, "application/x-dtbncx+xml", report, version);
      ncxParser.addValidator(XMLValidators.NCX_RNG.get());
      ncxHandler = new NCXHandler(ncxParser, path, xrefChecker);
      ncxParser.addXMLHandler(ncxHandler);
      ncxParser.process();
       
        if (ocf.getUniqueIdentifier() != null && !ocf.getUniqueIdentifier().equals(ncxHandler.getUid()))
        {
          report.message(MessageId.NCX_003,
              new MessageLocation(path, ncxParser.getLineNumber(), ncxParser.getColumnNumber(), String.format("%1$s: %2$s", ncxHandler.getUid(), ocf.getUniqueIdentifier())));
        }


      try
      {
        in = ocf.getInputStream(path);
      }
      catch (IOException e)
      {
        in = null;
      }

      if (in != null)
      {
        ncxParser = new XMLParser(ocf, in, path, "application/x-dtbncx+xml", report, version);
        ncxParser.addValidator(XMLValidators.NCX_SCH.get());
        ncxParser.process();
        try
        {
          in.close();
        }
        catch (IOException ignored)
View Full Code Here

TOP

Related Classes of com.adobe.epubcheck.xml.XMLParser

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.