[stringtemplate-interest] Problem with C# dictionaries
Varghese
vcottagiri at zafinlabs.com
Mon Oct 30 00:26:27 PST 2006
Hi,
I tried your example out in java. Got the following errors.
Class java.lang.String has no such attribute: one in template context
[anonymous anonymous]
java.lang.NoSuchFieldException: one
at java.lang.Class.getField(Class.java:1507)
at
org.antlr.stringtemplate.language.ASTExpr.rawGetObjectProperty(ASTExpr.java:489)
at
org.antlr.stringtemplate.language.ASTExpr.getObjectProperty(ASTExpr.java:385)
at
org.antlr.stringtemplate.language.ActionEvaluator.attribute(ActionEvaluator.java:351)
......
Class java.lang.String has no such attribute: two in template context
[anonymous anonymous]
java.lang.NoSuchFieldException: two
at java.lang.Class.getField(Class.java:1507)
at
org.antlr.stringtemplate.language.ASTExpr.rawGetObjectProperty(ASTExpr.java:489)
at
org.antlr.stringtemplate.language.ASTExpr.getObjectProperty(ASTExpr.java:385)
at
org.antlr.stringtemplate.language.ActionEvaluator.attribute(ActionEvaluator.java:351)
.......
Try '$value:{$i$: $it$};separator="\n"$' instead of
'$value:{One: $it.one$ Two: $it.two$};separator="\n"$'
I am not sure how to can access key iterator for a map data structure.
The $it$ for a map is its values iterator.
regards
vergis
brian.kejser at protexis.com wrote:
> Hi
>
> Here's the C# code:
>
> Dictionary<string, string> dictionary = new Dictionary<string, string>();
>
> dictionary.Add("one", "testing");
> dictionary.Add("two", "more testing");
>
> stringTemplate.SetAttribute("value", dictionary);
>
> Here's the first string template:
>
> Start
> One: $value.one$
> Two: $value.two$
> End
>
> Here's its output:
>
> Start
> One: testing
> Two: more testing
> End
>
> Here's the second string template:
>
> Start
> $value:{One: $it.one$
> Two: $it.two$};separator="\r\n"$
> End
>
> Here's its output:
>
> Start
> One:
> Two:
> One:
> Two:
> End
>
> Shouldn't the outputs be the same? Am I doing something wrong or is this a
> bug?
>
> Thanks
>
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>
>
>
>
More information about the stringtemplate-interest
mailing list