[reportlab-users] pyRXP and processing instructions
Stuart Bishop
reportlab-users@reportlab.com
Tue, 4 Mar 2003 08:49:00 +1100
On Monday, March 3, 2003, at 11:56 PM, Andreas Jung wrote:
>>> I have not found any pointer to pyRXP and processing instructions.
>>> Is there some support planned?
>>>
>>> Thanks,
>>> Andreas
>>
>> I'm pretty sure RXP will generate some event but not sure how
>> we should handle it in our tree representation. It's an
>> interesting question. What do you think it should do when it
>> sees a processing instruction? Call a callback? Make a new
>> kind of node in the tree?
>
> I think processing instructions should be represented by a new node
> that makes the PI available for later processing. A callback is not
> very useful since processing happens after pyRXP would have created
> the nested tuple representation.
I personally don't like comments being returned as '<!-- foo -->'.
I was going to make <?processing instructions?> return the same way
for compatibility, but want to alter the representation slightly (if
a flag is set). I think this is best done either as:
- Comments & processing instructions are returned as an element
tuple rather than a string. You can tell it is a special node
as t[0] in (pyRXP.Comment, pyRXP.ProcessingInstruction). This is
problematic for a processing instruction, as you really want it
split into 'command' and 'arguments'.
- A 'Comment' or 'ProcessingInstruction' class is returned instead
of the element tuple.
In theory, we could return more intelligent classes than 'tuple' now
without sacrificing backwards compatibility, speed or memory by
subclassing
tuple (?). Perhaps a real life DOM tree could be returned via
parser.Parse()?
I havn't looked to closely at this yet - it is still in blue sky stage.
And while I'm here - RXP 1.3 has been released and apparently fixes
some memory
leaks and stuff. It drops in happily over the existing RXP, except that
myWarnCB
in pyRXP.c breaks. Everything still works fine (except for the warning
callback)
if I make myWarnCB just 'return'.
--
Stuart Bishop <zen@shangri-la.dropbear.id.au>
http://shangri-la.dropbear.id.au/