dynamic update of XML-Documents from local FileSystem
Dear List, is it possible to link xml-documents residing in the local filesystem to zope via the XML-Document Product dynamically. It means that changes in the xml-document are reflected in zope on the fly? If somebody knows about that, I would be very thankful for some hints how to do it? Elena
Elena Schulz wrote:
is it possible to link xml-documents residing in the local filesystem to zope via the XML-Document Product dynamically. It means that changes in the xml-document are reflected in zope on the fly?
If somebody knows about that, I would be very thankful for some hints how to do it?
This sounds tricky to do. Both XMLDocument (which isn't maintained anymore, btw) as well as its successor ParsedXML (which is being maintained and developed further) store the XML as a tree of objects, not as text. When you view the contents for instance in the Zope management screens, it'll ask the tree to render itself as XML text on the fly each time. The tree in XMLDocument follows loosely the w3c DOM level 1 recommendation, while the tree in ParsedXML strictly implements the w3c DOM level 2 recommendation. So, if a file on the local file system contains XML and changes what would need to happen in Zope is more than a simple access to the text data and passing it through XMLDocument. What would need to happen is a reparse of the XML text, storing it in the XMLDocument. It should be possible to either adapt XMLDocument (or ParsedXML) or write some new product that does something like this, though: Each document in Zope would carry with it a path to the filesystem file, and a last changed datetime of the file. Then, on each access to the document object (this is the tricky part; I am not sure how to do this without some inefficiency, unless you make sure the user code is responsible to trigger this check instead), you check the file in the filesystem, compare the last change datetime with the one you stored, and if the file on the filesystem is newer, load the file and call a method to reparse the entire tree into XMLDocument (or ParsedXML). Why do you want to do this by the way? Would it help if ParsedXML had working FTP support, for instance? I've sent a cc of this reply to the zope-xml list as well; it is a good place to discuss XML questions. Regards, Martijn
participants (2)
-
Elena Schulz -
Martijn Faassen