I have the following XML
<root
xmlns="urn:hl7-org:v3">
<head>
<leaf>l123</leaf>
</head>
</root>
I have a main FTL file
Main.ftl
<#ftl ns_prefixes={"D":"urn:hl7-org:v3"}>
<#import "support.ftl" as aux/>
<@aux.support inp=inputXML["D:root"].head/>
and a supporting file with a macro
<#macro support inp>
${inp.leaf}
</#macro>
when i run these I am getting the following error
An error occurred while transforming input message using FreeMarker template: For "${...}" content: Expected a string or something automatically convertible to string (number, date or boolean), or "template output" , but this has evaluated to a sequence+hash (wrapper: f.e.dom.NodeListModel): ==> inp.leaf [in template "support.ftl" at line 2, column 3]
The template works if I pass the string to the supporting FTL instead of the XML
Main.ftl
<#ftl ns_prefixes={"D":"urn:hl7-org:v3"}>
<#import "support.ftl" as aux/>
<@aux.support inp=inputXML["D:root"].head.leaf/>
and a supporting file with a macro
<#macro support inp>
${inp}
</#macro>
This is just an example, my XML is big and I have many supporting FTLs, so I would like to pass XML instead of passing strings and creating a lot of parameters.
How do I do that?
Thanks
Found the solution.
This can be achieved by making the macro with no parameters.
The complete XML is passed if there are no parameters in the macro.
So if my macro is as follows:
<#macro support >
${inputXML["D:root"].head.leaf}
</#macro>
it works.