From: Gabe Wachob <gwachob@findlaw.com> <zope:if condition="total_votes"> <p> <zope:in var="choices"> <zope:var expr="percent_for(_['sequence-index'])" fmt="%2d"/> </zope:in> <br/> </p> <zope:else> <em>No votes have been cast yet</em> </zope:if>
That's XML which represents HTML (a la XSL-- note the <br/> -- XML doesn't have unclosed tags). The only thing that might not work above is inserting & or < , etc. in certain places (they would normally have to be & or <)
Ahhh, but you have the floating (unclosed) <zope:else> tag. :P I was actually working on a similar spec many months ago here at DC. The truest XML-ish way we can think of (well, not true-est, but pretty truthful at least) is <zope:if condition="total_votes"> <zope:ifTrue>...</zope:ifTrue> <zope:ifFalse>...</zope:ifFalse> </zope:if> The else clause is its own block within the if and should be properly enclosed. It's tempting to be more pythonic and do if..else..end and have a floating <zope:else/> tag, but it kindof defeats the hierachical structure of XML. Or actually (as Jim Fulton just pointed out to me), something like a SWITCH or CASE structure is needed: <zope:switch> <zope:if condition="cond1">....</zope:if> <zope:elif condition="cond2">....</zope:elif> <zope:elif condition="cond3">....</zope:elif> <zope:else>....</zope:else> </zope:switch> This is why a pure XML variant of DTML like the above would most likely require a different engine than current DTML. I think this is better (and more powerful) in the long run than the <? ?> syntax which still feels hacky and would probably get limited support from editors as it is. A benefit of a pure XML variant of DTML would be that an accompanying DTD could be fed to an editor and then give all the tags to the writer. Full XSL support could be even better (especially with potential XQL support in Zope). (I initially fought XSL in Zope, but recent readings of much newer drafts of the XSL spec have lightened me :). --jPS - - - / jeff@digicool.com - http://www.digicool.com/