Java 如何使用Thymeleaf模板引擎将带有可变参数的处理指令注入XML

Java 如何使用Thymeleaf模板引擎将带有可变参数的处理指令注入XML,java,xml,spring,thymeleaf,processing-instruction,Java,Xml,Spring,Thymeleaf,Processing Instruction,我正在使用Thymeleaf创建一个基于模板的XML文档 来自模板(此处仅显示其中的一部分) ,但无法找到有关XML处理指令的任何信息。我找到了一种解决方法,可以帮我完成这项工作: <A> <span th:utext="${'<?foo bar=&quot;' + barValue + '&quot; ?>'}" th:remove="tag"></span> </A> <A> <?foo

我正在使用Thymeleaf创建一个基于模板的XML文档

来自模板(此处仅显示其中的一部分)


,但无法找到有关XML处理指令的任何信息。

我找到了一种解决方法,可以帮我完成这项工作:

<A>
  <span th:utext="${'<?foo bar=&quot;' + barValue + '&quot; ?>'}" th:remove="tag"></span>
</A>
<A>
  <?foo bar="baz" ?>
</A>
<A>
  <span th:utext="${'<?foo bar=&quot;' + barValue + '&quot; ?>'}" th:remove="tag"></span>
</A>
Context context = new Context();
context.setVariable("barValue", "baz");
String xml = templateEngine.process("document1", context);