in reply to Re: broken twig?
in thread broken twig?

That is the thing that confuses me. $twig->purge in process_attachment() seems to delete the whole record, not just the attachment. What I want to do is purge only the attachment.

I also call purge in process_record and it seems to do what is expected there (if I comment out the purge in process_attachment that is) Meaning if I have multiple records, each one is purged in turn after processing
using purge_up_to($attach) does the same. When process_record is called it has no children so it has nothing to process Am I doing something wrong in the way I handle the attachment?

here is a more faithful view of the xml:

<document version="2.2"> <record> <record_id>113082</record_id> <creation_ts>2005-09-08 11:53 MDT</creation_ts> <short_desc>test</short_desc> <delta_ts>2005-09-08 11:58:21 MDT</delta_ts> <attachment> <attachid>47644</attachid> <date>2005-09-08 11:55 MDT</date> <desc>diff</desc> <data>Large amounts of encoded data in excess of 5 MB </data> </attachment> <attachment> .... </attachment> </record> </document>

Replies are listed 'Best First'.
Re^3: broken twig?
by mirod (Canon) on Sep 13, 2005 at 21:04 UTC

    The twig_purge in attachment will indeed purge everything before that element, meaning that the record_id, creation_ts, short_desc and delta_ts elements will be purged, but the (now empty) record will be kept. Is this what is causing you problems?

    Maybe what you are looking for is just $attach->delete in the attachment handler, then $twig->purge in the record handler. If Scalar::Util is installed, then using delete will release the memory for the attachment (at least so it can be re-used by the Perl process).

      That is exactly what I need ($attach->delete) THANK YOU!!!

      btw, The XML::Twig module is absolutely awsome. It has greatly reduced the amount of work I need to do on this project (we had been using just plain old XML::Parser tree with a load of magic numbers to identify elements)

      Out of curiosity, is Scalar::Util installed with the base perl packages? cause I don't recall installing it separately but it seems to be on my system.

      Thanks again.

        I believe Scalar::Util was added to the core in 5.8.0 (according to perldoc perl58delta).

        And thanks for your kind words.