title: Programmatically resolve Thymeleaf templates
body: <p>I'm trying to render XML/JSON using Thymeleaf templates. I don't want to render a view using the template name, just want to resolve the template as shown below. Trouble is all I get back is the template name, not it's content.</p>
  
  <p><strong>Set up:</strong></p>
  
  <pre><code>@Bean
  SpringResourceTemplateResolver xmlTemplateResolver(ApplicationContext appCtx) {
      SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
  
      templateResolver.setApplicationContext(appCtx);
      templateResolver.setPrefix("classpath:/templates/");
      templateResolver.setSuffix(".xml");
      templateResolver.setTemplateMode(XML);
      templateResolver.setCharacterEncoding(UTF_8.name());
      templateResolver.setCacheable(false);
  
      return templateResolver;
  }
  
  @Bean
  SpringTemplateEngine templateEngine(ApplicationContext appCtx) {
      SpringTemplateEngine templateEngine = new SpringTemplateEngine();
      templateEngine.addTemplateResolver(xmlTemplateResolver(appCtx));
  
      return templateEngine;
  }
  </code></pre>
  
  <p><strong>Template (src/main/resources/templates/breakfast-menu.xml):</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;breakfast_menu&gt;
      &lt;food&gt;
          &lt;name&gt;${item['name']}&lt;/name&gt;
          &lt;price&gt;${item['price']}&lt;/price&gt;
          &lt;description&gt;${item['description']}&lt;/description&gt;
          &lt;calories&gt;${item['calories']}&lt;/calories&gt;
      &lt;/food&gt;
  &lt;/breakfast_menu&gt;
  </code></pre>
  
  <p><strong>Usage:</strong></p>
  
  <pre><code>@Autowired
  SpringTemplateEngine templateEngine;
  
  someMethod() {
      Context context = new Context();
      context.setVariable("item", item);
      item.put("name", "Waffle");
      String content = templateEngine.process("breakfast-menu", context);
  
      // content == "breakfast-menu". WTH?
  }
  </code></pre>
  
  <p>Using Thymeleaf 3.0.0.BETA01.</p>