INT-1659 changed the name of the attribute to 'evaluate-as-string', updated schema and tests. Updated documentation

This commit is contained in:
Oleg Zhurakousky
2010-12-03 13:37:42 -05:00
parent 928f38f315
commit 6725b68d5d
6 changed files with 64 additions and 23 deletions

View File

@@ -47,7 +47,7 @@ public class XPathRouterParser extends AbstractRouterParser {
element.getNamespaceURI(), "xpath-expression");
Assert.isTrue(xPathExpressionNodes.getLength() <= 1, "At most one xpath-expression child may be specified.");
String xPathExpressionRef = element.getAttribute("xpath-expression-ref");
IntegrationNamespaceUtils.setValueIfAttributeDefined(xpathRouterBuilder, element, "evaluate-as-node");
IntegrationNamespaceUtils.setValueIfAttributeDefined(xpathRouterBuilder, element, "evaluate-as-string");
boolean xPathExpressionChildPresent = (xPathExpressionNodes.getLength() == 1);
boolean xPathReferencePresent = StringUtils.hasText(xPathExpressionRef);
Assert.isTrue(xPathExpressionChildPresent ^ xPathReferencePresent,

View File

@@ -47,7 +47,7 @@ public class XPathRouter extends AbstractMessageRouter {
private volatile XmlPayloadConverter converter = new DefaultXmlPayloadConverter();
private volatile boolean evaluateAsNode = true;
private volatile boolean evaluateAsString = false;
/**
* Create a router that uses an XPath expression. The expression may
@@ -97,8 +97,8 @@ public class XPathRouter extends AbstractMessageRouter {
this.xPathExpression = expression;
}
public void setEvaluateAsNode(boolean evaluateAsNode) {
this.evaluateAsNode = evaluateAsNode;
public void setEvaluateAsString(boolean evaluateAsString) {
this.evaluateAsString = evaluateAsString;
}
/**
@@ -117,11 +117,11 @@ public class XPathRouter extends AbstractMessageRouter {
@SuppressWarnings("unchecked")
protected List<Object> getChannelIdentifiers(Message<?> message) {
Node node = this.converter.convertToNode(message.getPayload());
if (this.evaluateAsNode){
return this.xPathExpression.evaluate(node, this.nodeMapper);
if (this.evaluateAsString){
return Collections.singletonList((Object)this.xPathExpression.evaluateAsString(node));
}
else {
return Collections.singletonList((Object)this.xPathExpression.evaluateAsString(node));
return this.xPathExpression.evaluate(node, this.nodeMapper);
}
}

View File

@@ -369,11 +369,11 @@
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:ID"/>
<xsd:attribute name="evaluate-as-node" type="xsd:boolean" default="true">
<xsd:attribute name="evaluate-as-string" type="xsd:boolean" default="false">
<xsd:annotation>
<xsd:documentation><![CDATA[
By default XPath expressions are evaluated as NODESET type and then converted
to a List<String> of channel names, thus handling single channel scenarios as well as multiple.
to a List of channel names, thus handling single channel scenarios as well as multiple.
However certain XPath expressions may evaluate as String type from the very
beginning (e.g., 'name(./node())' - which will return the name of the root node) thus resulting in
the exception if default evaluation type (NODESET) is used. This flag will allow you to manage the