0

我正在尝试在 Mule 中的 XPath 表达式下运行。它一个接一个地给我错误。有人可以帮我纠正这些 Mule XPath 表达式:

 <xm:namespace-manager includeConfigNamespaces="true">
      <xm:namespace prefix="acord" uri="ACORD.org/Standards/Life/2" />
      <xm:namespace prefix="soap" uri="schemas.xmlsoap.org/soap/envelope/" />
    </xm:namespace-manager>

    <set-variable variableName="pwaHolding"
         value="#[xpath('//acord:TXLife/acord:TXLifeRequest/acord:OLifE/acord:Relation[acord:RelationRoleCode/@tc = '37']/@OriginatingObjectID').value" />
    <set-variable variableName="pwaPolNumber"
         value="#[xpath('//acord:TXLife/acord:TXLifeRequest/acord:OLifE/acord:Holding[@id=$pwaHolding]/acord:Policy/acord:PolNumber').text]" />

尝试在 XPATH 表达式上方执行时出现异常:

    Message  :Execution of the expression "xpath('//acord:TXLife/acord:TXLifeRequest/acord:OLifE/acord:Relation[acord:RelationRoleCode/@tc == '37']/@OriginatingObjectID').value" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: String
    Code                  : MULE_ERROR--2
    --------------------------------------------------------------------------------
    Exception stack is:
    1. [Error: unexpected token: 37]
    [Near : {... @tc == '37']/@OriginatingObjec ....}]
                                  ^
    [Line: 1, Column: 96] (org.

mvel2.CompileException)
org.mvel2.compiler.ExpressionCompiler:247 (null)
2. Execution of the expression "xpath('//acord:TXLife/acord:TXLifeRequest/acord:OLifE/acord:Relation[acord:RelationRoleCode/@tc == '37']/@OriginatingObjectID').value" failed. (org.mule.api.expression.ExpressionRuntimeException)
org.mule.el.mvel.MVELExpressionLanguage:211 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/ExpressionRuntimeException.html)
3. Execution of the expression "xpath('//acord:TXLife/acord:TXLifeRequest/acord:OLifE/acord:Relation[acord:RelationRoleCode/@tc == '37']/@OriginatingObjectID').value" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: String (org.mule.api.transformer.TransformerMessagingException)
org.mule.transformer.AbstractTransformer:123 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerMessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
[Error: unexpected token: 37]
[Near : {... @tc == '37']/@OriginatingObjec ....}]                              ^
[Line: 1, Column: 96]
at org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:247)
at org.mvel2.util.ParseTools.subCompileExpression(ParseTools.java:1944)
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:862) 
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

嗨大卫,

我什至在替换后'仍然&quot;出现以下错误:

消息:执行表达式“xpath('//acord:TXLife/acord:TXLifeRequest/acord:OLifE/acord:Relation[acord:RelationRoleCode/@tc == '37']/@OriginatingObjectID').value”失败。(org.mule.api.expression.ExpressionRuntimeException)。消息有效负载的类型:字符串
代码:MULE_ERROR--2
-------------------------------------------------- ------------------------------
异常堆栈是:
1. [错误:意外令牌:37]
[附近:{... @tc == '37']/@OriginatingObjec ....}]
                      ^
[行:1,列:96](org.mvel2.CompileException)
  org.mvel2.compiler.ExpressionCompiler:247(空)
2. 表达式“xpath('//acord:TXLife/acord:TXLifeRequest/acord:OLifE/acord:Relation[acord:RelationRoleCode/@tc == '37']/@OriginatingObjectID').value”的执行失败。(org.mule.api.expression.ExpressionRuntimeException)
  org.mule.el.mvel.MVELExpressionLanguage:211 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/ExpressionRuntimeException.html)
3. 表达式“xpath('//acord:TXLife/acord:TXLifeRequest/acord:OLifE/acord:Relation[acord:RelationRoleCode/@tc == '37']/@OriginatingObjectID').value”的执行失败。(org.mule.api.expression.ExpressionRuntimeException)。消息负载的类型:字符串(org.mule.api.transformer.TransformerMessagingException)
  org.mule.transformer.AbstractTransformer:123 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerMessagingException.html)

我有第二个 XPATH 表达式有问题,它也失败了。请帮助我解决这个问题

4

1 回答 1

3

该错误来自您'在由 分隔的字符串中使用 a 的事实',这是行不通的。例如,在以下表达式中,问题在于'37'

value="#[xpath('//acord:TXLife/acord:TXLifeRequest/acord:OLifE/acord:Relation[acord:RelationRoleCode/@tc = '37']/@OriginatingObjectID').value" />

另一个问题是]MEL 表达式末尾缺少结束符。

尝试:

value="#[xpath(&quot;//acord:TXLife/acord:TXLifeRequest/acord:OLifE/acord:Relation[acord:RelationRoleCode/@tc = '37']/@OriginatingObjectID&quot;).value" />

查看您的第二个 XPath,我看到了[@id=$pwaHolding]. 我假设此时您正在尝试使用pwaHolding由第一个 XPath 提取的流变量。这将不起作用,因为 MVEL 没有字符串插值。您需要改为使用连接,顺便说一下,不要忘记单引号将该值@id与以下内容进行比较:

[@id‌='&quot; + pwaHolding + &quot;']
于 2013-07-25T18:38:05.890 回答