[XML-SIG] Interested in feedback

Benjamin Saller case@appliedtheory.com
Tue, 27 Jun 2000 16:08:13 -0400 (EDT)

Today, Paul Prescod wrote:

    Some interesting ideas...to a certain extent, though you should watch
    out for reinventing the wheel.

    Benjamin Saller wrote:
    > xml.getValue("container1.allow.host")     # == 'loki'
    > xml.getValue("container2.allow.host[1]")  # == 'foo.bar.com'
    What happens if you don't give an index but there are multiple
    sub-elements of a type? Do you get a list or the first one?

You get the first element of a set on a call to getValue. If your code
supports multiple values getValues is your friend and can return a
list of typed data.
    The "." is a legal XML name character. You could have an element type
    named "container1.allow.host." 

    "/" would be a better choice.

Thats a good point. Making that switch would make sense at this point.
    If you do use "/" then you will have reinvented a tiny subset of XPath.
    No harm in that: you should probably look at the spec and try to
    rationalize your mini-language with it explicitly. I think that Python
    1.7 should have an XPath subset in it and this is probably a good start.

    Also, insofar as you have an in-memory tree data structure, it might be
    better to use a DOM rather than building your own structure using SAX.

I think that XPath is a more approachable idea than navigating a tree of
child nodes in a dom tree. Given that I don't expose any of that I thought
the DOM might be a bit heavy weight for very simple way it would be used.

When I started using XML in python I was really surprised to find that
there was no easy way to navigate an XML document. My hope was that even
if the implementation was questionable or didn't reuse all the tools in
PyXML people would see the idea and think about how to provide this
interface to people.
Thanks for your feedback.    

Benjamin Saller                                     <case@appliedtheory.com>
Technical Strategist                                AppliedTheory
	Where tire hits pavement on the Information super-highway,	
			 that's where my head is...