Having TemplateException or NumberFormatException

ven12344 <[email protected]> Wed, 10 Sep 2014 15:23:29 -0700 (PDT)
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Hi, All

Need help with Freemarker local variable comparison with a constant or local
constant variable, tried both but did not work

*FIRST APPROACH*

I have code like this

<#local level = doc["XPath..../@level"]>

"doc" here is the passed in XML document to freemarker and I am getting the
level (this is attribute in XML which will give the level of the element
like 1,2,3...) info using XPath and comparing to a constant local variable
like this 

<#if (symbolLevel > levelTest)><#t>

where

<#local levelTest = 4>

For this bit of code I got this exception

freemarker.template.TemplateException: The only legal comparisons are
between two numbers, two strings, or two dates.
Left  hand operand is a freemarker.ext.dom.AttributeNodeModel
Right hand operand is a freemarker.template.SimpleNumber


*SECOND APPROACH*

I have code like this

<#local level = doc["number(XPath..../@level)"]>

and I am getting the level info using XPath's *number function* and
comparing to a constant local variable like this 

<#if (symbolLevel > 4)><#t>

For this bit of code I got the same exception as the third approach.


*THIRD APPROACH*

I have code like this

<#local level = doc["number(XPath..../@level)"]>

and I am getting the level info using XPath's *number function* and
comparing to a constant local variable like this 

<#if (symbolLevel > levelTest)><#t>

For this bit of code I got this exception

java.lang.NumberFormatException
	at java.math.BigDecimal.<init>(BigDecimal.java:459)
	at java.math.BigDecimal.<init>(BigDecimal.java:728)
	at freemarker.core.ArithmeticEngine.toBigDecimal(ArithmeticEngine.java:529)
	at freemarker.core.ArithmeticEngine.access$000(ArithmeticEngine.java:68)
	at
freemarker.core.ArithmeticEngine$BigDecimalEngine.compareNumbers(ArithmeticEngine.java:142)
	at
freemarker.core.ComparisonExpression.isTrue(ComparisonExpression.java:131)
	at
freemarker.core.ParentheticalExpression.isTrue(ParentheticalExpression.java:66)
	at freemarker.core.IfBlock.accept(IfBlock.java:80)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:179)
	at freemarker.core.Environment.visit(Environment.java:415)
	at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.Environment.visit(Environment.java:297)
	at freemarker.core.UnifiedCall.accept(UnifiedCall.java:130)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.Macro$Context.runMacro(Macro.java:163)
	at freemarker.core.Environment.visit(Environment.java:601)
	at freemarker.core.UnifiedCall.accept(UnifiedCall.java:106)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
	at freemarker.core.Environment.visit(Environment.java:208)
	at freemarker.core.Environment.process(Environment.java:188)
	at freemarker.template.Template.process(Template.java:237)




--
View this message in context: http://freemarker.624813.n4.nabble.com/Having-TemplateException-or-NumberFormatException-tp4655267.html
Sent from the freemarker-user mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk