[reportlab-users] pyRXP and processing instructions
Andy Robinson
reportlab-users@reportlab.com
Wed, 5 Mar 2003 01:02:48 -0000
> I like this choice too.
> What was the purpose of the arg in the tuple tree? How can it be neatly
> used?
It was just a placeholder for future use and we have not
figured out quite what for. We figured that if we wrote
lots of client code like this:
(name, attrs, children, stuff) = myNode
then we would not have to break this code later. If we
did (name, attrs, children) then it would break later.
IMHO the most important thing to put there would be info
on the position in the original XML spanned by
the tag. However, it's not clear what structure to use.
And there will be other ideas.
Suggestion: certain not-implemented-yet parser flags could
result in the fourth argument becoming a dictionary of
extra info. This would obviously slow things down and
increase memory use considerably, but you would only take the
hit if you needed it. Also, your own apps would be free to put
things in the dictionary in slot 4.
So for an app which wanted to be able to quote line numbers
in the original XML, or do accurate rewriting of unchanged
nodes, we could ask the parser to insert these facts:
tagStartByteOffset
tagStartLineNo
tagStartLinePos
tagEndByteOffset
tagEndLineNo
tagEndLinePos
Client apps could also very easily insert things like a link to
the parent node, or implement a 'modified' flag. They could do this
safe in the knowledge that there would not be any name
clashes with attributes of the XML being parsed, which could
happen if you put extra bits in the attribute dictionary.
just thinking aloud, I have no strong opinions on this.
Andy