java xpathexpression,java-具有节点功能的Spring int-xml:xpath-expression错误

我使用XMLSpy编写以下XPath来确定最长的字符串长度,并且它可以在XMLSpy中使用:

string-length(//exception:ElementMessageAbcException/@exceptionMsg[not(string-length(.) < //exception:ElementMessageAbcException/@exceptionMsg/string-length(.))] )

但是,当我在春季集成中将相同的字符串放入xpath-expression中时,会出错:

org.springframework.beans.factory.BeanCreationException: Error

creating bean with name ‘xpathMaxLengthExceptionMsg’: Instantiation of

bean failed; nested exception is

org.springframework.beans.factory.BeanDefinitionStoreException:

Factory method [public static

org.springframework.xml.xpath.XPathExpression

org.springframework.xml.xpath.XPathExpressionFactory.createXPathExpression(java.lang.String,java.util.Map)

throws

java.lang.IllegalStateException,org.springframework.xml.xpath.XPathParseException]

threw exception; nested exception is

org.springframework.xml.xpath.XPathParseException: Could not compile

[//exception:MarkitMessageAciException/@exceptionMsg[not(string-length()

<

//exception:MarkitMessageAciException/@exceptionMsg/string-length())]]

to a XPathExpression: null; nested exception is

javax.xml.xpath.XPathExpressionException Caused by: javax.xml.transform.TransformerException: Unknown nodetype: string-length

样本XML:

confirmTs="2014-10-14T11:43:36.191-05:00"

correlationId="ORG-1008891250014" numberAccepted="0"

numberRejected="1" status="exception"

xmlns:ack="http://www.example.net/imdwrd/schemas/Element-message-Abc-ack"

xmlns:confirm="http://www.example.net/imdwrd/schemas/Element-message-Abc-confirm"

xmlns:event="http://www.example.net/imdwrd/schemas/data-source-event"

xmlns:exception="http://www.example.net/imdwrd/schemas/Element-message-Abc-exception"

xmlns:internalClassification="http://www.example.net/imdwrd/schemas/Element-internal-classification"

xmlns:ns9="http://www.example.net/imdwrd/schemas/Element-message-Abc"

xmlns:organization="http://www.example.net/imdwrd/schemas/Element-organization-Abc"

xmlns:pricing="http://www.example.net/imdwrd/schemas/Element-pricing-Abc" xmlns:security="http://www.example.net/imdwrd/schemas/Element-security-Abc">

exceptionMsg="[property]=Organization [message]=Organization information has not changed. Update request has been cancelled."

exceptionType="informational" id="385059141722030" type="organization"/>

exceptionMsg="[property]=Organization [message]=Organizatiosn information has not changed. Update request has been cancelled. longer"

exceptionType="informational" id="385059141722030" type="organization"/>

解决方法:

我不知道XML Spy是如何工作的,但是我看到了这一点:

/@exceptionMsg/string-length(.)

是错误的语法. string-length()实际上是xPath函数,但它不是XML的节点.

目前尚不清楚您的目标是什么,但我希望它能对您有所帮助.

UPDATE

好吧,我已经知道发生了什么事.

因此,您应该使用其他一些库. Saxon是此事上最好的.

但是,您应该这样做:

-Djavax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom=net.sf.saxon.xpath.XPathFactoryImpl

或以编程方式指定该System属性.

标签:spring-integration,java,spring,xml,xpath

来源: https://codeday.me/bug/20191013/1911035.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值