Package javax.xml.validation

Examples of javax.xml.validation.Schema


            MessagePartInfo mpi = header.getPart();
            try {
                if (MessageUtils.getContextualBoolean(message,
                                                 org.apache.cxf.message.Message.SCHEMA_VALIDATION_ENABLED,
                                                 Boolean.FALSE)) {
                    Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0), message
                                                                     .getExchange().getBus());
                    validateHeader(message, mpi, schema);
                }
            } catch (Fault f) {
                if (!isRequestor(message)) {
View Full Code Here


     *             configuration requested.
     * @throws IOException If any IO errors occur.
     */
    public static Configuration create (final File schemaLocation, final File configFile, final String pTargetAddress) throws SAXException , ParserConfigurationException , IOException {
        final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        final Schema schema = schemaFactory.newSchema(schemaLocation);

        // create a validator for the document
        final Validator validator = schema.newValidator();

        final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
        domFactory.setNamespaceAware(true); // never forget this
        final DocumentBuilder builder = domFactory.newDocumentBuilder();
        final Document doc = builder.parse(configFile);
View Full Code Here

     * @throws IOException If any IO errors occur.
     */
    private final Document parse (final File schemaLocation, final File configFile) throws ConfigurationException {
        try {
            final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            final Schema schema = schemaFactory.newSchema(schemaLocation);

            // create a validator for the document
            final Validator validator = schema.newValidator();

            final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
            domFactory.setNamespaceAware(true); // never forget this
            final DocumentBuilder builder = domFactory.newDocumentBuilder();
            final Document doc = builder.parse(configFile);
View Full Code Here

    if ( stream == null ) {
      return null;
    }

    try {
      Schema schema = xmlParserHelper.getSchema( PERSISTENCE_SCHEMA );
      persistence = xmlParserHelper.getJaxbRoot( stream, Persistence.class, schema );
    }
    catch ( XmlParsingException e ) {
      context.logMessage(
          Diagnostic.Kind.WARNING, "Unable to parse persistence.xml: " + e.getMessage()
View Full Code Here

      if ( stream == null ) {
        continue;
      }
      EntityMappings mapping = null;
      try {
        Schema schema = xmlParserHelper.getSchema( ORM_SCHEMA );
        mapping = xmlParserHelper.getJaxbRoot( stream, EntityMappings.class, schema );
      }
      catch ( XmlParsingException e ) {
        context.logMessage(
            Diagnostic.Kind.WARNING, "Unable to parse " + mappingFile + ": " + e.getMessage()
View Full Code Here

    }
    return ormStream;
  }

  public Schema getSchema(String schemaResource) throws XmlParsingException {
    Schema schema = SCHEMA_CACHE.get( schemaResource );

    if ( schema != null ) {
      return schema;
    }

    schema = loadSchema( schemaResource );
    Schema previous = SCHEMA_CACHE.putIfAbsent( schemaResource, schema );

    return previous != null ? previous : schema;
  }
View Full Code Here

      return resourceName.substring( resourceName.lastIndexOf( Constants.PATH_SEPARATOR ) + 1 );
    }
  }

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

    }

    protected Document parseInput(InputStream is, Message message) throws Exception { //NOPMD
        try {
            ValidatorErrorHandler errorHandler = new DefaultValidationErrorHandler();
            Schema schema = getSchema(message);
            DocumentBuilder db = XmlSignatureHelper.newDocumentBuilder(getConfiguration().getDisallowDoctypeDecl(), schema);
            db.setErrorHandler(errorHandler);
            Document doc = db.parse(is);
            errorHandler.handleErrors(message.getExchange(), schema, null); // throws ValidationException
            return doc;
View Full Code Here

        Node node;
        if (isPlainText != null && isPlainText) {
            node = getTextNode(message, is);
        } else {
            ValidatorErrorHandler errorHandler = new DefaultValidationErrorHandler();
            Schema schema = getSchemaForSigner(message, errorHandler);
            Document doc = parseInput(is, getConfiguration().getDisallowDoctypeDecl(), schema, errorHandler);
            errorHandler.handleErrors(message.getExchange(), schema, null); // throws ValidationException
            node = doc.getDocumentElement();
            LOG.debug("Root element of document to be signed: {}", node);
        }
View Full Code Here

        return node;
    }

    protected Schema getSchemaForSigner(Message message, ValidatorErrorHandler errorHandler) throws XmlSignatureException, SAXException,
            IOException {
        Schema schema;
        String schemaResourceUri = getSchemaResourceUri(message);
        if (schemaResourceUri == null) {
            schema = null;
        } else {
            schema = getSchema(message);
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.