Bruce Perryman | 12 Jul 03:41 2006
Picon

Help Evaluating Nested Maps

OK,

I'm doing something wrong, again.

This is the structure of my maps:

ABC
  ||
  =>DEF
        ||
        =>GHI
              ||
              =>A1=a
              =>A2=b
              =>A3=c
        =>GHI2
              ||
              =>B1=d
              =>B2=e
              =>B3=f

Hopefully this description makes sense to you. ABC contains a map DEF and DEF contains a few maps, two of which are GHI, and GHI2.

I am trying to evaluate A1 at the GHI level. This I do as follows:

${ABC.DEF.GHI.A1}

This results in the error that A1 is undefined. If I evaluate ${ABC.DEF.GHI} the error is that a string, etc. is expected but the expression evaluates to a simple hash.

Can you please point me in the right direction? Ultimately, I want to be able to use a variable to represent the GHI level with something like:

${ABC.DEF[x].A1}

But I thought I'd work with the 'simple' case first.

Thanks in advance for your help.

Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
fmpp-open mailing list
fmpp-open <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fmpp-open
Daniel Dekany | 12 Jul 05:07 2006
Picon

Re: Help Evaluating Nested Maps

I doesn't see any problem with this... so it's probably that GHI really doesn't have an entry with "A1" key, or that "A1" is mapped to a Java null value (that way the value is missing despite that the key exists).


What do you see if you list the hash entries like:


<#list ABC.DEF.GHI?keys as k>

${k} => ${ABC.DEF.GHI[k]?default('Java null')}

</#list>


Wednesday, July 12, 2006, 3:41:22 AM, Bruce Perryman wrote:


>

OK,


I'm doing something wrong, again.


This is the structure of my maps:


ABC

  ||

  =>DEF

        ||

        =>GHI

              ||

              =>A1=a

              =>A2=b

              =>A3=c

        =>GHI2

              ||

              =>B1=d

              =>B2=e

              =>B3=f


Hopefully this description makes sense to you. ABC contains a map DEF and DEF contains a few maps, two of which are GHI, and GHI2.


I am trying to evaluate A1 at the GHI level. This I do as follows:


${ABC.DEF.GHI.A1}


This results in the error that A1 is undefined. If I evaluate ${ABC.DEF.GHI} the error is that a string, etc. is expected but the expression evaluates to a simple hash.


Can you please point me in the right direction? Ultimately, I want to be able to use a variable to represent the GHI level with something like:


${ABC.DEF[x].A1}


But I thought I'd work with the 'simple' case first.


Thanks in advance for your help.



-- 

Best regards,

 Daniel Dekany


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
fmpp-open mailing list
fmpp-open <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fmpp-open
Bruce Perryman | 12 Jul 17:30 2006
Picon

Re: Help Evaluating Nested Maps

Great suggestion!

Implementing your suggestion revealed trailing whitespace in the keys. Removing the whitespace solved the problem.

Thanks a lot for your help and your great insight!

Daniel Dekany <ddekany <at> freemail.hu> wrote:

