Posted on 2009-12-04 00:03:37-08 by trendle
Change Request...for replicateElement in OODoc::XPath

Just getting used to this (still not sure what differentiates a 'node' from an 'element', but that's something else).

After misreading the Doc for a bit and wondering why my added sheet always came AFTER and not 'before' as I expected I realised my mistake and fixed it.

$new_sheet = $doc->replicateElement($sheet,$sheet,position => 'before');

But looking at the code, there's scope for a trivial simplification that would make life for simple sods like me much easier.... (seeing that 'sheet' is referenced twice, once for the copy, and once for the location).

So with a small change to XPath.pm I can now write (with the same result) ...

# $new_sheet = $doc->replicateElement($sheet,'before');

Here's the diff code...

relative to the following version...

# # $Id : XPath.pm 2.229 2009-05-24 JMG$ # # Created and maintained by Jean-Marie Gouarne # Copyright 2008 by Genicorp, S.A. (www.genicorp.com) # #----------------------------------------------------------------------------- package OpenOffice::OODoc::XPath; use 5.008_000; our $VERSION = 2.229; use XML::Twig 3.32; use Encode;

--------- RCSDIFF ---------

rdiff -r1.1 XPath.pm 1990a1991,1998 > elsif ($position eq 'before') > { > $element->paste_before($proto); > } > elsif ($position eq 'after') > { > $element->paste_before($proto); > }

----------------------------

Hope you can make use of this.

Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.