Package javax.xml.validation

Examples of javax.xml.validation.Schema


            event.setEventName(eventName);

            EventProxy eventProxy = getConfig().getEventProxy(
                eventName);
            Schema s = getConfig().getValidatingSchema(eventName);
           
            if (eventProxy == null) {
              throw new TranslationException(
                  "Unable to map event: " + eventName //$NON-NLS-1$
                      + " to Config file"); //$NON-NLS-1$
View Full Code Here


    return null;
  }
 
  private static Schema getSchemaFromStream(final InputStream is, final String location) {
    try {
      Schema s = SF.newSchema(new SAXSource(new InputSource(is)));
      if (s != null) {
        LOGGER.info("Successfully loaded schema at: " + location); //$NON-NLS-1$
      } else {
        LOGGER.severe("Schema failed to load: " + location); //$NON-NLS-1$
      }
View Full Code Here

      throws ParserException {
    for (String eventName : this.eventNameTagHandler.getEventNames()) {
      if (this.schemaMappings.containsKey(eventName)) {
        LOGGER.severe("The event \"" + eventName + "\" is already mapped to a schema. Cannot map to another schema."); //$NON-NLS-1$ //$NON-NLS-2$
      } else {
        Schema s = loadSchema(this.schemaLocation);
        if (s != null) {
          this.schemaMappings.put(eventName, s);
        }
      }
    }
View Full Code Here

      Attributes attributes) throws ParserException {
    this.schemaLocation = attributes.getValue(SCHEMA_LOCATION);
  }

  private Schema loadSchema(final String location) {
    Schema s = this.loadedSchema.get(location);
    if (s == null) {
      s = JAXBSchemaFactory.loadSchema(location, this.getClass());
      if (s != null) {
        this.loadedSchema.put(location, s);
      } else {
View Full Code Here

    private SyslogMessage test(String message) throws Exception {
        MessageContext msgContext = new MessageContext();
        ByteArrayInputStream in = new ByteArrayInputStream(message.getBytes("us-ascii"));
        OMElement element = new SyslogMessageBuilder().processDocument(in, null, msgContext);
        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = factory.newSchema(new StreamSource(SyslogMessageBuilderTest.class.getResource("schema.xsd").toExternalForm()));
        Validator validator = schema.newValidator();
        validator.setErrorHandler(new ErrorHandler() {
            public void error(SAXParseException exception) throws SAXException {
                throw exception;
            }
View Full Code Here

        return null;
    }
   
   
    private static Schema createSchema(ServiceInfo serviceInfo) {
        Schema schema = serviceInfo.getProperty(Schema.class.getName(), Schema.class);
        if (schema == null) {
            SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            Map<String, byte[]> schemaSourcesMap = new LinkedHashMap<String, byte[]>();
            Map<String, Source> schemaSourcesMap2 = new LinkedHashMap<String, Source>();
View Full Code Here

   
    public static Schema getSchema(ServiceInfo serviceInfo) {
        if (serviceInfo == null) {
            return null;
        }
        Schema schema = serviceInfo.getProperty(Schema.class.getName(), Schema.class);
        if (schema == null && !serviceInfo.hasProperty(Schema.class.getName())) {
            synchronized (serviceInfo) {
                return createSchema(serviceInfo);
            }
        }
View Full Code Here

            return;
        }

        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        // root element has namespace - we can use schema validation
        Schema schema = factory.newSchema(new StreamSource(FeatureValidationUtil.class
            .getResourceAsStream("/org/apache/karaf/features/karaf-features-1.0.0.xsd")));

        // create schema by reading it from an XSD file:
        Validator validator = schema.newValidator();

        try {
            validator.validate(new DOMSource(doc));
        } catch (Exception e) {
            throw new IllegalArgumentException("Unable to validate " + uri, e);
View Full Code Here

                return null;
            }

            log.debug("{} found.", validationXmlFile);

            Schema schema = getSchema();
            JAXBContext jc = JAXBContext.newInstance(ValidationConfigType.class);
            Unmarshaller unmarshaller = jc.createUnmarshaller();
            unmarshaller.setSchema(schema);
            StreamSource stream = new StreamSource(inputStream);
            JAXBElement<ValidationConfigType> root =
View Full Code Here

        setDataWriterValidation(service, message, dataWriter);
        return dataWriter;
    }
    private void setDataWriterValidation(Service service, Message message, DataWriter<?> writer) {
        if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, message)) {
            Schema schema = EndpointReferenceUtils.getSchema(service.getServiceInfos().get(0),
                                                             message.getExchange().getBus());
            writer.setSchema(schema);
        }
    }
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.