[Zope] ParsedXML Documentation / Examples?

Giuseppe Bonelli giuseppe.bonelli@tiscali.it
Tue, 1 Jul 2003 18:37:05 +0200


> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
> zoper@disturbance.dhs.org
> Sent: martedi 1 luglio 2003 17.21
> To: Duncan M. McGreggor
> Cc: zope-xml@zope.org; Zope
> Subject: Re: [Zope] ParsedXML Documentation / Examples?
>
>
> Duncan,
>
> Thanks for the response. I guess I should clarify a bit: I am
> looking for
> tools to aid in the creation of XML from a large, heierarchical set of
> data (well, large here = ~300 nodes) produced dynamically
> from an RDBMS,
> then store this XML document in a single text blob in the
> database - kind
> of a 'snapshot' of the current set of data.

I would write a simple product defining:

1. a folderish container class
2. a dtml-like class for storing the xml, something like:

from somewhereInYourPythonPath import allTheNecessaryModules

def addMyXMLFile(self, id, title='', REQUEST=None):
    "too lazy to use a docstring here"
    ob=myXMLFile(id, title, XMLStringContent)
    self._setObject(id, ob)
    self._getOb(id).reindex_object()
    message = """A new xmlFile as been added and the project schedule is
back on track\n"""
    return MessageDialog(title   = 'XML added',
			message = message.replace('\n','<br/>'),
			action  = ".")

class myXMLFile(CatalogAware, DTMLDocument.DTMLDocument)
    """you want a docstring, don't you?"""
    meta_type = 'My XML File'
    manage_options=DTMLDocument.DTMLDocument.manage_options
    def __init__(self, id, title, XMLContent):
    "initialise a new istance"
    DTMLDocument.DTMLDocument.__init__(self, XMLContent)
    self.id=id
    self.title=title
Globals.default__class_init__(editableEoloXMLFile)

Note that you have to supply the xml from your RDBMS as a string (in the
correct encoding).

>From now on you can do pretty everything you need to your XML. I use
routinely XMLTransform (and soon its successor zopexmlmethods) and
standard python XML tools.

I would also, probably, keep the xmlfile on the file system using
localFS or the like (ie externalFile).

Doing all this from external python code gives you, IMHO, a tremendous
flexibility.


>[...snip...]
> ZopeXMLMethods looks to be very specific to handling XSL transforms;
> ParsedXML, now that I have looked more deeply at it, seems
> focused on a
> ZMI interface to XML documents (though documentation indicates that it
> should be possible to use DTML to create and manipulate XML data).

Thats my understanding, too. I tend to use ZopeXMLMethods.

>
> Anyone, please correct me if I am mistaken in the above statements.
>
> At this point, the shortest route to get what I want appears
> to be to use
> TTW Python Scripts and just deal with Python's native XML
> capabilities...
> comments?

I would use external python code, as detailed above.

>
> Any advice and / or personal anecdotes about what has worked
> for you and
> what hasn't would be appreciated. As with many projects, I am
> up against a
> deadline already passed.
>

The above mentioned architecture has proveed for me very useful and easy
to mantain. I cannot, though, give you comment on performance, as my
user application profile is quite light (i.e. less than 5 concurrent
user on a xml base of less than 500 fragments). What for sure helps, is
having many small xml documents rather than few big documents. I learned
to automatically split imported xml document in subfolders, based on
some high level tag in your xml tree. This gives you the added
advantages of context sensitive (at folder level) search capabilities
out of the box using Zcatalog.

Hope this helps.

--peppo
PS: deadlines are already passed by definition. Othervise we would call
them lifelines :)