|
From: <dg...@mo...> - 2004-09-14 14:38:10
|
Hello,
I like the itcl/tk- and Tdom-like calling conventions for tdom:
(tclkit) 82 % set doc [dom::DOMImplementation create]
::dom::tcl::document7::Document
(tclkit) 83 % set top [dom::document createElement $doc html]
::dom::tcl::document7::node2
(tclkit) 84 % set title [$doc createElement title]
::dom::tcl::document7::node6
(tclkit) 85 % $top appendChild $title
::dom::tcl::document7::node6
(tclkit) 86 % set body [$doc createElement body]
::dom::tcl::document7::node13
(tclkit) 87 % $top appendChild $body
::dom::tcl::document7::node13
(tclkit) 88 % $body setAttribute bgcolor black
unknown method "setAttribute"
This does not work, however this:
(tclkit) 90 % dom::element setAttribute $body bgcolor black
black
which is for me a little bit awkward, and I always forget to add the
nodename after the (get|set)Attribute-command. I am used to javascript
where we say something like:
var input = window.document.createElement("input");
input.setAttribute("name", "inputvalue");
(tclkit) 91 % ::dom::serialize $doc
<?xml version='1.0'?>
<!DOCTYPE html>
<html><title/><body bgcolor="black"/></html>
It should be not to difficult to write some simple wrapper classes
with Snit or something similar. As a side effect the same code might
run with tdom also. But using snit may slow down the code. Did
anyone have a better suggestion?
regards,
Detlef
--
Dr. Detlef Groth
Max-Planck-Institut
fuer Molekulare Genetik
Ihnestr. 63/73
D-14195 Berlin
Tel.: + 49 30 - 8413 1235
|