XML, the Perl Way

Home XML::Twig Modules Talks Articles Tutorials Reports Tools PGC mirod Le Blog

XML::Twig::Blog

28 Apr 2006

XML::Twig News: VMS Patch

Peter (Stig) Edwards sent me a patch to fix all the build problems on VMS.

I integrated the changes, which fell in a few categories:

  • VMS supports only 1 dot per file name, so no more t/test_3.22.t,
  • tools like cat, echo and even... perl are not necessarily available, so I had to replace them, either with the VMS version, or by finding the right version of perl and using it,
  • VMS quirks, like LWP::Simple not forking.

I don't have a VMS machine here, so of course I could not test the changes, but it looks like they should be OK.

The whole discussion is on RT.

BTW, on the subject of patches: I rarely apply them as is. Don't take it personally. First, patches are often on Twig.pm, which is generated from Twig_pm.slow, so I can't apply them directly. Then, surprisingly enough, I like to know what's in a patch before applying it, so I review them carefully, and what best way to review them than to rewrite them. Then I often find better ways, or at least ways that are more consistent with the existing module, to make the change, or more general. But I appreciate getting them anyway.

[XML::Twig News] [permalink]



21 Mar 2006

XML::Twig News: New name for an old method: unwrap

Chris Burbridge suggested that the erase method be aliased to unwrap, to spare others missing it and re-writing it, as he did.

This is now in the development version.

In case you had missed it, erase / unwrap removes an element, replacing it by all of its children, as if its start and end tags had been erased, or the element unwrapped and its content left in its place. Hence the names.

[XML::Twig News] [permalink]



03 Mar 2006

Module News: New *XPath* modules

I recently released 4 XPath-related modules on CPAN, so here is a little introduction:

There are 2 basic modules: XML::XPathEngine and Tree::XPathEngine. These 2 modules are basically a repackaging of XML:XPath. The 2 other modules, HTML::TreeBuilder::XPath and Tree::DAG_Node::XPath use those modules to add XPath support to respectively /HTML::TreeBuilder and Tree::DAG_Node.

XML::XPathEngine is very close to XML::XPath. I changed node sets so they can sort any node type that offers a cmp method), applied a few bug fixes (the ones I have had on RT for nearly 2 years now. I also integrated regular expressions into the language (see the docs). XML::XPathEngine should be used to add XPath support to XML or HTML modules. It creates objects that evaluate XPath expressions on a DOM. So as long as the calling module can fake a DOM convincingly enough, XML::XPathEngine will evaluate XPath expressions. The closer the calling module mimicks a DOM, the more of XPath is supported.

HTML::TreeBuilder::XPath uses XML::XPathEngine, and adds methods like findnodes and findvalue to any tree (in fact to any HTML::Element object).

Tree::XPathEngine is a simplified version of XML::XPathEngine, for "non-.*ML" trees. They assume a simpler model (tree, nodes, attributes, optional text value for nodes) and the names of methods are more perlish (no camelCase). It also allows a different regexp to be used for node and attribute names, so you're not limited to XML names.

Tree::DAG_Node::XPath adds the usual findnodes, findvalue... to Tree::DAG_Node.

The idea for these modules stemmed from my XXX (eXtending XML::XPath) article and talk. I felt that it was worth re-using XML::XPath, and making it easier to re-use. Plus the module did not seem to be really maintained, so I wanted to be able to at least fix the bugs.

The docs for the *::XPathEngine modules are probably a little lacking at this point, and I would welcome any feedback on them, especially from people who would use the modules to add XPath to other modules (WWW::Mechanize anyone?).

[Module News] [permalink]



Comments

Recent

Archives

2006