INT-3140: Add #xpath() SpEL Function Support
JIRA: https://jira.springsource.org/browse/INT-3140 * Introduce `XPathUtils` * Add `#xpath()` tests * Add documentation INT-3140: Polishing according PR comments INT-3140 Polishing - Doc and javadoc polishing - Fix some compiler warnings (not all xpath)
This commit is contained in:
committed by
Gary Russell
parent
fa59b50bdc
commit
88de8117aa
@@ -176,13 +176,11 @@
|
||||
</note>
|
||||
For more information regarding JSON see 'JSON Transformers' in <xref linkend="transformer"/>.
|
||||
</listitem>
|
||||
<listitem>
|
||||
<emphasis role="bold">#xpath</emphasis> - to evaluate an 'xpath' on some provided object.
|
||||
For more information regarding xml and xpath see <xref linkend="xml"/>.
|
||||
</listitem>
|
||||
<!--<listitem>
|
||||
<emphasis>#xpath</emphasis> - TBD
|
||||
</listitem>
|
||||
<listitem>
|
||||
<emphasis>#request</emphasis> - TBD
|
||||
</listitem>
|
||||
<listitem>
|
||||
<emphasis>#auth</emphasis> - TBD
|
||||
</listitem>-->
|
||||
</itemizedlist>
|
||||
|
||||
@@ -361,6 +361,13 @@ public class Foo {
|
||||
In addition to JSON Transformers, Spring Integration provides a built-in <emphasis>#jsonPath</emphasis>
|
||||
SpEL function for use in expressions. For more information see <xref linkend="spel"/>.
|
||||
</para>
|
||||
<para>
|
||||
<emphasis role="bold">#xpath SpEL Function</emphasis>
|
||||
</para>
|
||||
<para>
|
||||
Since version <emphasis>3.0</emphasis>, Spring Integration also provides a built-in <emphasis>#xpath</emphasis>
|
||||
SpEL function for use in expressions. For more information see <xref linkend="xpath-spel-function"/>.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="transformer-annotation">
|
||||
|
||||
@@ -117,8 +117,9 @@
|
||||
<title>SpEL Functions Support</title>
|
||||
<para>
|
||||
To customize the SpEL <interfacename>EvaluationContext</interfacename> with static
|
||||
<classname>Method</classname> functions the new <code><spel-function/></code>
|
||||
component is introduced. For more information see <xref linkend="spel-functions" />.
|
||||
<classname>Method</classname> functions, the new <code><spel-function/></code>
|
||||
component is introduced. Two built-in functions are also provided (<code>#jsonPath</code>
|
||||
and <code>#xpath</code>). For more information see <xref linkend="spel-functions" />.
|
||||
</para>
|
||||
</section>
|
||||
<section id="3.0-spel-property-accessors">
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
<listitem>
|
||||
<para><emphasis><link linkend='xml-xpath-filter'>XPath Filter</link></emphasis></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis><link linkend='xpath-spel-function'>#xpath SpEL Function</link></emphasis></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><emphasis><link linkend='xml-validating-filter'>Validating Filter</link></emphasis></para>
|
||||
</listitem>
|
||||
@@ -1253,6 +1256,39 @@
|
||||
</calloutlist></para>
|
||||
</section>
|
||||
|
||||
<section id="xpath-spel-function">
|
||||
<title>#xpath SpEL Function</title>
|
||||
<para>
|
||||
Spring Integration, since version <emphasis>3.0</emphasis>, provides the <code>#xpath</code>
|
||||
built-in SpEL function, which invokes the static method <code>XPathUtils.evaluate(...)</code>.
|
||||
This method delegates to an <interfacename>org.springframework.xml.xpath.XPathExpression</interfacename>.
|
||||
The following shows some usage examples:
|
||||
<programlisting language="xml"><![CDATA[<transformer expression="#xpath(payload, '/name')"/>
|
||||
|
||||
<filter expression="#xpath(payload, headers.xpath, 'boolean')"/>
|
||||
|
||||
<splitter expression="#xpath(payload, '//book', 'document_list')"/>
|
||||
|
||||
<router expression="#xpath(payload, '/person/@age', 'number')">
|
||||
<mapping channel="output1" value="16"/>
|
||||
<mapping channel="output2" value="45"/>
|
||||
</router>]]></programlisting>
|
||||
<code>#xpath</code> also supports a third optional parameter for converting the result of the xpath evaluation.
|
||||
It can be
|
||||
one of the String constants <code>'string'</code>, <code>'boolean'</code>, <code>'number'</code>,
|
||||
<code>'node'</code>, <code>'node_list'</code> and <code>'document_list'</code> or an
|
||||
<interfacename>org.springframework.xml.xpath.NodeMapper</interfacename> instance.
|
||||
By default the <code>#xpath</code> SpEL function returns a String representation of the xpath evaluation.
|
||||
</para>
|
||||
<note>
|
||||
To enable the <code>#xpath</code> SpEL function, simply add the <code>spring-integration-xml.jar</code>
|
||||
to the CLASSPATH; there is no need to declare any component(s) from the Spring Integration Xml Namespace.
|
||||
</note>
|
||||
<para>
|
||||
For more information see <xref linkend="spel"/>.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="xml-validating-filter">
|
||||
<title>XML Validating Filter</title>
|
||||
<para>
|
||||
|
||||
Reference in New Issue
Block a user