Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2002-2012 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.integration.xml.config;

Author(s):
Jonas Partner
Oleg Zhurakousky
Artem Bilan
Constant that defines a W3C XML Schema.
	public static final String SCHEMA_W3C_XML = "http://www.w3.org/2001/XMLSchema";

Constant that defines a RELAX NG Schema.
	public static final String SCHEMA_RELAX_NG = "http://relaxng.org/ns/structure/1.0";
	protected BeanDefinitionBuilder parseHandler(Element elementParserContext parserContext) {
		BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder.genericBeanDefinition(FilterFactoryBean.class);
		IntegrationNamespaceUtils.setReferenceIfAttributeDefined(filterBuilderelement"discard-channel");
		IntegrationNamespaceUtils.setValueIfAttributeDefined(filterBuilderelement"throw-exception-on-rejection");
		BeanDefinitionBuilder selectorBuilder = BeanDefinitionBuilder.genericBeanDefinition(XmlValidatingMessageSelector.class);
		String validator = element.getAttribute("xml-validator");
		String schemaLocation = element.getAttribute("schema-location");
		boolean validatorDefined = StringUtils.hasText(validator);
		boolean schemaLocationDefined = StringUtils.hasText(schemaLocation);
		if (!(validatorDefined ^ schemaLocationDefined)) {
					"Exactly one of 'xml-validator' or 'schema-location' is allowed on the 'validating-filter' element");
		}
		if (schemaLocationDefined) {
			selectorBuilder.addConstructorArgValue(schemaLocation);
			// it is a restriction with the default value of 'xml-schema' which
			// corresponds to 'http://www.w3.org/2001/XMLSchema'
			String schemaType = "xml-schema".equals(element.getAttribute("schema-type")) ?  : ;
			selectorBuilder.addConstructorArgValue(schemaType);
		}
		else {
			selectorBuilder.addConstructorArgReference(validator);
		}
		IntegrationNamespaceUtils.setValueIfAttributeDefined(selectorBuilderelement"throw-exception-on-rejection");
		filterBuilder.addPropertyValue("targetObject"selectorBuilder.getBeanDefinition());
		return filterBuilder;
	}
New to GrepCode? Check out our FAQ X