The Artima Developer Community
Sponsored Link

Weblogs Forum
Which Part of "No XML" Don't You Understand?

59 replies on 4 pages. Most recent reply: Mar 7, 2006 9:39 PM by Robin Parmar

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 59 replies on 4 pages [ « | 1 2 3 4 | » ]
Anthony Tarlano

Posts: 9
Nickname: tarlano
Registered: Jun, 2003

Re: Which Part of "No XML" Don't You Understand? Posted: Jan 31, 2006 3:02 PM
Reply to this message Reply
Advertisement
Guido,

Sorry I forgot to tell you the *reason* why you should use qpy.

Since it only is a template package it allows you to use any other engine component of your choice (Paste, cherrypy, etc) just like you wrote about in your previous post.

It's what you want it's just another package!!

Anthony

Vineet Jain

Posts: 1
Nickname: vinjvinj
Registered: Jan, 2006

Re: Which Part of "No XML" Don't You Understand? Posted: Jan 31, 2006 3:06 PM
Reply to this message Reply
Have you looked at preppy from Reportlab. You only have to download one file and it's simple and fast. You might not like the fact that it compiles the template to a python class file. (this can be done explicity, the way I do it, or done without any user interaction)

download: http://www.reportlab.org/downloads.html
docs: http://www.reportlab.com/docs/preppyspec.pdf

To access a variable (some_variable) in a dictionary:
<title>{{some_variable}}</title>

To do a for loop:
{{for row in dbResultSet}}
<tr><td>{[row.firstname}}</td><td>{{row.l astName}}</td>
{{endfor}}

To embed python in your template
{{script}}
man lines
indented properly
{{endscript}}

I use it to generate html, emails, and some python source.

Joe Goldthwaite

Posts: 6
Nickname: jgold
Registered: Jan, 2006

Re: Which Part of "No XML" Don't You Understand? Posted: Jan 31, 2006 3:48 PM
Reply to this message Reply
I also liked preppy. I'm not a python expert but I have created a project based on Zope. I tried Zope's templating language but found them confusing. Preppy on the other hand was simple and fast. Maybe it's just because it works the way I think a templating language should but I really like it. I'd be interested to hear what you think if you ever get a chance to give it a look.

Logan Hanks

Posts: 4
Nickname: loganhanks
Registered: Mar, 2005

Re: Which Part of "No XML" Don't You Understand? Posted: Jan 31, 2006 4:12 PM
Reply to this message Reply
I'm a Nevow supporter, and I'd like to point out that I've never used its XML template support. Have you seen Nevow's "stan" and its awesomeness?

Cliff Wells

Posts: 3
Nickname: cwells
Registered: Jan, 2006

Re: Which Part of "No XML" Don't You Understand? Posted: Jan 31, 2006 5:10 PM
Reply to this message Reply
from nevow import tags as T

T.html [
T.head [ T.title [ 'not xml' ] ],

T.body [
T.ul (render = render.sequence, data = range(10)) [
li (pattern = 'item') [
'''
which part of "no xml" don't you
understand?
'''
]
]
]
]


While Nevow *can* use XML templates, it certainly isn't required nor even recommended.

My personal feeling is that if I see "<tag>" in a template then it's an XML-based template, validation be damned. That includes Django, Cheetah, Kid, et al. The fact that there happens to be some code mashed into the XML in the ugliest possible way doesn't improve the situation.

If that style appeals to you, perhaps you should try PHP for a year and see if you don't come around.

John M Camara

Posts: 15
Nickname: camara
Registered: Dec, 2004

Re: Which Part of "No XML" Don't You Understand? Posted: Jan 31, 2006 5:55 PM
Reply to this message Reply
DOM vs Non-DOM templates

kinda of reminds me of

Relational vs Object Oriented Databases

Less than 5% of developers actually understand why the two approaches are import and can select the proper tool for the job. The other 95+% select one approach or the other and just can't see why the other approach is useful. Tunnel vision and one track minds. You gotta love it.

