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

Terence Parr parrt at cs.usfca.edu
Wed May 17 14:39:15 PDT 2006


>
> 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);

You should probably structure it so that the children are in a map.   
You can then say: $node.child$ to get the child subtree.

> - 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)

Yeah, i'd go with the map.  Might have to wrap those objects if you  
have no control over them to change their implementation.

> I think the solution you gave does not exactly apply to this problem,
> does it?

Yes, but my trees just have lists of children...i don't care about  
the XML schema in my case.  For you, you can make a template  
hierarchy that is equiv to an XML DTD no problem, but if that schema  
is diff each time, you'll need a new ST group for each possible tree  
structure.

> 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 )

This should work great with ST. :)

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

You are very welcome :)

Ter



More information about the stringtemplate-interest mailing list