[stringtemplate-interest] Top-Down automatic attributeaggregation?
Kunle Odutola
Kunle_Odutola at hotmail.com
Wed May 24 17:12:09 PDT 2006
> Hi!
G'day Ulf,
> An Attribute can be:
> An ArrayList containing either more Hashtables(deeper nesting)
> or a single String
ST# treats attributes whose values are of types that implement IList
specially. They are considered to be multi-valued attributes.
> WHAT WORKS:
>
> Calling strictly hirarchical templates does work with this
> structure.
>
> With a datastructure of Foo.Bar
> .FooBar
>
> TemplateA(Foo) ::= << $Foo:TemplateB$ >>
> TemplateB() ::= << $it.Bar$ ; $it.FooBar$ >>
>
> evaluates correctly.
>
> PROBLEM:
>
> I now can NOT access the deeper nestings of the structure.
> With above structure the following access
>
> TemplateA(Foo) ::= << $Foo.FooBar$ >>
>
> gives me a
> "Class System.Collections.ArrayList has no such attribute:
> FooBar in template context [TemplateA]"
>
> When calling subtemplates with parameters ST seems to
> 'ignore' the additional ArrayList-layer (resolving it as expected)
> but when accessing Foo.FooBar the ArrayList gets in the way.
> A Call to Foo.attributeList.FooBar also fails
> attributeList is my (for testing public) member which holds
> the ArrayList. (it involves wrapping ArrayList and giving it
> an accessor which (called with the string that designates
> the AL in the parent Hashtable) returns a reference to
> itself (the AL).
I might be missing something here but, ArrayList instances don't have a
FooBar member.
> So I have to ask: Has anyone any experience with this
> problem? Or do you Terence or Kunle have an idea to how a
> suitable data structure has to look?
No specials requirements beyond keeping in mind that ILists (e.g. arrays,
arraylists etc) are treated specially. If you do use a list, remember that
you won't be able to access members by index. They are considered to be
multi-valued attributes and you can iterate over the contents as one would
expect.
> I don't have enough understanding of how ST gets its
> attributes from a given datastructure to figure out something better.
>
> I fear to ask how this would work out referencing PARENT
> attributes from sub-templates.
What are parent attributes?
Kunle
More information about the stringtemplate-interest
mailing list