<!-- body { margin: 5px 5px 5px 5px; background-color: #ffffff; } /* ========== Text Styles ========== */ hr { color: #000000} body, table /* Normal text */ { font-size: 9pt; font-family: 'Courier New'; font-style: normal; font-weight: normal; color: #000000; text-decoration: none; } span.rvts1 /* Heading */ { font-size: 10pt; font-family: 'Arial'; font-weight: bold; color: #0000ff; } span.rvts2 /* Subheading */ { font-size: 10pt; font-family: 'Arial'; font-weight: bold; color: #000080; } span.rvts3 /* Keywords */ { font-size: 10pt; font-family: 'Arial'; font-style: italic; color: #800000; } a.rvts4, span.rvts4 /* Jump 1 */ { font-size: 10pt; font-family: 'Arial'; color: #008000; text-decoration: underline; } a.rvts5, span.rvts5 /* Jump 2 */ { font-size: 10pt; font-family: 'Arial'; color: #008000; text-decoration: underline; } span.rvts6 { font-size: 11pt; font-family: 'tahoma'; font-weight: bold; color: #ffffff; } span.rvts7 { font-size: 11pt; font-family: 'tahoma'; } a.rvts8, span.rvts8 { font-size: 11pt; font-family: 'tahoma'; color: #0000ff; text-decoration: underline; } span.rvts9 { font-size: 8pt; font-family: 'arial'; font-style: italic; color: #c0c0c0; } /* ========== Para Styles ========== */ p,ul,ol /* Paragraph Style */ { text-align: left; text-indent: 0px; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px; } .rvps1 /* Centered */ { text-align: center; } -->
I doesn't see any problem with this... so it's probably that GHI really doesn't have an entry with "A1" key, or that "A1" is mapped to a Java null value (that way the value is missing despite that the key exists).

What do you see if you list the hash entries like:

<#list ABC.DEF.GHI?keys as k>
${k} => ${ABC.DEF.GHI[k]?default('Java null')}
</#list>

Wednesday, July 12, 2006, 3:41:22 AM, Bruce Perryman wrote:

>
OK,

I'm doing something wrong, again.

This is the structure of my maps:

ABC
  ||
  =>DEF
        ||
        =>GHI
              ||
              =>A1=a
              =>A2=b
              =>A3=c
        =>GHI2
              ||
              =>B1=d
              =>B2=e
              =>B3=f

Hopefully this description makes sense to you. ABC contains a map DEF and DEF contains a few maps, two of which are GHI, and GHI2.

I am trying to evaluate A1 at the GHI level. This I do as follows:

${ABC.DEF.GHI.A1}

This results in the error that A1 is undefined. If I evaluate ${ABC.DEF.GHI} the error is that a string, etc. is expected but the expression evaluates to a simple hash.

Can you please point me in the right direction? Ultimately, I want to be able to use a variable to represent the GHI level with something like:

${ABC.DEF[x].A1}

But I thought I'd work with the 'simple' case first.

Thanks in advance for your help.


-- 
Best regards,
 Daniel Dekany

Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail Beta.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
fmpp-open mailing list
fmpp-open <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fmpp-open
Colbert Philippe | 18 Jul 20:26 2006

SUGGESTION: Make a two-level TDD file structure

SUGGESTION: Make a two-level TDD file structure for more abstraction power.
 
The TDD feature is one of the most powerful features of FMPP.  TDD hierarchical structure lends itself to complex applications.  That's great!
 
However, I find myself wanting a little bit more.   I would like to see a two-level TDD file setup.  That is I want to see two (2) different TDD files.  The values of the first TDD file beeing used in the second TDD file (property interpolation) and the second TDD being the final TDD file to be used with FMPP.
 
This would greatly increase the power of FMPP.   It's a natural extensition.  For instance, my application simply create XML configuration files using FMPP.   I have wrapped each reusable XML section into an FMPP macro.  So values are replaced directly into the macro.   My TDD file separates parameters by macros.   I would need a second TDD file to have "application specific concept abstraction".   That is grouping values by application concepts.   This second two-level concept can be reused in any application and would make things easier and cleaner.
 
Let me go even one step further by generalizing this concept of levels of TDD file.   Let me suggests that FMPP supports any number of cascading TDD files.  Instead of limiting ourselves to two-leve, let's make it n-level TDD file cascading.
 
TDD file1 --> TDD file 2 --> ... TDD file N ---> Used by FMPP
 
The TDD file N is used by FMPP.   The other files are forgotten.   This would allow any number of levels of abstraction.
 
Colbert Philippe
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
fmpp-open mailing list
fmpp-open <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fmpp-open
Daniel Dekany | 18 Jul 22:30 2006
Picon

Re: SUGGESTION: Make a two-level TDD file structure

Tuesday, July 18, 2006, 8:26:36 PM, Colbert Philippe wrote:


>

SUGGESTION: Make a two-level TDD file structure for more abstraction power.

 

The TDD feature is one of the most powerful features of FMPP.  TDD hierarchical structure lends itself to complex applications.  That's great!

 

However, I find myself wanting a little bit more.   I would like to see a two-level TDD file setup.  That is I want to see two (2) different TDD files.  The values of the first TDD file beeing used in the second TDD file (property interpolation) and the second TDD being the final TDD file to be used with FMPP.

 

This would greatly increase the power of FMPP.   It's a natural extensition.  For instance, my application simply create XML configuration files using FMPP.   I have wrapped each reusable XML section into an FMPP macro.  So values are replaced directly into the macro.   My TDD file separates parameters by macros.   I would need a second TDD file to have "application specific concept abstraction".   That is grouping values by application concepts.   This second two-level concept can be reused in any application and would make things easier and cleaner.

 

Let me go even one step further by generalizing this concept of levels of TDD file.   Let me suggests that FMPP supports any number of cascading TDD files.  Instead of limiting ourselves to two-leve, let's make it n-level TDD file cascading.

 

TDD file1 --> TDD file 2 --> ... TDD file N ---> Used by FMPP

 

The TDD file N is used by FMPP.   The other files are forgotten.   This would allow any number of levels of abstraction.

 

Colbert Philippe


Good-old TDD bleeds from hundreds of wounds, huh? For example, what you say, if I understand your suggestion well at least, is a "deficiency" that is known for me. It should be solved purely on the TDD level. The TDD should have a line like:


    %substitutions: {tdd(data/whatever.tdd)}

    # Note that of course you could use cvs(...) and whatnot.


and then the TDD language should allow referring to these variables somehow... don't know, for example with a sub(name) function. (Similarly, the inheritance that TDD config files can do, should be a TDD feature, not an FMPP config. loader feature.) Or you even wanted macro calls in the TDD file? This is how a simple config. file format could gradually become a 2nd programming language... :)


Now, I don't develop FMPP actively for while, as it is clearly stated on the index page as well. So, if you (or anybody) needs new features (as opposed to bugfixes, that I still do), I'm open to discuss proposals that then can be followed with proper quality patches. Or even giving admin rights to the project, if I find the person reliable and talented. Otherwise all I can say, that if I will ever write a next generation preprocessor tool (Is there a real demand for a such tool? I'm not sure...), I won't forget about these things.


-- 

Best regards,

 Daniel Dekany

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
fmpp-open mailing list
fmpp-open <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fmpp-open
Colbert Philippe | 19 Jul 08:10 2006

Can we loop on an Map in the TDD?

We know that we can loop on List in the TDD file (i..e someList : [ ...items...]) using the <#list ....> command. 
 
Can we loop on Map in the TDD file in the order it appears in the TDD file?   There is a strong need for this.   Looping through entries of a map, we could get access to the key and value of each entry (i.e. entry.key and entry.value)?
 
Java allows for looping through Map but the order is not respected.   I don't know if such Map exists.  The programmer might have to code a Map as a List<Entry> in order to achieve this.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
fmpp-open mailing list
fmpp-open <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fmpp-open
Daniel Dekany | 19 Jul 10:56 2006
Picon

Re: Can we loop on an Map in the TDD?

Wednesday, July 19, 2006, 8:10:41 AM, Colbert Philippe wrote:


>

We know that we can loop on List in the TDD file (i..e someList : [ ...items...]) using the <#list ....> command.  

 

Can we loop on Map in the TDD file in the order it appears in the TDD file?   There is a strong need for this.   Looping through entries of a map, we could get access to the key and value of each entry (i.e. entry.key and entry.value)?

 

Java allows for looping through Map but the order is not respected.   I don't know if such Map exists.  The programmer might have to code a Map as a List<Entry> in order to achieve this.


Listing maps is possible using the myMap?keys or myMap?values in FreeMarker, however, as you said, it doesn't keep the order as the entires were added. It could be fixed by replacing HashMap with LinkedHashMap in the TDD implementation. The problem is that LinkedHashMap was added in J2SE 1.4 only (incredible, isn't it?)... So if I use that, maps will not be ordered if you use J2SE 1.3 or 1.2, and that's confusing. Or FMPP has to require at least J2SE 1.4. Or do somebody know about a J2SE 1.2 compatible free LinkedHashMap implementation that extends HashMap? I haven't found any...


-- 

Best regards,

 Daniel Dekany

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
fmpp-open mailing list
fmpp-open <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fmpp-open

Gmane