Using the XPath Filter
此组件定义了一个基于 XPath 的消息过滤器。内部,这些组件使用一个包装 AbstractXPathMessageSelector
实例的 MessageFilter
。
This component defines an XPath-based message filter.
Internally, these components uses a MessageFilter
that wraps an instance of AbstractXPathMessageSelector
.
有关详细信息,请参阅 Filter。 |
See Filter for further details. |
要使用 XPath 过滤器,您至少必须通过声明 xpath-expression
元素或在 xpath-expression-ref
属性中引用 XPath 表达式来提供一个 XPath 表达式。
to use the XPath filter you must, at a minimum, provide an XPath expression either by declaring the xpath-expression
element or by referencing an XPath Expression in the xpath-expression-ref
attribute.
如果提供的 XPath 表达式计算得出一个 boolean
值,则不需要其他配置参数。然而,如果 XPath 表达式计算得出一个 String
,您应设置 match-value
属性,对其比对计算结果。
If the provided XPath expression evaluates to a boolean
value, no further configuration parameters are necessary.
However, if the XPath expression evaluates to a String
, you should set the match-value
attribute, against which the evaluation result is matched.
match-type
有三个选项:
match-type
has three options:
-
exact
:对应于java.lang.String
中的equals
。基础实现使用StringValueTestXPathMessageSelector
-
exact
: Correspond toequals
onjava.lang.String
. The underlying implementation uses aStringValueTestXPathMessageSelector
-
case-insensitive
:对应于java.lang.String
中的equals-ignore-case
。基础实现使用StringValueTestXPathMessageSelector
-
case-insensitive
: Correspond toequals-ignore-case
onjava.lang.String
. The underlying implementation uses aStringValueTestXPathMessageSelector
-
regex
:匹配java.lang.String
中的一个操作。基础实现使用RegexTestXPathMessageSelector
-
regex
: Matches operations onejava.lang.String
. The underlying implementation uses aRegexTestXPathMessageSelector
当提供 regex
的 'match-type' 值时,随 match-value
属性一起提供的 value 必须是一个有效的正则表达式。
When providing a 'match-type' value of 'regex', the value provided with the match-value
attribute must be a valid regular expression.
以下示例显示了 xpath-filter
元素的所有可用属性:
The following example shows all the available attributes for the xpath-filter
element:
<int-xml:xpath-filter discard-channel="" 1
id="" 2
input-channel="" 3
match-type="exact" 4
match-value="" 5
output-channel="" 6
throw-exception-on-rejection="false" 7
xpath-expression-ref=""> 8
<int-xml:xpath-expression ... /> 9
<int:poller ... /> 10
</int-xml:xpath-filter>
1 | 您要发送拒绝消息到的消息频道。可选。 |
2 | Message channel where you want rejected messages to be sent. Optional. |
3 | 基础 Bean 定义的 ID。可选。 |
4 | ID for the underlying bean definition. Optional. |
5 | 此端点的接收消息频道。可选。 |
6 | The receiving message channel of this endpoint. Optional. |
7 | 在 XPath 求值结果和 match-value 之间应用的匹配类型。默认值为 exact 。可选。 |
8 | Type of match to apply between the XPath evaluation result and the match-value .
The default is exact .
Optional. |
9 | 与 XPath 求值结果进行匹配的字符串值。如果您没有设置此属性,则 XPath 求值必须产生一个布尔结果。可选。 |
10 | String value to be matched against the XPath evaluation result. If you do not set this attribute, the XPath evaluation must produce a boolean result. Optional. |
11 | 将符合筛选条件的消息派发到该频道。可选。 |
12 | The channel to which messages that matched the filter criteria are dispatched. Optional. |
13 | 默认情况下,此属性的值设为 false ,并且拒绝的消息(不符合筛选条件的信息)会被静默地丢弃。但是,如果设为 true ,则消息拒绝将导致错误条件,并且异常将沿上行传播到调用方。可选。 |
14 | By default, this property is set to false and rejected messages (those did not match the filter criteria) are silently dropped.
However, if set to true , message rejection results in an error condition and an exception being propagated upstream to the caller.
Optional. |
15 | 引用待评估 XPath 表达式实例。 |
16 | Reference to an XPath expression instance to evaluate. |
17 | 此子元素设置要评估的 XPath 表达式。如果您不包含此元素,则必须设置 xpath-expression-ref 属性。此外,您只能包含一个 xpath-expression 元素。 |
18 | This child element sets the XPath expression to be evaluated.
If you do not include this element, you must set the xpath-expression-ref attribute.
Also, you can include only one xpath-expression element. |
19 | 与 XPath 过滤器一同使用轮询器。可选。 |
20 | A poller to use with the XPath filter. Optional. |