freemarkerxdocreport

xDocReport logical and error


I know freemarker logical and is &&, but when I used it in xDocReport, an error occurred: SystemId Unknown; Line #4; Column #2796; The entity name must immediately follow the '&' in the entity reference.. I changed it to && and \u0026\u0026, neither worked.

code detail: «[#if scope!='a' && scope!='b']»

I think it is a basic usage. Do I miss something? thx!

p.s. From the error message, directive <and> may be used, but i cannot find any tech doc about it.


Solution

  • Templates themselves aren't meant to be valid XML fragments, but from what you are saying, in XDocReport they apparently have to be. To achieve that, starting from FreeMarker 2.3.27 you can write \and or &amp;&amp; instead of &&. (Also, you can write &lt; and &gt; instead of < and >; see https://freemarker.apache.org/docs/dgui_template_exp.html#dgui_template_exp_comparison).

    Before 2.3.27, && has no alternative syntax, so you will have to rewrite those expressions so that they don't use logical "and"... like !(scope == 'a' || scope == 'b') in your case.