다음과 같은 구성을 시도 할 수 있습니다 : 당신의 XML 소스의 많은 속성, 그냥 따라 enricher 요소를 추가해야하는지에 관계없이
<enricher doc:name="Message Enricher">
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
%var evaluation = "ABC"
%var substitution = "BC"
%function substitute(serverVal)(
serverVal when serverVal != evaluation otherwise substitution
)
---
[email protected] mapObject {
($$): substitute($)
}
]]></dw:set-payload>
</dw:transform-message>
<enrich source="#[payload.Server]" target="#[variable:param1]"/>
<enrich source="#[payload.Server2]" target="#[variable:param2]"/>
</enricher>
합니다. <enrich source="#[payload.Server3]" target="#[variable:param3]"/>
새로운 변수를 설정 :
<Interface Server="ABC" Server2="DEF" Server3="ABC"/>
그런 다음 당신은 단지 추가해야합니다
예를 들어, 당신은 새로운 XML 소스를 가지고있다.
주 : DataWeave은 EE 중 하나입니다. CE의 경우 다른 변압기로 교체 할 수 있습니다 (예 : Groovy). 아래 예에서 페이로드는 String 형식입니다. 원래 응용 프로그램/xml 형식은 byte-array-to-string-transformer
을 사용하여 String으로 변환됩니다. 이후이 CE를 실행 해요 -
<scripting:component doc:name="Groovy">
<scripting:script engine="Groovy"><![CDATA[def attributeMap = new XmlSlurper().parseText(payload).attributes()
attributeMap.each() {
it.value = it.value == "ABC" ? "BC" : it.value
}
payload = attributeMap]]></scripting:script>
</scripting:component>
니스 접근, 나는 흠, 내가 SAXParser를 예외를 받고 있어요 갈이 – elwis
, DataWeave 만한다는 것을주지? – elwis
* DataWeave *는 ** EE ** 기능 중 하나입니다. Groovy를 대체 할 대체 답변을 업데이트했습니다. –