Examples of ValidationReport


Examples of com.adobe.epubcheck.util.ValidationReport

    return testPropertyList(value, vocabs, false);
  }

  private Set<Property> testPropertyList(String value, Map<String, Vocab> vocabs, boolean verbose)
  {
    ValidationReport testReport = new ValidationReport(VocabTest.class.getSimpleName());

    Set<Property> props = VocabUtil.parsePropertyList(value, vocabs, testReport, loc);

    if (verbose)
    {
      outWriter.println(testReport);
    }

    assertEquals("The error results do not match", expectedErrors, testReport.getErrorIds());
    assertEquals("The warning results do not match", expectedWarnings, testReport.getWarningIds());
    assertEquals("The fatal error results do not match", expectedFatalErrors,
        testReport.getFatalErrorIds());

    return props;
  }
View Full Code Here

Examples of com.adobe.epubcheck.util.ValidationReport

    return testProperty(value, vocabs, false);
  }

  private Optional<Property> testProperty(String value, Map<String, Vocab> vocabs, boolean verbose)
  {
    ValidationReport testReport = new ValidationReport(VocabTest.class.getSimpleName());

    Optional<Property> prop = VocabUtil.parseProperty(value, vocabs, testReport, loc);

    if (verbose)
    {
      outWriter.println(testReport);
    }

    assertEquals("The error results do not match", expectedErrors, testReport.getErrorIds());
    assertEquals("The warning results do not match", expectedWarnings, testReport.getWarningIds());
    assertEquals("The fatal error results do not match", expectedFatalErrors,
        testReport.getFatalErrorIds());

    return prop;
  }
View Full Code Here

Examples of com.adobe.epubcheck.util.ValidationReport

    return testVocabs(value, false);
  }

  private Map<String, Vocab> testVocabs(String value, boolean verbose)
  {
    ValidationReport testReport = new ValidationReport(VocabTest.class.getSimpleName());

    Map<String, Vocab> result = VocabUtil.parsePrefixDeclaration(value, PREDEF_VOCABS,
        KNOWN_VOCABS, FORBIDDEN_URIS, testReport, loc);

    if (verbose)
    {
      outWriter.println(testReport);
    }

    assertEquals("The error results do not match", expectedErrors, testReport.getErrorIds());
    assertEquals("The warning results do not match", expectedWarnings, testReport.getWarningIds());
    assertEquals("The fatal error results do not match", expectedFatalErrors,
        testReport.getFatalErrorIds());

    return result;
  }
View Full Code Here

Examples of com.adobe.epubcheck.util.ValidationReport

  }

  public void testValidateDocument(String fileName, List<MessageId> errors, List<MessageId> warnings, List<MessageId> fatalErrors,
                                   boolean verbose)
  {
    ValidationReport testReport = new ValidationReport(fileName, String.format(
        Messages.get("single_file"), "nav", "3.0"));

    GenericResourceProvider resourceProvider;
    if (fileName.startsWith("http://") || fileName.startsWith("https://"))
    {
      resourceProvider = new URLResourceProvider(fileName);
    }
    else
    {
      URL fileURL = this.getClass().getResource(basepath + fileName);
      String filePath = fileURL != null ? fileURL.getPath() : basepath + fileName;
      resourceProvider = new FileResourceProvider(filePath);
    }

    NavChecker navChecker = new NavChecker(resourceProvider, testReport, basepath
        + fileName, "application/xhtml+xml", EPUBVersion.VERSION_3);

    navChecker.validate();

    if (verbose)
    {
      outWriter.println(testReport);
    }

    assertEquals("The error results do not match", errors, testReport.getErrorIds());
    assertEquals("The warning results do not match", warnings, testReport.getWarningIds());
    assertEquals("The fatal error results do not match", fatalErrors, testReport.getFatalErrorIds());
  }
View Full Code Here

Examples of com.adobe.epubcheck.util.ValidationReport

  */
  private void validate() throws Exception
  {
    Archive epub = new Archive(TEMP_DIR.getPath());
    epub.createArchive();
    ValidationReport report = new ValidationReport(TEMP_DIR.getName());
    EpubCheck epubCheck = new EpubCheck(epub.getEpubFile(), report);
    epubCheck.validate();
    assertTrue(report.getErrorCount() < 1);
    assertTrue(report.getWarningCount() < 1);
    epub.deleteEpubFile();
    // outWriter.println(report);
  }
View Full Code Here

