[XML-SIG] Reconsidering the DOM API

Walter Doerwald walter@livinglogic.de
Thu, 29 Jun 2000 11:26:12 +0200

At 20:08 28.06.00, Mike Olson wrote:
>Paul Prescod wrote:
> >
> > Walter Doerwald wrote:
> > >
> > > Why not put children and attribute access into __getitem__
> > >          c =3D b[0][1][0]["abc"]
> >
> > Not a bad idea as syntactic sugar. We should consider it for the NEXT
> > version of the DOM API mapping.
>I like it for syntatic sugar as well, but namespaces would make the
>attribute access interesting
>c =3D b[("http://www.fourthought.com","abc")]
>c =3D b["http://wwwifourthought.com:abc"]
>Also, for childNode access would we do anything about node types?  is
>b[0] the first child, first element, first elment with a certain
>tagname?  All I see as useful.

b[0] is the first child.

b.find(type =3D xml.Element)[0]
b.find(test =3D lambda x: type(x)=3D=3Dxml.Element)[0]
is the first child, that's an element.

b.find(type =3D html.a)[0]
b.find(test =3D lambda x: type(x)=3D=3Dhtml.a)[0]
is the first child with an element type of html.a.
Of course this means, that every element type corresponds
to a Python class (as the "abstract" Element already does).
(But again we have the problem of bringing namespaces into
this scheme).

         Walter D=F6rwald

Walter D=F6rwald =B7 LivingLogic AG =B7 Bayreuth, Germany =B7 www.livinglogi=