Re: [Zope] DTML reformulated as XML (was RE: [Zope] <% ... %> ?)
I do want to point one thing out, though: adding namespaces does break the DTD. Currently there is no way to validate a document that uses
Hmm, didn't realize that.
There's a big difference between validation (against a DTD) and well-formedness however. I suppose ideally you'll want validity, but for now (IMHO) stick with well-formedness (is that a word?).
Here's one thing in DTML that would be awfully obscure in XML:
<a href="<!--#var BASE1-->">
That is, putting a tag inside an attribute. Chris Petrilli and Jim talked about this today, perhaps as as entity references.
That'd be ok for the Zope variables that take no arguments (BASEn, URLn etc.) ie map BASE1 to &BASE1; but what about Zope variables that take attributes, eg ZopeTime fmt=whatever (for example, you'd use this awful construct to create a URL that had subparts such as /990612/) A very hairy problem.
At any rate, I'd love for someone in the Zope community to march off and take a look at this, then make a proposal for how things should be changed. As always, patches are accepted. :^)
I've been meaning to do something like this. I might just spend some time thinking about it this weekend. Any actual coding probably won't happen, though. :)
Understood. If you produced a clear definition of the goals, some samples for the syntax, and a list of things that are good and bad about it, then that would be a major win.
The simple stuff is easy:
<?xml version='1.0'?> <xdtml:xdtml xmlns:xdtml="http://www.zope.org/xdtml" xmlns="http://www.w3.org/TR/xhtml1">
<xdtml:var name='standard_html_header'/> <h1><xdtml:var name='title'/></h1> <p>This is a paragraph.</p>
<xdtml:if expr='age > 18'> <p>Text not everyone should read.</p> </xdtml:if>
<xdtml:var name='standard_html_footer'/>
</xtml:xdtml>
I'd love to do a straw vote from the "I hate SSI" crowd: is the above better?
No dis to Otto, but NIMHO. Too much typing. I'm from a PHP background where blocks of code exist in tandem with HTML. At first I had a real problem with DTML (still do, but that's another story :), but reading Paul and Chris' posts about separating code and data I realise that the DTML way is probably the best way to do it (as with so many other Zopey things). ps I don't hate SSI, and I don't have an alternative to the syntax Otto is describing - I should shut up now.
The if gets really strange when you start adding 'elif' and 'else' clauses. I'll have to think about that one.
The containing xdtml element is just there as a place to hang the namespace declarations off of. Also, it's there to make the DTML object a full-fledged self-contained XML document, needed to make any kind of editor useful.
Precisely. It comes from the namespace declaration at the top.
One more thing to muse over is whether other things from XML land should surface.
For instance, I've long wondered if the ubiquitous var tag should be broken apart. People ask: why can't you give me a list of the things that can go in the var tag? Why doesn't Zope check to see if my documents reference subdocuments that no longer exist? The answer of "it's too dynamic" feels like less than an answer.
Instead, we could begin granularizing the tags, perhaps into things that describe better where they came from.
For instance, instead of saying <!--#var standard_html_header-->, which means insert a subdocument, why not use the XLink syntax from XML?
Would that not imply Zope parsing all elements in a page/object looking for attributes called xml:link? Isn't this a largeish overhead? It could also mean people writing <a xml:link="simple" href="standard_html_header" show="embed"/> instead of the above. Of course, if you get XLink stuff working in Zope, then presumably you get other interesting possibilities out too. rambling-ly yours, tone.
Tony McDonald wrote:
Paul wrote: Here's one thing in DTML that would be awfully obscure in XML:
<a href="<!--#var BASE1-->">
That is, putting a tag inside an attribute. Chris Petrilli and Jim talked about this today, perhaps as as entity references.
That'd be ok for the Zope variables that take no arguments (BASEn, URLn etc.) ie map BASE1 to &BASE1; but what about Zope variables that take attributes, eg ZopeTime fmt=whatever (for example, you'd use this awful construct to create a URL that had subparts such as /990612/)
I think the option here is to allow "assignments" to entities earlier in the document. Or maybe not. Or maybe I'm in over my head -- at 5'4", that happens often. :^)
I'd love to do a straw vote from the "I hate SSI" crowd: is the above better?
No dis to Otto, but NIMHO. Too much typing. I'm from a PHP background where blocks of code exist in tandem with HTML. At first I had a real problem with DTML (still do, but that's another story :), but reading Paul and Chris' posts about separating code and data I realise that the DTML way is probably the best way to do it (as with so many other Zopey things). ps I don't hate SSI, and I don't have an alternative to the syntax Otto is describing - I should shut up now.
I wish everyone that gets turned off by DTML could be required to re-read this thread. It quickly becomes apparent that there are tough choices, and that if it was a simple change, we'd have done it. :^) At the end of the day, any change will have some drawbacks. Except for the one that Jim has already checked in: :^) http://www.zope.org/pipermail/zope-checkins/1999-June/000667.html
For instance, instead of saying <!--#var standard_html_header-->, which means insert a subdocument, why not use the XLink syntax from XML?
Would that not imply Zope parsing all elements in a page/object looking for attributes called xml:link? Isn't this a largeish overhead? It could also
Zope already does syntax parsing (i.e. compiling) when you add/edit a template (something the PHP folks are working on for PHP4). In this case, using a different tag than var means Zope could have a shot at helping you -- when you click Edit, it could tell you that standrd_html_header doesn't exist, and you could fix the typo.
mean people writing <a xml:link="simple" href="standard_html_header" show="embed"/> instead of the above. Of course, if you get XLink stuff working in Zope, then presumably you get other interesting possibilities out too.
Now that's a different can of worms :^) Mozilla has xlink working but only for references, not for embedding.
rambling-ly yours,
Yep, that's what the weekend is for! --Paul
Tony McDonald wrote:
(snip)
Here's one thing in DTML that would be awfully obscure in XML:
<a href="<!--#var BASE1-->">
That is, putting a tag inside an attribute. Chris Petrilli and Jim talked about this today, perhaps as as entity references.
That'd be ok for the Zope variables that take no arguments (BASEn, URLn etc.) ie map BASE1 to &BASE1; but what about Zope variables that take attributes, eg ZopeTime fmt=whatever (for example, you'd use this awful construct to create a URL that had subparts such as /990612/)
A very hairy problem.
Nah. <dtml-let yy="ZopeTime().yy()" mm="ZopeTime().mm()" dd="ZopeTime().dd()"> <a href="&dtml-URL1;/&dtml-yy;&dtml-mm;&dtml-dd;/">...</a> </dtml-let> (snip)
For instance, instead of saying <!--#var standard_html_header-->, which means insert a subdocument, why not use the XLink syntax from XML?
Would that not imply Zope parsing all elements in a page/object looking for attributes called xml:link?
Yes, but in an XML variant of Zope, this would merely involve walking an object tree.
Isn't this a largeish overhead?
Not really. Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
participants (3)
-
Jim Fulton -
Paul Everitt -
Tony McDonald