[stringtemplate-interest] Top-Down automatic attribute aggregation?

Dreyer Ulf (CR/APA3) Ulf.Dreyer at de.bosch.com
Tue May 16 23:23:57 PDT 2006


Hello Terence,

thank you for the quick answer but I fear that
either I just don't get it or I didn't state my problem correctly
or it is just to early in the morning for functional programming. ;)

I'll try for a more precise problem description - if that still matches
what you had in mind then please elaborate on it because it's a case
of "I don't get it".

The data from the xml-file is non-uniform 
(meaning no single template can traverse the tree)
and the feed-mechanism should be independent from the templates.

sample data:

a
|
----b
|   - c
|   - d
|
|---b
|   - c
|   - d
|
|---x
    - y

whith template calls along the lines of

//in ATemplate :
$a.b:BTemplate()$
$XTemplate(a.x)$

//in BTemplate 
 someOutPutText using $it.c$ and calling $d:Dtemplate()$

The actual classes to hold the XML-data have
to be generic with some kind of getAttributeByName(String: aName);
- This is my first problem. I'm not sure how these "adaptor"-class 
should look for StringTemplate to handle it as
Key-value lookups are only supportet by maps. (By the way I am using
the C#-implementation of Stringtemplate and antrl)

I think the solution you gave does not exactly apply to this problem,
does it?
Some more Info:
I'd like to write a system which provides some data in the proposed
way and have different users write their own (different) templates 
using that data. (AND make that process as simple as possible - hence
the "automatism" for putting xml into the topmost template )

Looking forward to your advice,

Ulf

P.S.: Thank you for this gread piece of software and
      most of all for antlr (looking forward to 3.0)

[old solution:]
> Just pass the tree in and then walk.  From

> http://www.cs.usfca.edu/~parrt/papers/ST.pdf

> preorder(t) ::= "<t.text> <t.children:preorder()>"

> ain't that sweeet! :)
> > Is there some easy way to construct a full tree of data (which does

> > not resolve
> > to fixed classes with getAttribute methods) and feed it to the root

> > template?
> Sure.  as long as it has children or some other structure.
> Ter


More information about the stringtemplate-interest mailing list