cancel
Showing results for 
Search instead for 
Did you mean: 

Error generating rendition using...

jeff
Champ in-the-making
Champ in-the-making
I'm trying to use a web form to create a html document using a ftl. template.  IN step three of using the web form I receive the following error:

Error generating rendition using document.ftl: Encountered "{" at line 4, column 18. Was expecting one of: "in" … ">" … <EMPTY_DIRECTIVE_END> … "." … "[" … "(" … "?" … "!" … "??" … "+" … "-" … "*" … "/" … "%" … "!=" … "=" … "==" … ">=" … <ESCAPED_GTE> … ">" … <ESCAPED_GT> … <LESS_THAN_EQUALS> … <LESS_THAN> … ".." … <AND> … <OR> … "," … <ID> … <STRING_LITERAL> …

The xml file is produced fine, but no html file is produced.  The contents of my document.ftl are:

<html>
<body>
<#– <#if document.mimetype = "text/xml"> –>
   <#assign dom=${name}.xmlNodeModel>
   <h1>${dom.book.@title}</h1>
   <#list dom.book.chapter as c>
      <h2>${c.title}</2>
   </#list> 
<#– </#if> –>
</body>
</html>

Any insight to the error message would be much appreciated!
6 REPLIES 6

mikeh
Star Contributor
Star Contributor
In Freemarker, you only need to use the ${variable} syntax when you're not already in a Freemarker statement.

So instead of
<#assign dom=${name}.xmlNodeModel>
try
<#assign dom=name.xmlNodeModel>

Thanks,
Mike

jeff
Champ in-the-making
Champ in-the-making
Hi Mike,

Thanks so much for your quick reply.  I've removed the brackets as suggested so now I have:

<html>
<body>
<#– <#if document.mimetype = "text/xml"> –>
   <#assign dom=name.xmlNodeModel>
   <h1>${dom.book.@title}</h1>
   <#list dom.book.chapter as c>
      <h2>${c.title}</2>
   </#list> 
<#– </#if> –>
</body>
</html>

However, after trying to run this through the web form I can still create the xml file fine, but I receive this error:

Error generating rendition using document.ftl: freemarker.core.NonStringException: Error on line 5, column 10 in freemarker_template Expecting a string, date or number here, Expression dom.book.@title is instead a freemarker.ext.dom.NodeListModel

without the successful creation of the html file.

I've specified dom.book.@title both as a normalizedString and as a string on separate occasions.

I've also tried dom.book.title as an element rather than an attribute with the same error result. 

Could you please shed some light on this error?

thanks,
Jeff

mikeh
Star Contributor
Star Contributor
Could you post the XML you're trying to parse please?

Thanks,
Mike

mikeh
Star Contributor
Star Contributor
I think the line "<#assign dom=${name}.xmlNodeModel>" is useless, have you seen this page : http://freemarker.org/docs/dgui_quickstart_basics.html an this one : http://freemarker.sourceforge.net/docs/xgui_imperative_learn.html ?
You need to read the whole help page… including the second sentence  :wink:
Assume that the programmer has put the XML document into the data-model as variable doc.

Mike

jeff
Champ in-the-making
Champ in-the-making
Hi isa and Mike,

Thanks to both of you for your help!  I've got it to work now.  Isa, you are correct, I did not require "NodeModel".  Also, I was trying to access the variables incorrectly, instead of dom.book.chapter I should have only been using book.chapter.

It can only be onward and upward from here! 

Thanks again.
Jeff

mikeh
Star Contributor
Star Contributor
Thanks for the follow-up. I hadn't realised you were talking about WCM, but re-reading your question it's clear you were!

Glad the issue is fixed.

Thanks,
Mike