From: Ype K. <yk...@xs...> - 2001-09-02 09:43:06
|
Ted, >I'm trying to build a simple XML editor targetted at a specific use. I am >displaying the xml node names as elements in a JTree and have implemented a >TreeModel to accomplish this. > >The nodes in the tree model extract relevant info from a JDOM Element object >passed to their fromXML method after creation. This method populates the >callee node's child list and calls each child's fromXML method. > >From the print out generated by the fromXML method, it appears that >everything is working, but when the process is complete another print shows >that something has gone dramatically wrong. > >print generated during population: > > [Element: <nodehandler/>] > [Element: <group_atts/>] > [Element: <nodehandler/>] > [Element: <file/>] > [Element: <nodehandler/>] > [Element: <file/>] > [Element: <nodehandler/>] > [Element: <file/>] > >print of tree root element's 'children' list after population of the >TreeModel: > >[group_atts, file, nodehandler, file, nodehandler, file, nodehandler] > >Relevant code snippet from InstallSetTreeModel: > > def fromXML( self, node, space='' ): > print space,node > self.name = node.name > for n in node.children: > f = InstallSetTreeModel( self ) > f.fromXML( n, space+' ') > self.children.append( f ) > >Obviously *something* isn't right. What am I doing wrong? node is a JDOM >Element object, node.children returns a List of child Elements. Once this >model is placed in a tree, each node in the tree has for children each node in the tree. It's a *huge* circular reference bug, and I haven't been able >to find it. First off: I am not familiar with JDOM and XML, so what follows might be quite non relevant. It seems to me that your problem might be caused by f = InstallSetTreeModel( self ) returning self instead of a newly created InstallSetTreeModel. Supposing this is a constructor call, why is self passed? In case you want a new child node (f is appended to self.children lateron), you might introduce a separate method for creating a new child node. > >The code is part of a project that will allow java/jython applications to >download updates from a website. The whole shebang will be publicly >available when i'm done too, if that's any sort of carrot. :) > >I can post the whole file if it would help, I just wanted to avoid spamming >the list right off. > >ted > >_______________________________________________ >Jython-users mailing list >Jyt...@li... >https://lists.sourceforge.net/lists/listinfo/jython-users |