[stringtemplate-interest] Broken link: StringTemplate 3.0 Printable Documentation/Conditionally Included Subtemplates (IF statements)

Stefan Eder stefan.eder at ebuconnect.de
Thu Jan 17 01:20:32 PST 2008


Thanks Ter,

I am a beginner with ST and I believe strongly that you are right.
Logic should be in the model, not in the view.

My model is XML. I unmarshal it with JAXB-2 into Java Beans.
Principally a nice way to apply attribute trees, but the model is as it 
is not complete for use with ST. For instance I have minOccurs and 
maxOccurs attributes and in dependency of maxOccurs I want to decide if 
an instance variable of the child type or a list of those is generated...

The solution for me is now to design another XSD perfectly fitting my 
requirements with ST and use XSLT to transform my general purpose model 
in such an ST attributes model.
It easily solves my example problem by inserting another boolean 
attribute and has much more potential.

Another question:
Exists a list of reserved words which must not be used as attribute names?
I made the experience, that an attribute named length is not allowed in 
ST(G)s.
Such a list would be very helpful and could save me some time.

Stefan



Terence Parr schrieb:
>
> On Jan 16, 2008, at 7:25 AM, Stefan Eder wrote:
>
>> Hi,
>>
>> there is a broken link ("Conditionally Included Subtemplates (IF
>> statements)") within the "StringTemplate 3.0 Printable Documentation".
>> And within the online documentation I have not found the the answer on
>> my question:
>> Which expressions are supported in IF/ELIF statements?
>> Can I compare an attribute with a constant?
>
> Hi Stefan,
>
> ST does not allow expressions except references to attributes, 
> templates, or !attribute. No comparisons.
>
>> - If so, what kind of constants are supported (strings, integers, ...)?
>> -- If so, how to express them?
>> - If so, what kind of operators are supported (EQUAL, NOT_EQUAL,
>> LESSTHAN, ...)?
>
> none, that is perhaps you confusion.  I think you should read more 
> about the philosophy of ST where I discussed the separation of logic 
> from view.  All logic must be in the model not the view.
>
> Ter



More information about the stringtemplate-interest mailing list