Quantcast

Assigning dynamic variables

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Assigning dynamic variables

ken4ward
I have a sample project I am working on, it is to dynamically get inputs from an XML file, when I did the normal assignment static it worked, an example: <#assign x = 0> but when i try assigning dynamically, as this: <#assign ${x} = ${doc.db.persons.personname[0]}> neither did this work this way: <#assign x = ${doc.db.persons.personname[0]}> it throws this error: Encountered "{" at line 8, column 11 in src/transaction.ftl. Was expecting one of: "=" ... "in" ... ">" ... What am I doing wrong?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Assigning dynamic variables

Wong, Christopher

Just do it without the ${} stuff:

 

<#assign x = doc.db.persons.personname[0]>

 

From: ken4ward [mailto:[hidden email]]
Sent: Tuesday, July 15, 2014 7:59 AM
To: [hidden email]
Subject: [FreeMarker-user] Assigning dynamic variables

 

I have a sample project I am working on, it is to dynamically get inputs from an XML file, when I did the normal assignment static it worked, an example: <#assign x = 0> but when i try assigning dynamically, as this: <#assign ${x} = ${doc.db.persons.personname[0]}> neither did this work this way: <#assign x = ${doc.db.persons.personname[0]}> it throws this error: Encountered "{" at line 8, column 11 in src/transaction.ftl. Was expecting one of: "=" ... "in" ... ">" ... What am I doing wrong?


View this message in context: Assigning dynamic variables
Sent from the freemarker-user mailing list archive at Nabble.com.



This e-mail and files transmitted with it are confidential, and are intended solely for the use of the individual or entity to whom this e-mail is addressed. If you are not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you are not one of the named recipient(s) or otherwise have reason to believe that you received this message in error, please immediately notify sender by e-mail, and destroy the original message. Thank You.

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Assigning dynamic variables

Daniel Dekany
And also, update FreeMarker... AFAIR 2.3.20 (from one year ago)
already advices users not to use ${} like that.

--
Thanks,
 Daniel Dekany


Tuesday, July 15, 2014, 10:00:08 PM, Wong, Christopher wrote:

> Just do it without the ${} stuff:
>  
> <#assign x = doc.db.persons.personname[0]>
>  
> From: ken4ward [mailto:[hidden email]]
> Sent: Tuesday, July 15, 2014 7:59 AM
> To: [hidden email]
> Subject: [FreeMarker-user] Assigning dynamic variables
>  
> I have a sample project I am working on, it is to dynamically get
> inputs from an XML file, when I did the normal assignment static it
> worked, an example: <#assign x = 0> but when i try assigning
> dynamically, as this: <#assign ${x} =
> ${doc.db.persons.personname[0]}> neither did this work this way:
> <#assign x = ${doc.db.persons.personname[0]}> it throws this error:
> Encountered "{" at line 8, column 11 in src/transaction.ftl. Was
> expecting one of: "=" ... "in" ... ">" ... What am I doing wrong?
> View this message in context: Assigning dynamic variables
> Sent from the freemarker-user mailing list archive at Nabble.com.
>
> This e-mail and files transmitted with it are confidential, and are
> intended solely for the use of the individual or entity to whom this
> e-mail is addressed. If you are not the intended recipient, or the
> employee or agent responsible to deliver it to the intended
> recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly
> prohibited. If you are not one of the named recipient(s) or
> otherwise have reason to believe that you received this message in
> error, please immediately notify sender by e-mail, and destroy the original message. Thank You.


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Assigning dynamic variables

ken4ward
Thanks, Daniel, highly appreciate your warm response, though I got it resolved earlier.
Loading...