Package javax.xml.validation

Examples of javax.xml.validation.Schema


        callback.done(true);
        return true;
    }

    protected void doProcess(Exchange exchange) throws Exception {
        Schema schema;
        if (isUseSharedSchema()) {
            schema = getSchema();
        } else {
            schema = createSchema();
        }

        Validator validator = schema.newValidator();

        // the underlying input stream, which we need to close to avoid locking files or other resources
        Source source = null;
        InputStream is = null;
        try {
View Full Code Here


                LOGGER.error("Unable to access schema " + schema);
            }
            if (is != null) {
                final Source src = new StreamSource(is, LOG4J_XSD);
                final SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
                Schema schema = null;
                try {
                    schema = factory.newSchema(src);
                } catch (final SAXException ex) {
                    LOGGER.error("Error parsing Log4j schema", ex);
                }
                if (schema != null) {
                    validator = schema.newValidator();
                    try {
                        validator.validate(new StreamSource(new ByteArrayInputStream(buffer)));
                    } catch (final IOException ioe) {
                        LOGGER.error("Error reading configuration for validation", ioe);
                    } catch (final SAXException ex) {
View Full Code Here

                LOGGER.error("Unable to access schema {}", this.schema, ex);
            }
            if (is != null) {
                final Source src = new StreamSource(is, LOG4J_XSD);
                final SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
                Schema schema = null;
                try {
                    schema = factory.newSchema(src);
                } catch (final SAXException ex) {
                    LOGGER.error("Error parsing Log4j schema", ex);
                }
                if (schema != null) {
                    final Validator validator = schema.newValidator();
                    try {
                        validator.validate(new StreamSource(new ByteArrayInputStream(buffer)));
                    } catch (final IOException ioe) {
                        LOGGER.error("Error reading configuration for validation", ioe);
                    } catch (final SAXException ex) {
View Full Code Here

            throw XMLMarshalException.errorInstantiatingSchemaPlatform(e);
        }
    }
   
    public Schema getSchema() {
        Schema schema = null;
        try {
            schema = xmlParser.getXMLSchema();
        } catch(UnsupportedOperationException ex) {
            //if this parser doesn't support the setSchema/getSchema API, just return null;
        }
View Full Code Here

        setValidatorHandler(xmlReader);
        xmlReader.setContentHandler(contentHandler);
    }
   
    private void setValidatorHandler(XMLReader xmlReader) {
        Schema schema = null;
        try {
            schema = saxParserFactory.getSchema();
        } catch (UnsupportedOperationException e) {
            // Oracle XDK does not support getSchema()
        }

        if (null != schema) {
            ValidatorHandler validatorHandler = schema.newValidatorHandler();
            xmlReader.setValidatorHandler(validatorHandler);
            validatorHandler.setErrorHandler(getErrorHandler());
        }
       
    }
View Full Code Here

      return null;
    }
  }

  private Schema getSchema(String schemaName) {
    Schema schema = null;
    URL schemaUrl = this.getClass().getClassLoader().getResource( schemaName );
    if ( schemaUrl == null ) {
      return schema;
    }
View Full Code Here

        // create xsd validator
        SchemaFactory factory = SchemaFactory
                .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Source schemaSource = new StreamSource(filexsd);

        Schema schema = factory.newSchema(schemaSource);
        // validate source xml to xsd
        Validator validator = schema.newValidator();
        validator.validate(new StreamSource(filexml));

        // parse xml to dom
        DocumentBuilder parser = DocumentBuilderFactory.newInstance()
                .newDocumentBuilder();
View Full Code Here

        // create xsd validator
        SchemaFactory factory = SchemaFactory
                .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Source schemaSource = new StreamSource(filexsd);

        Schema schema = factory.newSchema(schemaSource);
        // validate source xml to xsd
        Validator validator = schema.newValidator();
        validator.validate(new StreamSource(filexml));

        // parse xml to dom
        DocumentBuilder parser = DocumentBuilderFactory.newInstance()
                .newDocumentBuilder();
View Full Code Here

   public void create() throws Exception
   {
      documentBuilderFactory = DocumentBuilderFactory.newInstance();
      documentBuilderFactory.setNamespaceAware(useNamespaceAwareParser);
      documentBuilderFactory.setValidating(validateDTDs);
      Schema schema = SchemaHelper.getSchema(schemaLocation);
      if (schema != null)
      {
         documentBuilderFactory.setSchema(schema);
      }
   }
View Full Code Here

      URL schemaURL = getClass().getResource("kernel-configuration_1_0.xsd");
      if (schemaURL != null)
      {
         try
         {
            Schema schema = factory.newSchema(schemaURL);
            Validator validator = schema.newValidator();
            Reporter reporter = new Reporter(url);
            validator.setErrorHandler(reporter);

            // Validate the document
            validator.validate(new StreamSource(url.openStream()));
View Full Code Here

TOP

Related Classes of javax.xml.validation.Schema

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.