Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright 2002-2013 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
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package org.springframework.integration.xml.transformer;
Transformer implementation that evaluates XPath expressions against the message payload and inserts the result of the evaluation into a message header. The header names will match the keys in the map of expressions.

Jonas Partner
Mark Fisher
public class XPathHeaderEnricher extends HeaderEnricher {

Create an instance of XPathHeaderEnricher using a map with header names as keys and XPathExpressionValueHolders to evaluate the values.
		private final XPathExpression expression;
		private volatile Boolean overwrite = null;
			Assert.hasText(expression"expression must have text");
			this. = XPathExpressionFactory.createXPathExpression(expression);
			Assert.notNull(expression"expression must not be null");
			this. = expression;
		public void setEvaluationType(XPathEvaluationType evaluationType) {
			this. = evaluationType;
		public void setOverwrite(Boolean overwrite) {
			this. = overwrite;
		public Boolean isOverwrite() {
			return this.;
		public Object processMessage(Message<?> message) {
			Node node = .convertToNode(message.getPayload());
			Object result = this..evaluateXPath(this.node);
			if (result instanceof String && ((Stringresult).length() == 0) {
				result = null;
			return result;
New to GrepCode? Check out our FAQ X