【问题标题】:Camel XPATH choice on xmlns attribute containsxmlns 属性上的 Camel XPATH 选择包含
【发布时间】:2021-08-28 09:14:20
【问题描述】:

我想在包含值的 xml 命名空间上使用选择。

<Document xmlns="www.ddd.test.123.001">
 <properties>...
</Document>

骆驼:

from("direct:in")
        .choice()
            .when().xpath("/Document[@xmlns, contains(., 'test.123')]")
        .to("mock:pain:001")

xmlns 包含我想使用的路由值。 有可能吗?正确的骆驼 XPath 字符串是什么?

【问题讨论】:

    标签: xml xpath apache-camel


    【解决方案1】:

    我不知道 Camel,但在 XPath 1.0 中会是

    "/*[local-name() = 'Document' and contains(namespace-uri(), 'test.123')]"
    

    您不能使用/Document,因为它只会匹配没有命名空间中的 Document 元素。

    【讨论】:

    • 不错的一个!谢谢,返回命名空间值的方法是什么?
    • namespace-uri(/*)
    猜你喜欢
    • 2012-10-12
    • 2012-02-20
    • 1970-01-01
    • 2023-03-05
    • 2013-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多