Re: dynamic reference
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Monday, May 18, 2009, 3:13:58 PM, a.reiter wrote:
> Hi Daniel,
>
> thanks a lot for the answer
>
> the thing is a bit mor complicated, i try to explain... :-)
>
> i have this xml structure
>
>
> <book title="Test" author="einstein" number="4711" />
>
>
>
> i need to access the attributes, the problem is, the attributes are
> very dynamic, so i don't know the names
> i cann access the title of the book by doing: ${book.@title}
>
> BUT the name of the attribute, here "title" is unknown
> what i have is a separate list, where the names of attributes are stored, called "attr"
>
> now i want to iterate over all velues of attributes defined in that list
> is that possible?
>
> should look like that, but this does not work
>
> <#list attr as a>
> ${book.@[a][0]!"undefined"}
> </#list>
>
> i hope, the question is clear
I guess... assuming you are using our XML-wrapper it should be:
<#list attr as a>
${book['@' + a][0]!"undefined"}
</#list>
Also note that the attributes can be listed as <#list book.@@ as a >.
> regards
> andre
>
>
>
> Daniel Dekany wrote:
>> Monday, May 18, 2009, 1:40:46 PM, a.reiter wrote:
>>
>>> Hello everybody
>>> I'm new to Freemarker, but already impressed of the features and performance
>>>
>>> now I have a simple question:
>>>
>>> in my model there two variables:
>>>
>>> foo="bar"
>>> bar="what ever"
>>>
>>> the problem is, that the model is dynamically, so my template does
>>> not know, that there is a variable "bar", only "foo" variable is well known.
>>>
>>> so how can i get the contant of the unknown "bar" variable? is it possibla at all?
>>
>> Do the foo variable hold the variable name of the unknown variable?
>> Then:
>>
>> .data_model[foo]
>>
>>> best regards
>>> andre
>>
>
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables
> unlimited royalty-free distribution of the report engine
> for externally facing server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>
--
Best regards,
Daniel Dekany
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects