[Zope-xml] wandering the tree questions

Christopher N. Deckard cnd at ecn.purdue.edu
Wed Jan 23 13:46:45 EST 2002


I have an XML document here:

http://eng.purdue.edu/people/cnd/zope/ParsedXML/xml_documents/usgs_cru_xml

I am using this for a template system.  Basically, you define a
template in the XML document, and then I use it to dynamically build
a HTML form.  It's got other meta-data for noting that something is
required or has to be a certain type etc.  I don't store my data in
XML, I store it in a zope Folder and the properties of a folder hold
the value for each part of the data I need to collect.

I thought that I would be all fancy with this and make it so that I
don't have to write lots of XML just to define properties.  I made
it so that I could define a property that has sub properties.  This
has pretty much infinite nesting, but actually Zope will kick in and
say that there was too much recursion.

Basically I want to generate a list of properties something like
this:
where:
  p = property
  sp = sub property
  ssp = sub property of sub property

properties:
  p1.sp1
  p2.sp1
  p3.sp1.ssp1
  p3.sp2.ssp1

So something like that.  The whole p.sp.ssp thing is the name of the
property that gets created as a property of a folder.  If you look
at the XML (in the templates section) you'll notice that it's kinda
like this

  <template>
    <version>
      <properties>
        <property/>
        <property/>
          <properties>
            <property>
          </properties>
        </property>
      </properties>
    </version>
  </template>


The way I get the p.sp.spp stuff is through a recursive python
script.  I originally go to a "version" node, and then did for
version.childNodes and looked for "properties", then did childNodes
on that and looked for "property" nodes.  If  "property" node had an
attribute called "type" equal to "parent", then it would call the
same method on that "property" node... recursively.

All of this was very quick when this resided on a ZEO cluster.  We
moved it from a ZEO setup to a straight Zope setup, and now it's
extremely slow.  In looking at my code, and looking at what i'm
iterating over, I keep looking at the same nodes over and over
again.

So I rewrote it to use getElementsByTagName.  This seems to be a
little faster, but that method seems to get everything under a node
with an element of that name.  So if I am on the first "properties"
node (above) and do a getElementsByTagName('property'), I get back
every single element, including things that are child nodes of other
things.  This makes what I'm trying to do pointless as I don't know
which is a sub "property" of a "property".

I hope this is making sense.  It doesn't seem to as I type it.  :-)

Does anyone have a suggestion on the best way to generate my list of
properties?  Or should I just forget the nesting and basically hard
code them?

-Chris

-- 
--------------------------------------------------------------------
    Christopher N. Deckard      |     Lead Web Systems Developer
      cnd at ecn.purdue.edu        |    Engineering Computer Network
  http://www.ecn.purdue.edu/    |         Purdue University 
---- zlib.decompress('x\234K\316Kq((-J)M\325KM)\005\000)"\005w') ---




More information about the Zope-xml mailing list