xml을 세션 변수에 저장하는 mule flow가 있습니다. 이 xml을 groovy에서 생성 된 xml에 삽입하고 싶습니다. 내가 아래 등 내 xmlmarkup 빌더에 세션 변수를 사용하면이 세션 변수가 <a><Subject1>science</Subject1><Subject2>Maths</Subject2></a>
xml 빌드 및 그루비를 사용하여 CDATA xml 병합
있다
#[sessionVars.shippingdetails]
처럼
내 세션 변수가 보인다. 나는 그러므로 내 출력 XML은 다음과 같이한다
import groovy.xml.XmlUtil
def builder = new groovy.xml.StreamingMarkupBuilder()
builder.encoding = "UTF-8"
// MAPPING
def person = {
// use mkp object which provides features like setting the namespace
mkp.xmlDeclaration()
mkp.declareNamespace("":"urn:abc:alos:BaseComponents")
//start with the XML root node closure
ItemRequest {
Requester{
subject(message.payload.subject)
}
Item{
Title(message.payload.name)
Description(message.payload.desc)
Category {
CategoryID(message.payload.cat_id)
}
ConditionID (message.payload.condition)
Mark (message.payload.Mark)
ShippingDetails [CDATA[sessionVars.shippingdetails]]
}
}
}
// WRITING
def writer = new StringWriter()
writer << builder.bind(person)
println writer.toString()
XmlUtil.serialize(builder.bind(person))
groovy.lang.GroovyRuntimeException: Namespace prefix: CDATA is not bound to a URI (javax.script.ScriptException). Message payload is of type: CaseInsensitiveHashMap (org.mule.api.transformer.TransformerMessagingException). Message payload is of type: CaseInsensitiveHashMap
으로 오류를 얻고있다.
<?xml version="1.0" encoding="UTF-8"?>
<ItemRequest xmlns="urn:abc:alos:BaseComponents">
<Requester>
<subject>something</subject>
</Requester>
<Item>
<Title>Cooler Can Blue</Title>
<Description>This is the place for description.</Description>
<Category>
<CategoryID>562</CategoryID>
</Category>
<ConditionID>25</ConditionID>
<Mark>3</Mark>
<ShippingDetails>
<a>
<Subject1>science</Subject1>
<Subject2>Maths</Subject2>
</a>
</ShippingDetails>
</Item>
</ItemRequest>