It's a good thing that most people only work on problems that are best solved with one of the choices and more often than not are selecting the right tool for the job. But you have to feel bad those poor suckers who choose the wrong tool because they happen to listen to the views of a one track minded people who are so adamant that their approach is the only true approach.

If you only believe in one of these approaches (templates or databases) as being right I have a question for you to think about. Do you really believe that people are so dumb that they would develop 2 approaches/styles to solve a problem if only one approach was superior?

Why are there so many types of hammers that are manufactured? You have common, framing, dead blow, finishing, etc (see http://www.hammernet.com/select.htm). They all have their use and selecting the right one for the job makes the job easier.

Now if we all knew how to select the right tools for the job.

John

Fredrik Lundh

Posts: 16
Nickname: effbot
Registered: Mar, 2005

Re: Which Part of "No XML" Don't You Understand? Posted: Jan 31, 2006 5:57 PM
Reply to this message Reply
What XML crowd? What did I miss? ;-)

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Which Part of "No XML" Don't You Understand? Posted: Jan 31, 2006 6:08 PM
Reply to this message Reply
Rigid structures, worse even, hierarchical rigid structures, will always be harder in some ways than the flatter and softer structures. For instance, when some folks are good at html and javascript they probably couldn't care a lot about how the database is handled, hence the popularity of MySQL since its beginning.

Nicola Larosa

Posts: 9
Nickname: teknico
Registered: Jan, 2006

Re: Which Part of "No XML" Don't You Understand? Posted: Jan 31, 2006 6:21 PM
Reply to this message Reply
Maybe you could be more specific?

> I don't want to use XML in my templates.

Maybe you mean you don't want validating XML?

> I don't want to generate XML

What do you want to generate? XHTML is XML, and HTML is very similar. Do you want to generate other kinds of text, in addition to HTML? I reckon you can't have the Web without (X)HTML, at least yet. ;-)

> and I don't want to have to type XML to tell the template
> engine what to do.

So you don't want to hook up code in XML attributes and the like. Fine.

There's something else I don't get.

Thanks to you (and many others), we have Python. Why don't we use it here too? Why tamper with awful minilanguages, when we have Python?

Let me concur with Mr.Tarlano: use Quixote's PTLs, or their more modern reimplementation, Qpy. Use standard Python syntax, throw strings around, and they'll go in the output.

There's no way around it: either you keep logic out of templates, or you mix it in. The only useful way to separate the two is via XML templates. Since you don't want them, you just decided to mix logic and templates, so do it the best way, for Python's sake! :-)

(BTW, there are two easy criteria for choosing web libraries and frameworks: discard anything that uses threads, or templating minilanguages. There, I said it.)

Tim Parkin

Posts: 3
Nickname: timparkin
Registered: Jan, 2006

Re: Which Part of "No XML" Don't You Understand? Posted: Jan 31, 2006 6:37 PM
Reply to this message Reply
"I don't want to use XML in my templates. I don't want to generate XML"

Having worked in web development for over ten years I have to completely agree with you :-)

Seriously though the point I was making is that if you're building pages in xml anyway - where what you are doing is configuring content in xml - it is only a small step to adding some extra directives to mark positions and spans where you want to apply changes and extract or insert content. It won't work for some people but for most html developers it will be fairly natural.

I'm not trying to convert you to xml configuration languages, my original question was to ask you what your initial requirements and desire were for a templating language.

Instead of trying to convince you which templating language you should be using, how about stating what your 'desires' and 'requirements' are?

Kevin Marks

Posts: 6
Nickname: kevinmarks
Registered: Jan, 2006

Re: Which Part of "No XML" Don't You Understand? Posted: Jan 31, 2006 7:51 PM
Reply to this message Reply
Writing logic in XSLT makes writing regexes look fun. Why would we give up a language with syntax that makes us productive for this?

Mike Sorich

Posts: 1
Nickname: sozza
Registered: Jan, 2006

