Examples of DocumentValidator


Examples of com.adobe.epubcheck.opf.DocumentValidator

          Messages.get("mode_version_not_supported"), mode, version));

      throw new RuntimeException(String.format(Messages.get("mode_version_not_supported"), mode, version));
    }

    DocumentValidator check = factory.newInstance(report, path,
        resourceProvider, modeMimeTypeMap.get(opsType),
        version);
    if (check.getClass() == EpubCheck.class)
    {
      int validationResult = ((EpubCheck)check).doValidate();
      if (validationResult == 0)
      {
        outWriter.println(Messages.get("no_errors__or_warnings"));
        return 0;
      }
      else if (validationResult == 1)
      {
        System.err.println(Messages.get("there_were_warnings"));
        return failOnWarnings ? 1 : 0;
      }
      System.err.println(Messages.get("there_were_errors"));
      return 1;
    }
    else
    {
      if (check.validate())
      {
        outWriter.println(Messages.get("no_errors__or_warnings"));
        return 0;
      }
      System.err.println(Messages.get("there_were_errors"));
View Full Code Here

Examples of com.adobe.epubcheck.opf.DocumentValidator

          Messages.get("mode_version_not_supported"), mode, version));

      throw new RuntimeException(String.format(Messages.get("mode_version_not_supported"), mode, version));
    }

    DocumentValidator check = factory.newInstance(report, path,
        resourceProvider, modeMimeTypeMap.get(opsType),
        version);

    if (check.validate())
    {
      outWriter.println(Messages.get("no_errors__or_warnings"));
      return 0;
    }
    System.err.println(Messages.get("there_were_errors"));
View Full Code Here

Examples of com.adobe.epubcheck.opf.DocumentValidator

  }
  static ValidationReport savedReport;

  public void testValidateDocument(String fileName, List<MessageId> errors, List<MessageId> warnings, List<MessageId> fatalErrors, String resultFile, boolean verbose)
  {
    DocumentValidator epubCheck;
    outWriter.printf("Starting testValidateDocument('%s')\n", fileName);
    ValidationReport testReport;
    if (fileName.startsWith("http://") || fileName.startsWith("https://"))
    {
      GenericResourceProvider resourceProvider = new URLResourceProvider(fileName);
      try
      {
        testReport = savedReport = new ValidationReport(fileName);
        epubCheck = new EpubCheck(
            resourceProvider.getInputStream(null), testReport, fileName);
      }
      catch (IOException e)
      {
        throw new RuntimeException(e);
      }
    }
    else
    {
      File testFile;
      try
      {
        URL url = this.getClass().getResource(basepath + fileName);
        URI uri = url.toURI();
        testFile = new File(uri);
      }
      catch (URISyntaxException e)
      {
        throw new IllegalStateException("Cannot find test file", e);
      }
      if (testFile.isDirectory())
      {
        Archive epub = new Archive(testFile.getPath());
        testReport = savedReport = new ValidationReport(epub.getEpubName());
        epub.createArchive();
        epubCheck = new EpubCheck(epub.getEpubFile(), testReport);
      }
      else
      {
        testReport = savedReport = new ValidationReport(fileName);
        epubCheck = new EpubCheck(new File(testFile.getPath()), testReport);
      }
    }


    epubCheck.validate();

    if (verbose)
    {
      outWriter.println(testReport);
    }
View Full Code Here

Examples of com.volantis.mcs.xml.schema.validation.DocumentValidator

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        DocumentValidator validator = new DocumentValidatorImpl(
                compiledSchemaMock);

        validator.open(elementType);
        assertTrue(validator.pcdata(false));
        assertTrue(validator.pcdata(false));
        assertTrue(validator.pcdata(false));
        validator.close(elementType);
    }
View Full Code Here

Examples of com.volantis.mcs.xml.schema.validation.DocumentValidator

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        DocumentValidator validator = new DocumentValidatorImpl(
                compiledSchemaMock);

        validator.open(elementType);
        assertTrue(validator.pcdata(true));
        assertTrue(validator.pcdata(true));
        assertTrue(validator.pcdata(true));
        validator.close(elementType);
    }
View Full Code Here

Examples of com.volantis.mcs.xml.schema.validation.DocumentValidator

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        DocumentValidator validator = new DocumentValidatorImpl(
                compiledSchemaMock);

        validator.open(elementType);
        assertFalse(validator.pcdata(true));
        assertFalse(validator.pcdata(true));
        assertFalse(validator.pcdata(true));
        validator.close(elementType);
    }
View Full Code Here

Examples of com.volantis.mcs.xml.schema.validation.DocumentValidator

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        DocumentValidator validator = new DocumentValidatorImpl(
                compiledSchemaMock);

        validator.open(elementType);
        assertFalse(validator.pcdata(true));
        try {
            validator.pcdata(false);
        } catch (ValidationException e) {
            assertEquals("PCDATA not allowed", e.getMessage());
        }
        validator.close(elementType);
    }
View Full Code Here

Examples of com.volantis.mcs.xml.schema.validation.DocumentValidator

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        DocumentValidator validator = new DocumentValidatorImpl(
                compiledSchemaMock);


        validator.open(elementType);
        {
            // Content is not whitespace so must be valid and will be consumed.
            assertTrue(validator.pcdata(false));

            validator.open(elementType);
            {
                // Content is whitespace and is not valid and so won't be
                // consumed.
                assertFalse(validator.pcdata(true));
            }
            validator.close(elementType);
        }
        validator.close(elementType);
    }
View Full Code Here

Examples of com.volantis.mcs.xml.schema.validation.DocumentValidator

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        DocumentValidator validator = new DocumentValidatorImpl(
                compiledSchemaMock);

        validator.open(elementType);
        {
            validator.open(elementType);
            {
                // Content is not whitespace so must be valid and will be
                // consumed.
                assertTrue(validator.pcdata(false));
            }
            validator.close(elementType);

            // Content is whitespace and is not valid and so won't be consumed.
            assertFalse(validator.pcdata(true));
        }
        validator.close(elementType);
    }
View Full Code Here

Examples of com.volantis.mcs.xml.schema.validation.DocumentValidator

    }

    protected void runThroughValidator(List elements)
            throws ValidationException {
       
        DocumentValidator validator = xdimeContext.getDocumentValidator();
        Iterator i = elements.iterator();
        while(i.hasNext()) {
            ElementType element = (ElementType)i.next();
            validator.open(element);
            validator.close(element);  
        }           
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.