INT-1156 initial commit for XPathTransformerParser and corresponding XSD updates
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -20,6 +20,7 @@ import org.springframework.integration.config.xml.AbstractIntegrationNamespaceHa
|
||||
|
||||
/**
|
||||
* @author Jonas Partner
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class IntegrationXmlNamespaceHandler extends AbstractIntegrationNamespaceHandler {
|
||||
|
||||
@@ -27,6 +28,7 @@ public class IntegrationXmlNamespaceHandler extends AbstractIntegrationNamespace
|
||||
registerBeanDefinitionParser("marshalling-transformer", new MarshallingTransformerParser());
|
||||
registerBeanDefinitionParser("unmarshalling-transformer", new UnmarshallingTransformerParser());
|
||||
registerBeanDefinitionParser("xslt-transformer", new XsltPayloadTransformerParser());
|
||||
registerBeanDefinitionParser("xpath-transformer", new XPathTransformerParser());
|
||||
registerBeanDefinitionParser("xpath-router", new XPathRouterParser());
|
||||
registerBeanDefinitionParser("xpath-selector", new XPathSelectorParser());
|
||||
registerBeanDefinitionParser("xpath-expression", new XPathExpressionParser());
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractTransformerParser;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Parser for the 'xpath-transformer' element.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @since 2.0
|
||||
*/
|
||||
public class XPathTransformerParser extends AbstractTransformerParser {
|
||||
|
||||
@Override
|
||||
protected String getTransformerClassName() {
|
||||
return "org.springframework.integration.xml.transformer.XPathTransformer";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parseTransformer(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
String expression = element.getAttribute("expression");
|
||||
Assert.isTrue(StringUtils.hasText(expression), "The 'expression' attribute is required.");
|
||||
builder.addConstructorArgValue(expression);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "evaluation-type");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -157,6 +157,43 @@
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="xpath-transformer">
|
||||
<xsd:complexType>
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Defines an XPath transformer.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="inputOutputEndpoint">
|
||||
<xsd:attribute name="expression" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The XPath expression to be evaluated against the input Message's payload.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="evaluation-type" default="STRING_RESULT">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The result type expected from the XPath evaluation. This will be the payload type of the output Message.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="BOOLEAN_RESULT"/>
|
||||
<xsd:enumeration value="NODE_RESULT"/>
|
||||
<xsd:enumeration value="NODE_LIST_RESULT"/>
|
||||
<xsd:enumeration value="NUMBER_RESULT"/>
|
||||
<xsd:enumeration value="STRING_RESULT"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="xpath-router">
|
||||
<xsd:complexType>
|
||||
<xsd:annotation>
|
||||
|
||||
Reference in New Issue
Block a user