Package javax.xml.validation

Examples of javax.xml.validation.Schema.newValidator()


            schema = getSchema();
        } else {
            schema = createSchema();
        }

        Validator validator = schema.newValidator();

        Source source;
        Result result;
        try {
            if (useDom) {
View Full Code Here


            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            FileUtil.copyInputStream(url.openStream(), baos);
            // Validate descriptor
            SchemaFactory schemaFactory = SchemaFactory.newInstance(XSD_SCHEMA_LANGUAGE);
            Schema schema = schemaFactory.newSchema(DescriptorFactory.class.getResource("/jbi-descriptor.xsd"));
            Validator validator = schema.newValidator();
            validator.setErrorHandler(new ErrorHandler() {
                public void warning(SAXParseException exception) throws SAXException {
                    LOGGER.debug("Validation warning on {}", url, exception);
                }
                public void error(SAXParseException exception) throws SAXException {
View Full Code Here

    private void parseXml(String xmlName) throws ParserConfigurationException, SAXException, IOException {
        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        schemaFactory.setErrorHandler(new ErrorHandlerImpl());
        schemaFactory.setResourceResolver(DEFAULT_RESOURCE_RESOLVER);
        Schema schema = schemaFactory.newSchema(SCHEMAS);
        Validator validator = schema.newValidator();
        validator.setErrorHandler(new ErrorHandlerImpl());
        validator.setFeature("http://apache.org/xml/features/validation/schema", true);
        validator.setResourceResolver(DEFAULT_RESOURCE_RESOLVER);
        validator.validate(new StreamSource(getXmlFile(xmlName)));
    }
View Full Code Here

        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        schemaFactory.setErrorHandler(new ErrorHandlerImpl());
        schemaFactory.setResourceResolver(new XMLResourceResolver());

        Schema schema = schemaFactory.newSchema(resource("schema/XMLSchema.xsd"));
        Validator validator = schema.newValidator();
        validator.validate(new DOMSource(document));
    }

    private URL resource(final String name) {
        final ClassLoader classLoader = getClass().getClassLoader();
View Full Code Here

            document.setDocumentURI(uri);
            if (validate) {
                Schema schema = getSchema(document);
                if (schema != null) {
                    // Validate TLD against specified schema
                    schema.newValidator().validate(new DOMSource(document));
                }
                /* See CR 6399139
                else {
                    log.warn(Localizer.getMessage(
                        "jsp.warning.dtdValidationNotSupported"));
View Full Code Here

      InputStream xsd = getClass().getClassLoader().getResourceAsStream("v2.01.xsd");
    Source schemaFile = new StreamSource(xsd);
      Schema schema = factory.newSchema(schemaFile);

      Validator validator = schema.newValidator();
    return validator;
  }

  private DOMSource createDocument() throws ParserConfigurationException,
      SAXException, IOException {
View Full Code Here

                new StreamSource(xmlSchemaURL.openStream()),
                new StreamSource(javaeeSchemaURL.openStream())
            });

        // validate
        schema.newValidator().validate(sourceForValidate);
    }

    private static URL getSchemaURL(final String xsdFileName) {
        return JaxbJavaee.class.getClassLoader().getResource("/META-INF/schema/" + xsdFileName);
    }
View Full Code Here

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);
            DocumentBuilder docBuilder = factory.newDocumentBuilder();
            Document doc = docBuilder.parse(new InputSource(new StringReader(args)));

            schema.newValidator().validate(new DOMSource(doc));

            return true;
        }catch (SAXException ex) {
         //   ex.printStackTrace();
            return false;
View Full Code Here

                    schema = factory.newSchema(sources);
                }
            }
           
            // Setup validator and input source.
            Validator validator = schema.newValidator();
            validator.setErrorHandler(inlineSchemaValidator);
           
            try {
                validator.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
            }
View Full Code Here

            else {
                schema = factory.newSchema();
            }
           
            // Setup validator and input source.
            Validator validator = schema.newValidator();
            validator.setErrorHandler(sourceValidator);
           
            try {
                validator.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
            }
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.