Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Where's a DOM builder that uses the Builder Pattern to ... buildDOMs?

Reply
Thread Tools

Where's a DOM builder that uses the Builder Pattern to ... buildDOMs?

 
 
Phlip
Guest
Posts: n/a
 
      01-04-2010
Not Hyp:

I hope I'm wrong, but seems that DOMBuilder, found among the various
xml.dom packages, cannot build DOM like this:

var html = DomBuilder.apply();

var form = html.FORM(
html.DIV(
html.INPUT({type : 'text', name : 'email'}),
html.INPUT({type : 'text', name : 'password'}),
html.INPUT({type : 'submit'}),
)
);

Do anyone know any good DOM builder packages that do build DOM good
like a DOM builder should?

--
Phlip
http://zeekland.zeroplayer.com/Uncle_Wiggilys_Travels/1
 
Reply With Quote
 
 
 
 
Stefan Behnel
Guest
Posts: n/a
 
      01-05-2010
Phlip, 04.01.2010 21:01:
> Not Hyp:
>
> I hope I'm wrong, but seems that DOMBuilder, found among the various
> xml.dom packages, cannot build DOM like this:
>
> var html = DomBuilder.apply();
>
> var form = html.FORM(
> html.DIV(
> html.INPUT({type : 'text', name : 'email'}),
> html.INPUT({type : 'text', name : 'password'}),
> html.INPUT({type : 'submit'}),
> )
> );
>
> Do anyone know any good DOM builder packages that do build DOM good
> like a DOM builder should?


You might be looking for something like this:

http://codespeak.net/lxml/lxmlhtml.h...-the-e-factory

Note that there are tons of ways to generate HTML with Python. A quick web
search (or a quick read on PyPI or the Python Wiki) should get you started.

Stefan
 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      01-05-2010
On Jan 5, 12:16*am, Stefan Behnel <(E-Mail Removed)> wrote:

> Note that there are tons of ways to generate HTML with Python.


Forgot to note - I'm generating schematic XML, and I'm trying to find
a way better than the Django template I started with!
 
Reply With Quote
 
Stefan Behnel
Guest
Posts: n/a
 
      01-07-2010
Phlip, 05.01.2010 18:00:
> On Jan 5, 12:16 am, Stefan Behnel <(E-Mail Removed)> wrote:
>
>> Note that there are tons of ways to generate HTML with Python.

>
> Forgot to note - I'm generating schematic XML, and I'm trying to find
> a way better than the Django template I started with!


Well, then note that there are tons of ways to generate XML with Python,
including the one I pointed you to.

Stefan
 
Reply With Quote
 
Phlip
Guest
Posts: n/a
 
      01-07-2010
On Jan 7, 5:36*am, Stefan Behnel <(E-Mail Removed)> wrote:

> Well, then note that there are tons of ways to generate XML with Python,
> including the one I pointed you to.


from lxml.html import builder as E
xml = E.foo()

All I want is "<foo/>", but I get "AttributeError: 'module' object has
no attribute 'foo'".

A peek at dir(E) shows it only has HTML tags, all hard coded.

So how to get it to generate any random XML tag my clients think of?

I will write this myself with __getattr__ etc, if I can't find it,
because the permissive & expressive builder pattern I'm after would be
very ... permissive & expressive.

All I want is a library that reads my mind!!! Is that too much to
ask??? (Unless if the library insists on throwing a NullMind
exception, on principle...)

--
Phlip
http://twitter.com/Pen_Bird
 
Reply With Quote
 
Stefan Behnel
Guest
Posts: n/a
 
      01-13-2010
Phlip, 07.01.2010 17:44:
> On Jan 7, 5:36 am, Stefan Behnel <(E-Mail Removed)> wrote:
>
>> Well, then note that there are tons of ways to generate XML with Python,
>> including the one I pointed you to.

>
> from lxml.html import builder as E
> xml = E.foo()
>
> All I want is "<foo/>", but I get "AttributeError: 'module' object has
> no attribute 'foo'".
>
> A peek at dir(E) shows it only has HTML tags, all hard coded.


Note how you imported 'E' from a package called 'lxml.html'. The last part
of that package name gives a hint on what it specialises in.


> So how to get it to generate any random XML tag my clients think of?


Have you thought of taking a look at the tutorial?

http://codespeak.net/lxml/tutorial.html#the-e-factory

Stefan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Builder Pattern Jason Python 4 02-02-2006 12:50 PM
Learning Borland C++ Builder uses Verne C++ 6 11-08-2004 01:05 AM
Design problem while using Builder pattern qazmlp Java 2 01-31-2004 03:32 PM
Design problem while using Builder pattern qazmlp C++ 2 01-31-2004 03:32 PM



Advertisments