복붙노트

[SPRING] Spring int-xml : 노드 함수가있는 xpath-expression 오류

SPRING

Spring int-xml : 노드 함수가있는 xpath-expression 오류

XMLSpy를 사용하여 다음 XPath를 작성하여 가장 긴 문자열 길이를 결정했으며 XMLSpy에서 작동합니다.

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

그러나 스프링 통합에서 xpath 표현식에 같은 문자열을 넣으면 오류가 발생합니다.

<int-xml:xpath-expression id="xpathMaxLengthExceptionMsg" expression="//exception:ElementMessageAciException/@exceptionMsg[not(string-length(.) &lt; //exception:ElementMessageAciException/@exceptionMsg/string-length(.))]">
    <map>
        <entry key="pricing" value="http://www.example.net/imdwrd/schemas/Element-pricing-aci" />
        <entry key="security" value="http://www.example.net/imdwrd/schemas/Element-security-aci" />
        <entry key="tns" value="http://www.example.net/imdwrd/schemas/Element-message-aci" />
        <entry key="internalClassification" value="http://www.example.net/imdwrd/schemas/Element-internal-classification" />
        <entry key="organization" value="http://www.example.net/imdwrd/schemas/Element-organization-aci" />
        <entry key="exception" value="http://www.example.net/imdwrd/schemas/Element-message-aci-exception"/>
        <entry key="xsi" value="http://www.w3.org/2001/XMLSchema-instance" />
    </map>
</int-xml:xpath-expression>

샘플 XML :

<?xml version="1.0" encoding="UTF-8"?>
<confirm:ElementMessageAbcConfirm
  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">
  <exception:ElementMessageAbcException exceptionCode="1000"
    exceptionMsg="[property]=Organization [message]=Organization information has not changed.  Update request has been cancelled."
    exceptionType="informational" id="385059141722030" type="organization"/>
 <exception:ElementMessageAbcException exceptionCode="1000"
    exceptionMsg="[property]=Organization [message]=Organizatiosn information has not changed.  Update request has been cancelled. longer"
    exceptionType="informational" id="385059141722030" type="organization"/>    
</confirm:ElementMessageAbcConfirm>

해결법

  1. ==============================

    1.나는 XML 스파이가 어떻게 작동하는지 모르지만, 나는 이것을 볼 수있다.

    나는 XML 스파이가 어떻게 작동하는지 모르지만, 나는 이것을 볼 수있다.

    /@exceptionMsg/string-length(.)
    

    잘못된 구문입니다. string-length ()는 실제로 xPath 함수이지만 XML의 노드는 아닙니다.

    그것은 당신의 목표가 무엇인지는 아직 명확하지 않지만, 그것이 올바른 방향으로 가도록 약간 도움이되기를 바랍니다.

    최신 정보

    글쎄, 무슨 일이 일어나는지 알아 냈어.

    XPath 2를 사용합니다 (XPath에서 가장 긴 자식 #text 노드 값을 갖는 XML 노드를 선택하려면 어떻게해야합니까?)하지만 Java에는 기본적으로 해당 기능이 없습니다.

    그래서 다른 라이브러리를 사용해야합니다. 색슨은이 문제에있어 최고의 사람입니다.

    그러나 당신은 이것을해야합니다 :

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

    또는 System 속성을 프로그래밍 방식으로 지정하십시오.

  2. from https://stackoverflow.com/questions/26496211/spring-int-xmlxpath-expression-erros-with-node-function by cc-by-sa and MIT license