Re: Which Part of "No XML" Don't You Understand? Posted: Jan 31, 2006 8:16 PM
Reply to this message Reply
I don't have problem with you not liking XML-based templating engines for web based programming. However, I would like to understand the reasons for this. I apologise if the reasons are obvious to others - I am a newbie in web based programming and really only vaguely familiar with one XML templating method (Kid).

Is it something to do with aesthetics, or is it more of practical/functional issue?

I presume that while the majority of your templates for web programming will be used to generate HTML, there is also the need to produce other types of output. You mentioned in a previous blog “they [turbogears] use [XML based] templates to generate non-HTML text files as well. And even if they could be used for this, the verbosity of the XML syntax and the inability to do a proper if-then-else in XML make template writing using XML a non-starter”. XML-based templating engines are likely to be suboptimal for more generic templating. Are you suggesting that because XML-based templating is not so good for non-HTML text that they are not worth considering (ie one templating method should be used for all outputs)? Or is it that XML-based templating is suboptimal even if used solely for HTML/XML generation in web applications?

You mention “I don't want to use XML in my templates”. When generating HTML in django or cheetah templating you still need to include HTML tags in the template. Is the problem that the templates use XHTML instead of HTML? Is it that much more difficult/ugly/verbose to use XHTML instead?

You mention “I don't want to generate XML”. I was under the impression that HTML was generally produced from the XML-based templating engines in the context of web based programming. I don’t really understand this point.

You have also mentioned that “I don't want to have to type XML to tell the template engine what to do”. Is the problem that the control code is placed in an attribute of the tag (at least this is where it is in Kid)? Is this less aesthetically pleasing and/or less functional?

These are not rhetorical questions - I would really like to understand the issues here.

Guido van van Rossum

Posts: 359
Nickname: guido
Registered: Apr, 2003

Re: Which Part of "No XML" Don't You Understand? Posted: Jan 31, 2006 9:47 PM
Reply to this message Reply
> Is it something to do with aesthetics, or is it more of
> practical/functional issue?

To me these are hard to separate. When using XML as the templating language to generate XHTML, the problem is that the templating elements or attributes look too similar to the output elements/attributes, because they're all XML. It's the same as when you're generating Python code from Python -- the Python code doing the generating and the string literals representing the bits of Python code being generated all jumble together to the average reader.

> I presume that while the majority of your templates for
> web programming will be used to generate HTML, there is
> also the need to produce other types of output. You
> mentioned in a previous blog “they [turbogears] use [XML
> based] templates to generate non-HTML text files as well.
> And even if they could be used for this, the verbosity of
> the XML syntax and the inability to do a proper
> if-then-else in XML make template writing using XML a
> non-starter”. XML-based templating engines are likely to
> be suboptimal for more generic templating. Are you
> suggesting that because XML-based templating is not so
> good for non-HTML text that they are not worth considering
> (ie one templating method should be used for all outputs)?
> Or is it that XML-based templating is suboptimal even if
> used solely for HTML/XML generation in web applications?

I think I have answered that above. It is also the general problem that XML is just extremely user-unfriendly -- much more so than HTML (which has a lot of latitude).

> You mention “I don't want to use XML in my templates”.
> When generating HTML in django or cheetah templating you
> still need to include HTML tags in the template. Is the
> problem that the templates use XHTML instead of HTML? Is
> it that much more difficult/ugly/verbose to use XHTML
> instead?

Yes.

> You mention “I don't want to generate XML”. I was under
> the impression that HTML was generally produced from the
> XML-based templating engines in the context of web based
> programming. I don’t really understand this point.

HTLM is much more forgiving than XML. Do you ever type </p>? Or <br/> or <hr/>? Do you always add quotes around argument values? Etc.

> You have also mentioned that “I don't want to have to type
> XML to tell the template engine what to do”. Is the
> problem that the control code is placed in an attribute of
> the tag (at least this is where it is in Kid)? Is this
> less aesthetically pleasing and/or less functional?

Confusing, as I explained above.

> These are not rhetorical questions - I would really like
> to understand the issues here.

Thanks for asking.

BTW, I'm going on a brief trip without web access soon. See you all on Friday, and don't kill each other! :-)

