Package javax.xml.validation

Examples of javax.xml.validation.Schema


      throw new IOException( "Failed to obtain InputStream while reading persistence.xml file: " + configURL );
    }

    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setNamespaceAware( true );
    final Schema v2Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_2_0.xsd" ) ) );
    final Validator v2Validator = v2Schema.newValidator();
    final Schema v1Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_1_0.xsd" ) ) );
    final Validator v1Validator = v1Schema.newValidator();

    InputSource source = new InputSource( is );
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    docBuilder.setEntityResolver( resolver );
    List<SAXParseException> errors = new ArrayList<SAXParseException>();
View Full Code Here


      throw new IOException( "Failed to obtain InputStream while reading persistence.xml file: " + configURL );
    }

    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setNamespaceAware( true );
    final Schema v2Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_2_0.xsd" ) ) );
    final Validator v2Validator = v2Schema.newValidator();
    final Schema v1Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_1_0.xsd" ) ) );
    final Validator v1Validator = v1Schema.newValidator();

    InputSource source = new InputSource( is );
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    docBuilder.setEntityResolver( resolver );
    List<SAXParseException> errors = new ArrayList<SAXParseException>();
View Full Code Here

        return writer;
    }

    private void setSchemaOutMessage(Service service, Message message, DataWriter<?> writer) {
        if (shouldValidate(message)) {
            Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0),
                                                             message.getExchange().get(Bus.class));
            writer.setSchema(schema);
        }
    }
View Full Code Here

    }

    private void setSchemaInMessage(Service service, Message message, DataReader<?> reader) {
        if (MessageUtils.getContextualBoolean(message, Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE)) {
            //all serviceInfos have the same schemas
            Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0),
                                                             message.getExchange().get(Bus.class));
            reader.setSchema(schema);
            /* This might be a reader that wants to grab the schema from the
             * service info.
             */
 
View Full Code Here

      throw new IOException( "Failed to obtain InputStream while reading persistence.xml file: " + configURL );
    }

    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setNamespaceAware( true );
    final Schema v2Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_2_0.xsd" ) ) );
    final Validator v2Validator = v2Schema.newValidator();
    final Schema v1Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_1_0.xsd" ) ) );
    final Validator v1Validator = v1Schema.newValidator();

    InputSource source = new InputSource( is );
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    docBuilder.setEntityResolver( resolver );
    List<SAXParseException> errors = new ArrayList<SAXParseException>();
View Full Code Here

    if ( event == null ) {
      throw new MappingException( "Could not locate root element", origin );
    }

    final Schema validationSchema;
    final Class jaxbTarget;

    final String elementName = event.asStartElement().getName().getLocalPart();

    if ( "entity-mappings".equals( elementName ) ) {
View Full Code Here

    Element rootElement = document.getDocumentElement();
    if ( rootElement == null ) {
      throw new MappingException( "No root element found", origin );
    }

    final Schema validationSchema;
    final Class jaxbTarget;

    if ( "entity-mappings".equals( rootElement.getNodeName() ) ) {
      final String explicitVersion = rootElement.getAttribute( "version" );
      validationSchema = resolveSupportedOrmXsd( explicitVersion );
View Full Code Here

      throw new IOException( "Failed to obtain InputStream while reading persistence.xml file: " + configURL );
    }

    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setNamespaceAware( true );
    final Schema v2Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_2_0.xsd" ) ) );
    final Validator v2Validator = v2Schema.newValidator();
    final Schema v1Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_1_0.xsd" ) ) );
    final Validator v1Validator = v1Schema.newValidator();

    InputSource source = new InputSource( is );
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    docBuilder.setEntityResolver( resolver );
    List<SAXParseException> errors = new ArrayList<SAXParseException>();
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.setFeature("http://apache.org/xml/features/validation/schema", true);
        validator.setResourceResolver(DEFAULT_RESOURCE_RESOLVER);
        validator.validate(new StreamSource(getXmlFile(xmlName)));
    }
View Full Code Here

   public static void validate(final Node node, final String schemaFile) throws Exception
   {
      SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

      Schema schema = factory.newSchema(findResource(schemaFile));
      Validator validator = schema.newValidator();

      // validate the DOM tree
      try
      {
         validator.validate(new DOMSource(node));
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.