[XML-SIG] Python / XML / XSLT vs. Cocoon for website server side

Richard Johannesson rtjohan at syspres.com
Thu Aug 14 17:04:59 EDT 2003


Dave - thanks for the feedback.

As you can tell, my understanding of XML/XSLT/Python is limited. I've done
simple Python stuff before, but never done any CGI/HTML with Python. Most
web work done in ASP for small internal corporate apps. ASP works for small
applications, but I'm betting that XML/Python scales better for large
systems. Concerned with how to scale website when content and presentation
layer are mixed. I'm primarily trying to decide the architecture of site and
which technology to use. Will outsource much of the work. So, the primary
concern is "can it scale". Can I outsource pieces and reuse as much of the
resulting work as possible. Although some of the Python templating solutions
probably could handle the presentation layer, using something that's not a
standard makes me nervous. Hence the focus on XSLT. If I would have to move
to something other than Python, then the XSLT can be reused.

>> I am laying out a new medium size website that I was hoping I could use
>> Python / XML on the server side. This is a brand new site, no e-commerce
at
>> first, but will add later. Site will need the blog, wiki, group calendar,
>> and other basic features. The size of site will initially about 50 pages,
>> but should grow quickly to few thousand pages. Much of the content will
be
>> produced by users. So, main concern is being able to apply stylesheets to
>> content to keep a consistent look.
>>
>> Key decisions:
>>  - All HTML generation done via XSLT
>
>You may also want to consider straight Python.  You could use
>Python code that works from the XML DOM (e.g. minidom).  There are
>also several solutions that will turn an XML document into a
>specialized DOM where the classes (and the instances that form the
>DOM tree) reflect the elements and tags in the XML source document.

This might be a good alternative. After dismissing the Java/Cocoon route,
I'm looking at the different html/XML libraries available in Python. Trying
to decide which ones should be used.

>>  - Have logic done in XSLT where possible
>Ha. Ha. Ha.  Only a sick pervert would make a joke like that.
>
>Can someone who has tried doing logic in XSLT stylesheets give a
>bit of insight on how to do logic in XSLT?  My understanding is
>that XSLT is good for recursive pattern matching and generation of
>content from patterns/templates, but not good once you go beyond
>that.  Can someone confirm that or show how complex logic is done
>in XSLT stylesheets?  Would that logic be readable and
>maintainable?

I've just read that this is possible. Not looked into how its done yet. Only
done some simple XSLT transformation so far - creating html doc from a few
xml docs using XSLT. Thanks for the warning. Theoretically, if the logic can
be stored in a language independent format - this sounds ideal. But, most
ideal things don't work in reality. Still worth looking into.

>>  - Use Python for glue
>Good idea.  Python *is* glue.  See "Glue It All Together With
>Python":
>
>    http://www.python.org/doc/essays/omg-darpa-mcc-position.html

Yup. Looks like the ultimate glue.

>>  - Use Postgresql for RDBMS
>Good idea.  There are several implementations of the Python DB API
>for PostgreSQL.  I'm using pyPgSQL myself.  It makes database
>access via SQL pretty easy.

How do you handle XML data storage? Use XML DB or use RDBMS? I've seen some
article that discussed extending Postgresql with custom functions to handle
XML. Likely to be too much work.

Probably will be pushing for stored procedures PL/pgSQL. I believe there was
some development to get Python stored procedure support for PostgreSQL. Last
I looked this seemed to have been dropped. Ideally, would be nice to write
the stored procedures in Python. Anyone do that successfully?

>>  - Use FreeBSD for Servers
>>  - Strict separation of content / presentation / logic
>>  ? Need to figure out what XML (enabled) database can use from Python
>>
>> Here are the assumptions I'm making:
>>  - XML to HTML transformations via XSLT will provide good platform
>> independence. .Net, J2EE, Python all support XSLT. So, if required to
move
>> to different platform, this should be possible
>Not to try to talk you out of XSLT, but there are other ways to
>gain platform independence.  Python is one good way.

Just seems that XSLT will provide also language independence. Most major
languages support XSLT. Trying to decide if its worth the cost in terms of
development time. I was under the impression that developing huge sites is
faster when using XSLT. Building the pages in Python seems to have the same
scalbility problems that ASP/PHP have since can't enforce content /
persentation layer seperation. Is this incorrect? I don't want to force the
developers to use something that doesn't make the overall development effort
faster. So, if creating a huge site is more maintainable and faster to
develop without XSLT I'd drop it in a heart beat. Just what I've read so far
is that at this point in time it should be better to use XSLT. That's after
some growing pains in getting used to it.

Seems also easier to partition the work when using XSLT.

>>  - XSLT/XML can generate just about any html page a CSS/template engine
can
>If you are saying that XSLT is a suitable tool for generating *any*
>HTML from XML, I'd be skeptical.  My belief is that there are
>complex transformations for which XSLT would *not* be suitable.
>Again, is there an XSLT expert that can give an evaluation here?

Yeah, would be great to hear where XSLT would be unsuitable. I'm pretty much
so far relying on the O'Reilly XML books - got pretty much all of them. XML
Schema, XSLT Cookbook, XSLT, Xpath and Xpointer and Master XML by Sybex +
online articles. But the only way to know is to use this stuff for a few
years extensively. Would be nice to learn from the masters and avoid the
classic mistakes.

>>  - Adding new content using XML/XSLT is less work than using ASP/PHP/JSP
>>
>> Decided to stay away from J2EE / Jboss (overkill/long ramp-up time/slow
>> development).
>>
>> I've been wondering how much extra work I'll have to do in Python if I
don't
>> use something like Cocoon. I guess it's possible to use Cocoon with
Python.
>> Would anyone recommend using Cocoon or some alternative?
>>
>> Is there much consulting work for XML/Python? Current customers are
pretty
>> much exclusively ASP / ASP.net.
>>
>> Thanks in advance for any feedback on the assumptions I'm making above,
any
>> comments about Cocoon, or what XML database Python supports.
>>
>> Regards,
>> Richard
>>
>>
>
>Dave
>
>--
>Dave Kuhlman
>dkuhlman at rexx.com
>http://www.rexx.com/~dkuhlman

Would be nice if some best practices could be created on Python / XML. Maybe
if we get enough feedback, this might lead to something like that. Just too
much confusion out there. One major strength Python has is its
documentation. If it would go even further and start capturing best
practices - it would be in a league of its own. Make it easier for newcomers
to pick-up the language and start implementing things properly.

Thanks again,
Richard





More information about the XML-SIG mailing list