Jayson Vantuyl

Posts: 7
Nickname: kagato
Registered: Jan, 2005

Re: Which Part of "No XML" Don't You Understand? Posted: Feb 1, 2006 2:48 AM
Reply to this message Reply
I hate to be the lone dissenter here, but I kind of agree with the use of XML for web templating. I don't think that, using XML to generate XML is in anyway seeing XML a solution to an unrelated problem. It's seeing XML as a solution to a very related problem.

If I'm generating XHTML (which everyone should eventually be doing) it is XML. It makes sense to me that it is a better match to generate it from other XML. Especially due to the fact that XML is MADE to be transformed and proper namespacing completely separates the templating language elements/attributes from the content.

Note that it also has a few things intrinsicly solved. It's easy to move the template from program to program. It's in Unicode so it is by nature easily internationalizable (IMHO, this is the most overlooked value of proper XML handling).

As for being "confusing" when the templating instructions and template are being mixed (both in XML), that's what namespaces are for. Not that Zope Page Templates are my favorite thing, but it's obvious that everything that either has a tal: or metal: in front of it is templating.

Now, I think that most of the XML stuff that gets into processing directives, odd entities, and other stuff is a waste of time. I think XPATH goes a bit overboard with its more involved syntax. I think that XPointer should be simpler. I think XSLT is completely unusable for templating (although it's made for transforming, which isn't the same thing). I think no one has properly handled schemas and DTDs in a way that I can stomach.

However, XML for generating XHTML is simply a good match for 95% of templating. Bottom line, to know enough to properly generate XHTML, I can properly generate namespaced-templated XML. I certainly am not a fan anything like Nevow's Stan. I like Twisted a bunch. I've used it for unspeakably cool and horrible things. However, the abuse of syntax in Stan makes me angry deep inside.

I do not dispute that editing XML by hand slows down programmers that really have better things to do. However, I don't believe that programmers should be writing the XML directly anyways.

This is my issue with Stan--it is programmer shorthand for XHTML. I prefer to hand generate the XML document and then transform it with clean Python code. I think that this has yet to have a good general-purpose implementation, but I firmly believe that generating the XML template entirely in code roots us in a world where you can't delegate content development because the template is tied to strongly to the code for people to specialize in the content (not in coding). Having other people generate and contribute to my sites saves me more time than abusing __getitem__ saves me keystrokes.

For the record, I'd go further to even suggesting that XML SHOULD be strongly considered for configuration files. This is not ideal right now, but it's simply a matter of having the right editing tools. Look at the configuration interfaces generated by Microsoft's Policy tools (or the older, better schema driven Novell NDS Administration tools). They're all generated from simple text files that could be easily expressed in XML. It could also be implemented on the console in a manner similar to Linux's "make config" and "make menuconfig". It's crying for an implementation, in fact, I'll go do that now...

My approach is that XML should be used for templating and configuration but that the programmer should not have to touch it directly either. It's not as easy, yet, but I don't think that anyone can deny that its not a acceptable to use, say, QT Designer as a tool to generate a GUI interface (or the base for an GUI interface). We simply need some standard languages with good tools to write them. XML fills this need as well as anything else right now.

Sridhar Ratna

Posts: 3
Nickname: srid
Registered: Jan, 2005

Re: Which Part of "No XML" Don't You Understand? Posted: Feb 1, 2006 3:28 AM
Reply to this message Reply
Guido, If you're looking for simple solution, I bet it won't be simple for your complex requirements. For example, simply try doing the use case of Nevow patterns[1] in Kid or Cheetah.

And, apart from XML based documents, do you think of any other formats that require a templating language other than Python's string substitution?

[1] Nevow patterns: http://divmod.org/users/exarkun/nevow-doc/nevow-xml-templates.html#nevow-pattern

Flat View: This topic has 59 replies on 4 pages [ « | 1  2  3  4 | » ]
Topic: Web Framework Redux Previous Topic   Next Topic Topic: Java Posse Interview part 2


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us