373.5. 使用 XQuery 作为转换
我们可以在路由中使用转换或设置消息转换,如下所示:
from("direct:start"). transform().xquery("/people/person");
from("direct:start").
transform().xquery("/people/person");
请注意,xquery 默认将使用 DOMResult。因此,如果我们希望获取用户角色节点的值,则需要使用 text ()告知 xquery 使用 String 作为结果类型,如下所示:
from("direct:start"). transform().xquery("/people/person/text()", String.class);
from("direct:start").
transform().xquery("/people/person/text()", String.class);