Re: ANN: XML builder for Python

2008-07-03 Thread Jonas Galvez
Walter Dörwald wrote: > Of course the node constructor could append the > node to the currently active element. However there > might be cases where you want to do something else > with the newly created node, so always appending the > node is IMHO the wrong thing. Unless you're using it as a temp

Re: ANN: XML builder for Python

2008-07-03 Thread Walter Dörwald
Jonas Galvez wrote: Walter Dörwald wrote: XIST has been using with blocks since version 3.0. [...] with xsc.Frag() as node: +xml.XML() +html.DocTypeXHTML10transitional() with html.html(): [...] Sweet! I don't like having to use the unary operator tho, I wanted something as simple as poss

Re: ANN: XML builder for Python

2008-07-03 Thread Walter Dörwald
Stefan Behnel wrote: Hi, Walter Dörwald wrote: XIST has been using with blocks since version 3.0. Take a look at: http://www.livinglogic.de/Python/xist/Examples.html from __future__ import with_statement from ll.xist import xsc from ll.xist.ns import html, xml, meta with xsc.Frag() as node

Re: ANN: XML builder for Python

2008-07-03 Thread Jonas Galvez
Stefan Behnel wrote: > Interesting. Is the "+" actually required? Are there other operators > that make sense here? I do not see what "~" or "-" could mean. > Or is it just a technical constraint? > I'm asking because I consider adding such a syntax to lxml as > a separate module. And I'd prefer co

Re: ANN: XML builder for Python

2008-07-03 Thread Stefan Behnel
Hi, Walter Dörwald wrote: > XIST has been using with blocks since version 3.0. > > Take a look at: > http://www.livinglogic.de/Python/xist/Examples.html > > > from __future__ import with_statement > > from ll.xist import xsc > from ll.xist.ns import html, xml, meta > > with xsc.Frag() as node

Re: ANN: XML builder for Python

2008-07-03 Thread Stefan Behnel
Hi, two comments. Gerard flanagan gmail.com> writes: > Nice! Here's a version that uses elementtree: [...] > def __call__(self, value='', **kargs): > self.element.text = value This should spell def __call__(self, value=None, **kargs): > class builder(element): > def

Re: ANN: XML builder for Python

2008-07-03 Thread Jonas Galvez
Walter Dörwald wrote: > XIST has been using with blocks since version 3.0. > [...] > with xsc.Frag() as node: > +xml.XML() > +html.DocTypeXHTML10transitional() > with html.html(): > [...] Sweet! I don't like having to use the unary operator tho, I wanted something as simple as possible, so I

Re: ANN: XML builder for Python

2008-07-03 Thread Walter Dörwald
Stefan Behnel wrote: Stefan Behnel wrote: Jonas Galvez wrote: Not sure if it's been done before, but still... Obviously ;) http://codespeak.net/lxml/tutorial.html#the-e-factory ... and tons of other tools that generate XML, check PyPI. Although it might be the first time I see the with sta

Re: ANN: XML builder for Python

2008-07-03 Thread Gerard flanagan
Jonas Galvez wrote: Not sure if it's been done before, but still... from __future__ import with_statement from xmlbuilder import builder, element xml = builder(version="1.0", encoding="utf-8") with xml.feed(xmlns='http://www.w3.org/2005/Atom'): xml.title('Example Feed') xml.link

Re: ANN: XML builder for Python

2008-07-02 Thread Stefan Behnel
Stefan Behnel wrote: > Jonas Galvez wrote: >> Not sure if it's been done before, but still... > > Obviously ;) > > http://codespeak.net/lxml/tutorial.html#the-e-factory > > ... and tons of other tools that generate XML, check PyPI. Although it might be the first time I see the with statement "m

Re: ANN: XML builder for Python

2008-07-02 Thread Stefan Behnel
Jonas Galvez wrote: > Not sure if it's been done before, but still... Obviously ;) http://codespeak.net/lxml/tutorial.html#the-e-factory ... and tons of other tools that generate XML, check PyPI. Stefan -- http://mail.python.org/mailman/listinfo/python-list

ANN: XML builder for Python

2008-07-02 Thread Jonas Galvez
Not sure if it's been done before, but still... from __future__ import with_statement from xmlbuilder import builder, element xml = builder(version="1.0", encoding="utf-8") with xml.feed(xmlns='http://www.w3.org/2005/Atom'): xml.title('Example Feed') xml.link(None, href='http://ex