Package javax.xml.validation

Examples of javax.xml.validation.Validator.validate()


    catch (XMLStreamException e) {
      throw new InvalidMappingException( "Unable to generate StAXSource from mapping", origin, e );
    }

    try {
      validator.validate( staxSource );
    }
    catch (SAXException e) {
      throw new InvalidMappingException( "SAXException performing validation", origin, e );
    }
    catch (IOException e) {
View Full Code Here


      }
      if (isV1Schema) {
                LOG.trace("Validate with persistence_1_0.xsd schema on file " + configURL);
        errors.clear();
        v1Validator.setErrorHandler( new ErrorLogger( errors ) );
        v1Validator.validate( new DOMSource( doc ) );
      }
    }
    if ( errors.size() != 0 ) {
      //report all errors in the exception
      StringBuilder errorMessage = new StringBuilder( );
View Full Code Here

      }
      if (isV1Schema) {
                LOG.trace("Validate with persistence_1_0.xsd schema on file " + configURL);
        errors.clear();
        v1Validator.setErrorHandler( new ErrorLogger( errors ) );
        v1Validator.validate( new DOMSource( doc ) );
      }
    }
    if ( errors.size() != 0 ) {
      //report all errors in the exception
      StringBuilder errorMessage = new StringBuilder( );
View Full Code Here

        schemaFactory.setResourceResolver(DEFAULT_RESOURCE_RESOLVER);
        Schema schema = schemaFactory.newSchema(SCHEMAS);
        Validator validator = schema.newValidator();
        validator.setFeature("http://apache.org/xml/features/validation/schema", true);
        validator.setResourceResolver(DEFAULT_RESOURCE_RESOLVER);
        validator.validate(new StreamSource(getXmlFile(xmlName)));
    }

    private File getXmlFile(String xmlName) throws IOException {

        // Copy the input file to tmp, replacing system prop expressions on non-string fields
View Full Code Here

      Validator validator = schema.newValidator();

      // validate the DOM tree
      try
      {
         validator.validate(new DOMSource(node));
      }
      catch (SAXException e)
      {
         XMLUtil.log.error("Invalid configuration", e);
View Full Code Here

    generateSchema(bos);
    try {
      final SpringApplicationService springApplicationService = (SpringApplicationService) u.unmarshal(xml);
      final Schema schema = schemaFactory.newSchema(new StreamSource(new ByteArrayInputStream(bos.toByteArray())));
      final Validator validator = schema.newValidator();
      validator.validate(new JAXBSource(jc, springApplicationService));
      return springApplicationService;
    } catch (SAXException | IOException e) {
      throw new IllegalArgumentException("Failed to parse XML. The XML must conform to the following schema:\n" + bos, e);
    }
  }
View Full Code Here

      Validator validator = schema.newValidator();

      // validate the DOM tree
      try
      {
         validator.validate(new DOMSource(node));
      }
      catch (SAXException e)
      {
         XMLUtil.log.error("Invalid configuration", e);
View Full Code Here

                sources.add(new StreamSource(Thread.currentThread().getContextClassLoader().getResourceAsStream(
                        "ssh-action-0.1.xsd")));
                SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
                Schema schema = factory.newSchema(sources.toArray(new StreamSource[sources.size()]));
                Validator validator = schema.newValidator();
                validator.validate(new StreamSource(new FileReader(file)));
                System.out.println("Valid worflow-app");
            }
            catch (Exception ex) {
                throw new OozieCLIException("Invalid workflow-app, " + ex.toString(), ex);
            }
View Full Code Here

    }

    public void testWfSchema() throws Exception {
        SchemaService wss = Services.get().get(SchemaService.class);
        Validator validator = wss.getSchema(SchemaName.WORKFLOW).newValidator();
        validator.validate(new StreamSource(new StringReader(APP1)));
    }

    // Test for validation of workflow definition against pattern defined in schema to complete within 3 seconds
    public void testWfSchemaFailure() throws Exception {
        SchemaService wss = Services.get().get(SchemaService.class);
View Full Code Here

    }

    public void testWfSchemaV2() throws Exception {
        SchemaService wss = Services.get().get(SchemaService.class);
        Validator validator = wss.getSchema(SchemaName.WORKFLOW).newValidator();
        validator.validate(new StreamSource(new StringReader(APP_V2)));
    }

    public void testWfSchemaV25() throws Exception {
        SchemaService wss = Services.get().get(SchemaService.class);
        Validator validator = wss.getSchema(SchemaName.WORKFLOW).newValidator();
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.