简体   繁体   English

骆驼Java DSL中用于比较属性值的表达式

[英]Expression for comparing attribute value in camel Java DSL

I'd like to write an expression with XPath for comparing an attribute value in my xml message header with a certain value to direct it to an appropriate folder. 我想用XPath编写一个表达式,将我的xml消息标题中的属性值与某个值进行比较,以将其定向到适当的文件夹。 The XML header is XML标头是

?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="cda\render\cda.xsl"?>
    <Books xmlns="urn:hl7-org:v3"
        xmlns:classCode="DOCCLIN" xmlns:moodCode="EVN"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:hl7-org:v3 ./cda_r2_normativewebedition2010/infrastructure/cda/CDA.xsd">
        <realmCode code="DE" />
        <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040" />
        <templateId root="2.16.840.1.113883.10.20.29" />
        <templateId root="2.16.840.1.113883.10.20.33" />
        <templateId root="2.16.840.1.113883.10.20.33.1.1" />
        <id extension="2015121415313522" />
        <code code="12.3.34.65" codeSystem="2.16.840.1.113883.6.1"
            codeSystemName="LOINC" displayName="Document" />
        <title>Prices</title>
        <effectiveTime value="201512141531+0000" />
        <confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25" />
        <languageCode code="de-DE" />

I would like to compare a certain node attirbute (Attribute code of the code Element) to a value and direct it to a folder it that holds true. 我想将某个节点属性(代码元素的属性代码)与一个值进行比较,然后将其定向到保存为真的文件夹中。

I wrote something like 我写了类似

from("file:testxml/")
                .choice()
                .when()
//              .xpath("urn:hl7-org:v3:Books/urn:hl7-org:v3:code/@code = '12.3.34.65'")
                .xpath("urn:hl7-org:v3:ClinicalDocument/urn:hl7-org:v3:code[@code='12.3.34.65']")
                .to("file:xPath/")
                .to("direct:xpath");

            }

I want to check whether the value of the attribute is '12.3.34.65'. 我想检查属性的值是否为“ 12.3.34.65”。 Could you please correct me and let me know to how to write the xpath expression in the right manner. 您能否更正我,让我知道如何以正确的方式编写xpath表达式。

Thanks a lot! 非常感谢!

You sample xml is not valid. 您样本的xml无效。 Also the attribute code of code element is not '12.3.34.65'. 同样,代码元素的属性代码也不为“ 12.3.34.65”。 Try below to redirect output to destinationFolder. 请尝试以下将输出重定向到destinationFolder。

from("file:testxml")
 .choice()
  .when()
   .xpath("/Books/code[@code='x.x.x.x']")
   .to("file:destinationFolder");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM