S
Stefan Behnel
Hi!
I need to generate source code (mainly Java) from a domain specific XML
language, preferably from within a Python environment (since that's where the
XML is generated).
I tried using XSLT, but I found that I need a template system that supports
Python interaction. I know, lxml's XSLT support is /somewhat/ getting there,
but even with that, XSLT is so clumsy when it comes to code generation
(looping constructs and if/else above all), that it would take me tons of XSLT
code to write what I want.
I've been looking through Python templating systems all over the place, but I
just can't find one that supports XPath - which is by far the best thing to
have when you generate stuff from XML. TAL might be able to get me part of the
way (at least, it supports some kind of Path expressions, though only for
object access), but the only available implementation is part of Zope and I
can't make my code depend on Zope only for a template system.
My problem is that I want to write as little Python code as possible to make
the templates (almost) stand alone and thus readable without the backend code.
I can transform the XML language to a more usable XML format beforehand, no
problem, but I then need to access the result from the template - and that's
almost impossible without XPath.
Does anyone have an idea what I could use? Any hints are helpful.
Thanks,
Stefan
I need to generate source code (mainly Java) from a domain specific XML
language, preferably from within a Python environment (since that's where the
XML is generated).
I tried using XSLT, but I found that I need a template system that supports
Python interaction. I know, lxml's XSLT support is /somewhat/ getting there,
but even with that, XSLT is so clumsy when it comes to code generation
(looping constructs and if/else above all), that it would take me tons of XSLT
code to write what I want.
I've been looking through Python templating systems all over the place, but I
just can't find one that supports XPath - which is by far the best thing to
have when you generate stuff from XML. TAL might be able to get me part of the
way (at least, it supports some kind of Path expressions, though only for
object access), but the only available implementation is part of Zope and I
can't make my code depend on Zope only for a template system.
My problem is that I want to write as little Python code as possible to make
the templates (almost) stand alone and thus readable without the backend code.
I can transform the XML language to a more usable XML format beforehand, no
problem, but I then need to access the result from the template - and that's
almost impossible without XPath.
Does anyone have an idea what I could use? Any hints are helpful.
Thanks,
Stefan