[jdev] Child nodes of DOM Attr
Joonas Govenius
joonas.govenius at gmail.com
Mon Sep 17 21:57:07 CDT 2007
On 9/17/07, Justin Karneges <justin-keyword-jabber.093179 at affinix.com> wrote:
> On Monday 17 September 2007 6:20 pm, Joonas Govenius wrote:
> > On 9/17/07, Joonas Govenius <joonas.govenius at gmail.com> wrote:
> > > Hi all,
> > >
> > > I ran into this problem with the Qt DOM implementation when writing
> > > some code for shared XML editing:
> > >
> > > If I try to insert a DOM Text node to a DOM Attr node using
> > > appendChild(), nothing happens. Does anyone know for sure whether
> > > that's the correct behavior?
> >
> > I guess this is standard. Firefox tells me "Modifications are not
> > allowed for this document" if I try to do this with JavaScript:
>
> What on earth are you doing?! :)
:)
I was considering whether I should allow someone to, say, append some
text to an attribute by appending it as a new text node.
> Attributes have a single value. They do not
> have child text nodes.
>
> You mentioned Qt DOM. In that case consider QDomAttr.setValue("value"). More
> conveniently, just call QDomElement.setAttribute("name", "value").
>
Right. that's what I ended up doing.
However, it doesn't seem that clear to me that "attributes have a
single value". According to
http://www.w3schools.com/dom/dom_nodetype.asp for example, Attr nodes
can have Text and EntityReference nodes as child nodes. They can all
be serialized into a single string though so in that sense you're
right and I think I'll just treat them as such.
Joonas
More information about the JDev
mailing list