I think this question is not going to be answered, what i need to know is the reason. Is it not well written or do i need to add more details?.
To sum up, i need to know if given a message there is a way to check whether an element exists or not (with namespace included) and add it myself if it isn't included.
Anything would help.
Hi Carlos... I got your private message... here's the answer...
Sounds like you have 2 issues... handling a large/huge message and conditionally adding a header element.
Handle the huge message by setting th filter type to SAX (default is DOM => can't handle big messages) See User Guide.
For conditionally adding the header... in the versions of Smooks in the ESB (easier in newer versions of Smooks)... easiest way is prob to do something like the following...
<jb:bean beanId="headerDetails" class="java.util.HashMap" createOnElement="order/header">
<jb:value property="secureId" data="order/header/secureId" />
<ftl:template><!-- <secureId>blah</secureId> --></ftl:template>
<ftl:inline directive="addto" />
So.. capture details about the data in the header into a HasMap and then add a conditional on a template (having an "addto" directive) that's applied to the header fragment.
Oh and... make sure to check the MVEL user docs re the use of "isdef" in the conditional... what I have there might not be 100% right, but it would be something like that.
Thanks Tom, i'm trying to use your solution, but that code works for an element inside the header right? In my case, the whole header may not be present (<header>...<header>) at all, for example, could be like this:
So, the result message after the transformation is:
Because the "add" directive locates the element at the end of the selector (Envelope in this case)
Is it possible to modify a little bit your solution to make it works for my particular scenario?
Thank you very much.