|Think about Loose Coupling|
XML::Twig question and problemby BenHopkins (Sexton)
|on Jun 27, 2007 at 23:04 UTC||Need Help??|
BenHopkins has asked for the wisdom of the Perl Monks concerning the following question:
Hey monks! I grovel in the gravel and genuinely genuflect gratefulness.
I'm using XML::Twig (3.30) and want to replace all entities in the data with ascii equivalents, i.e. — with --.
I tried using a _default_ root handler like this:
And the subroutine fixup looks like this:
The fixup_tag hash has p, byttl, person, hl1, etc., otherwise I was changing higher level tags, like nitf and that removed all the internal tags (not a good thing).
Question: is there some way to apply a filter to just the data and leave the tagging and attributes alone.
I have a feeling that a good answer to the above will obviate what comes next:
Problem: after running this, the output is invalid. The input document has <nitf><head><title></title> followed by a bunch of <meta> tags. The output has (after the DOCTYPE) a <title></title>, the <meta> tags, then the <head>, with <title> and <meta> duplicated, then comes a copy of the whole mess, this time inside the <nitf></nitf> tags!
Obviously, I'm doing something wrong.
Anybody have an idea of what it is?