XMLDocument question
I'm beginning to work with XMLDocument and I have a question. I'm a pretty green Zope newbie, so please excuse me if this is naive. I'm able to import XML documents to form a tree of elements and access those elements based on their 'e#' id notation; attributes also get parsed correctly into properties. I've modified a display method from the Examples files to return the text content of any element in response to a url request, so things seem to be working correctly. What's the strategy behind the id notation approach to access? It's pretty unwieldy given that you must view the document's display in the management interface to see what ids are there, and ids change when the document is edited. Is there a way to use the tag names in a url to target particular parts of the document? The alternate access method based on the numerical sequence of elements through the hierarchy is useful for iteration and documents of rigid structure, but less useful than tag names with more flexible documents when a particular element or subtree is desired. Since the slideshow example uses tag names along with objectValues to target particular document content for display, the names are clearly there (somewhere) and usable ... maybe I'm just thinking about this the wrong way. If someone could post some additional example code dealing with tag name manipulation, it would probably be really helpful to me. Jim ________________________________________________________________________ James H. Harrison, Jr., MD, PhD University of Pittsburgh Health System C920 PUH, 200 Lothrop Street Pittsburgh, PA 15213 jhrsn@pop.pitt.edu | voice: 412-647-5529 | fax: 412-647-9588 "If you want sense, you'll have to make it yourself!!"-Norton Juster ________________________________________________________________________
Jim Harrison wrote:
I'm beginning to work with XMLDocument and I have a question. I'm a pretty green Zope newbie, so please excuse me if this is naive.
[snip]
What's the strategy behind the id notation approach to access? It's pretty unwieldy given that you must view the document's display in the management interface to see what ids are there, and ids change when the document is edited. Is there a way to use the tag names in a url to target particular parts of the document?
Hm, XMLWidgets may not do what you want exactly but it does allow a way to target tag names (and specific tags). Look it up at: http://www.zope.org/Members/faassen/XMLWidgets You'll need to dive into the Python sources to use it though, currently. [snip]
Since the slideshow example uses tag names along with objectValues to target particular document content for display, the names are clearly there (somewhere) and usable ... maybe I'm just thinking about this the wrong way. If someone could post some additional example code dealing with tag name manipulation, it would probably be really helpful to me.
XMLWidgets does contain plenty of sample code. :) Regards, Martijn
Martijn Faassen at m.faassen@vet.uu.nl wrote:
What's the strategy behind the id notation approach to access? It's pretty unwieldy given that you must view the document's display in the management interface to see what ids are there, and ids change when the document is edited. Is there a way to use the tag names in a url to target particular parts of the document?
Hm, XMLWidgets may not do what you want exactly but it does allow a way to target tag names (and specific tags). Look it up at:
Thanks for the tip--I haven't had a chance yet to look at the examples, but I'll try to review it over the weekend. The release notes suggest that XMLWidgets may address some of my issues. After a little thought, the answer to my simplistic question above is that XML documents may (often) have repeating elements at a given level of the hierarchy. When that is the case, a url using element names will not be able to target a unique location in the document. Duh. It would still be interesting to consider using node ids that are a bit more informative than the current ones. Say, the tag name concatenated with the numerical position of the tag in the sequence of similar tags at that level. Jim ________________________________________________________________________ James H. Harrison, Jr., MD, PhD University of Pittsburgh Health System C920 PUH, 200 Lothrop Street Pittsburgh, PA 15213 jhrsn@pop.pitt.edu | voice: 412-647-5529 | fax: 412-647-9588 "If you want sense, you'll have to make it yourself!!"-Norton Juster ________________________________________________________________________
participants (2)
-
Jim Harrison -
Martijn Faassen