Examples of com.adobe.epubcheck.util.ValidationReport

    return test(value, false);
  }

  private Map<String, String> test(String value, boolean verbose)
  {
    ValidationReport testReport = new ValidationReport(PrefixParsingTest.class.getSimpleName());

    Map<String, String> result = PrefixDeclarationParser.parsePrefixMappings(value, testReport, loc);

    if (verbose)
    {
      outWriter.println(testReport);
    }

    assertEquals("The error results do not match", expectedErrors, testReport.getErrorIds());
    assertEquals("The warning results do not match", expectedWarnings, testReport.getWarningIds());
    assertEquals("The fatal error results do not match", expectedFatalErrors, testReport.getFatalErrorIds());

    return result;
  }
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.validation.core.ValidationReport

    String project = commandLine.getValue(Options.PROJECT_OPTION);
    String file = commandLine.getValue(Options.FILE_OPTION);

    ArrayList<Error> results = new ArrayList<Error>();
    DTDValidator validator = DTDValidator.getInstance();
    ValidationReport result = validator.validate(toUri(project, file));
    ValidationMessage[] messages = result.getValidationMessages();
    for (int ii = 0; ii < messages.length; ii++){
      StringBuffer message = new StringBuffer(messages[ii].getMessage());
      for (Object o : messages[ii].getNestedMessages()){
        ValidationMessage nested = (ValidationMessage)o;
        message.append(' ').append(nested.getMessage());
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.validation.core.ValidationReport

    String project = commandLine.getValue(Options.PROJECT_OPTION);
    String file = commandLine.getValue(Options.FILE_OPTION);

    ArrayList<Error> results = new ArrayList<Error>();
    XSDValidator validator = XSDValidator.getInstance();
    ValidationReport result = validator.validate(toUri(project, file));
    ValidationMessage[] messages = result.getValidationMessages();
    for (int ii = 0; ii < messages.length; ii++){
      StringBuffer message = new StringBuffer(messages[ii].getMessage());
      for (Object o : messages[ii].getNestedMessages()){
        ValidationMessage nested = (ValidationMessage)o;
        message.append(' ').append(nested.getMessage());
View Full Code Here

Examples of org.exist.validation.ValidationReport

            // Get inputstream
            // TODO DWES reconsider
            final InputStream is = new EmbeddedInputStream( new XmldbURL(docUri) );
           
            // Perform validation
            final ValidationReport report = validator.validate(is);
           
            // Return validation result
            isValid = report.isValid();
           
        } catch (final Throwable e) {
            handleException(e);
            return false;
        }
View Full Code Here

Examples of org.exist.validation.ValidationReport

        return parse(src, context, args);
  }

    private Sequence parse(final InputSource src, XQueryContext theContext, Sequence[] args) throws XPathException {
        Sequence resultSequence;
        final ValidationReport report = new ValidationReport();
        final SAXAdapter adapter = new SAXAdapter(theContext);
        try {
            final SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setNamespaceAware(true);
                     
            XMLReader xr = null;
           
            if (xr == null) {
                final SAXParser parser = factory.newSAXParser();
                xr = parser.getXMLReader();
            }
           
            xr.setErrorHandler(report);
            xr.setContentHandler(adapter);
            xr.setProperty(Namespaces.SAX_LEXICAL_HANDLER, adapter);
            xr.parse(src);
           
        } catch (final ParserConfigurationException e) {
            throw new XPathException(this, ErrorCodes.EXXQDY0002, "Error while constructing XML parser: "  + e.getMessage(), args[0], e);
        } catch (final SAXException e) {
            logger.debug("Error while parsing XML: " + e.getMessage(), e);
        } catch (final IOException e) {
            throw new XPathException(this, ErrorCodes.FODC0006, ErrorCodes.FODC0006.getDescription() + ": " + e.getMessage(),
                    args[0], e);
        }
       
        if (report.isValid()) {
            if (isCalledAs("parse-xml-fragment")) {
                resultSequence = new ValueSequence();
                NodeList children = adapter.getDocument().getDocumentElement().getChildNodes();
                for (int i = 0, il = children.getLength(); i < il; i++) {
                    Node child = children.item(i);
                    resultSequence.add((NodeValue)child);
                }
               
                return resultSequence;
            } else {
                return (DocumentImpl) adapter.getDocument();
            }
        } else {
            final MemTreeBuilder builder = theContext.getDocumentBuilder();
            final NodeImpl result = Shared.writeReport(report, builder);
            throw new XPathException(this, ErrorCodes.FODC0006, ErrorCodes.FODC0006.getDescription() + ": " + report.toString(), result);
        }
    }
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.