perl-XML-Filter-Hekeln - XML-Filter-Hekeln - a SAX stream editor

Property Value
Distribution RPM Universal
Repository Olea all
Package filename perl-XML-Filter-Hekeln-0.06-1.noarch.rpm
Package name perl-XML-Filter-Hekeln
Package version 0.06
Package release 1
Package architecture noarch
Package type rpm
Homepage -
License -
Maintainer -
Download size 22.19 KB
Installed size 28.16 KB
XML::Filter::Hekeln is a sophisticated SAX stream editor.
Hekeln is a SAX filter. This means that you can use a Hekeln
object as a Handler to act on events, and to produce SAX events
as a driver for the next handler in the chain. The name Hekeln
sounds like the german word for crocheting, whats the best to
describe, what Hekeln can do on markup language translation.
The main design goal was to make it as easy for Perl as possible,
while preserving a human readable form for the translation script.
Hekeln scripts are event based. Hekeln objects stream events to
the next in chain. They are therefore useable to handle XML
documents larger than physical memory, as they do not need to
store the entire document in a DOM or Grove structure. They will
also be faster than any XSL in most circumstances.
To tell you straight, how Hekeln works, I'll start with an example.
I want to translate XML::Edifact repositories into html. Those
repositories start with something like this:
desc="based on UN/EDIFACT D422.TXT"
name="Service Segment Directory"
Here is a sniplet from :
!	$self->handle('start_document',{});
<	html	>
<	body	>
<	h1	>
XML-Edifact Repository
</	h1	>
<	h2	>
</	h2	>
<	p	>
Agency: ~agency~
<	br	>
Code: ~code~
<	br	>
Version: ~version~
<	br	>
Description: ~desc~
</	p	>
<	hr	>
</	body	>
</	html	>
!	$self->handle('end_document',{});
This part is handling start_element and end_element events, that have
a target called repository. The translation done by Hekeln is done into
subroutines that are stored in a hash.
So anything is possible, if you understand the trick. To understand
the trick, uncomment the "'Debug' => 1" parameter of Hekeln invocation
in the script and redirect STDERR to some file.
This will produce a file starting like :
$hash->{start_element:repository}=eval "sub {
my ($self,$param) = @_;
my ($hash) = {};
$hash->{Name}="html"; $self->handle("start_element", $hash);
$hash->{Name}="body"; $self->handle("start_element", $hash);
$hash->{Name}="h1"; $self->handle("start_element", $hash);
$hash->{Data}="XML-Edifact Repository"; $self->handle("characters", $hash);
$hash->{Name}="h1"; $self->handle("end_element", $hash);
$hash->{Name}="h2"; $self->handle("start_element", $hash);
$hash->{Data}="$param->{name}"; $self->handle("characters", $hash);
$hash->{Name}="h2"; $self->handle("end_element", $hash);
$hash->{Name}="p"; $self->handle("start_element", $hash);
$hash->{Data}="Agency: $param->{agency}"; $self->handle("characters", $hash);
$hash->{Name}="br"; $self->handle("start_element", $hash);
$hash->{Data}="Code: $param->{code}"; $self->handle("characters", $hash);
$hash->{Name}="br"; $self->handle("start_element", $hash);
$hash->{Data}="Version: $param->{version}"; $self->handle("characters", $hash);
$hash->{Name}="br"; $self->handle("start_element", $hash);
$hash->{Data}="Description: $param->{desc}"; $self->handle("characters", $hash);
$hash->{Name}="p"; $self->handle("end_element", $hash);
$hash->{Name}="hr"; $self->handle("start_element", $hash);
$hash->{end_element:repository}=eval "sub {
my ($self,$param) = @_;
my ($hash) = {};
$hash->{Name}="body"; $self->handle("end_element", $hash);
$hash->{Name}="html"; $self->handle("end_element", $hash);
As you can imagine ~foobaa~ parts within a script will become expanded
with the the attributes given in the XML start_element event. Syntax
itself is a bit tricky as translation of the script into a sub is
stupid and fast.
Any event that has to be handled by Hekeln starts with an event_name
event_target pair and ends with a blank line.
Valid as left_indicator are "<", "</", "", "!", "+", "-", "++, "--",
"?{" and "?}", while the right indicator may be optional execpt for "<".
The first produce start_element, end_element and character events,
to make Hekeln scripts look similar to the markup you want to produce.
The "!" indicator is something special as it will be copied into the
sub as it is, to be evaluted in the complete context of a script. So its
possible to code conditionals or even loops with a constructions like
those :
!	$self->{Flag}{FooBaa}=1;
!	unshift @{$self->{Stack}}, "FooBaa";
!	$self->{Flag}{FooBaa}=undef;
!	shift @{$self->{Stack}} if $self->{Stack}[0] eq "FooBaa";
!	if ($self->{Flag}{FooBaa}) {
<	h1	>
flag FooBaa raised
</	h1	>
!	}
It wont be necessary to code exactly this, as this is done by "++", "--",
"?{" and "?}". "+" and "-" will raise or lower some flag, while "++" and
"--" not only manage the flags, but also a stack that is needed to process
character events.
The default behavior is to throw away any event that does not have a
subroutine matching the event, target pair. Events that do not have a
target, will use the top flag on the stack as a target. So if you want
to process character events, use "++" and "--" when handling the
surounding start_element and end_element events.
As a last word: Hekeln is not yet well tested, and badly needs some
better documentation. I would aplaude anybody for naming bug, or improving
the POD.


Package Version Architecture Repository
perl-XML-Filter-Hekeln - - -


Name Value
/usr/bin/perl -
perl(IO::File) -
perl(XML::Handler::YAWriter) -
perl(XML::Parser::PerlSAX) -
perl(strict) -
perl(vars) -


Name Value
perl(XML::Filter::Hekeln) = 0.06
perl-XML-Filter-Hekeln = 0.06-1


Type URL
Binary Package perl-XML-Filter-Hekeln-0.06-1.noarch.rpm
Source Package perl-XML-Filter-Hekeln-0.06-1.src.rpm

Install Howto

  1. Download latest olea-repo-release rpm from
  2. Install olea-repo-release rpm:
    # rpm -Uvh olea-repo-release*rpm
  3. Install perl-XML-Filter-Hekeln rpm package:
    # yum install perl-XML-Filter-Hekeln




2007-01-06 - olea@lisergia
- Initial build.

See Also

Package Description
perl-XML-Handler-YAWriter-0.23-1.noarch.rpm XML-Handler-YAWriter - Yet another Perl SAX XML Writer
perl-XML-LibXML-1.62001-8.i386.rpm XML-LibXML Perl module
perl-XML-LibXML-Common-0.13-1.i686.rpm XML-LibXML-Common - Routines and Constants common for XML::LibXML and XML::GDOME
perl-XML-LibXML-Iterator-1.00-1.noarch.rpm XML-LibXML-Iterator - XML::LibXML's Tree Iteration Class
perl-XML-LibXML-XPathContext-0.07-1.i686.rpm XML-LibXML-XPathContext - Perl interface to libxml2's xmlXPathContext
perl-XML-NamespaceSupport-1.09-1.noarch.rpm XML-NamespaceSupport - a simple generic namespace support class
perl-XML-NodeFilter-0.01-1.noarch.rpm XML-NodeFilter - Generic XML::NodeFilter Class
perl-XML-RSS-1.02-1.i386.rpm Autogenerated package for XML-RSS
perl-XML-SAX-0.14-1.noarch.rpm XML-SAX - Simple API for XML
perl-XML-SAX-Writer-0.44-8.noarch.rpm XML-SAX-Writer Perl module
perl-XML-XUpdate-LibXML-0.6.0-1.noarch.rpm XML-XUpdate-LibXML - update XML documents according to XUpdate file
perl-makerpm-0.409-1.noarch.rpm makerpm - Build binary distributions of Perl packages
perl-namespace-autoclean-0.08-1.noarch.rpm namespace-autoclean - Keep\ imports\ out\ of\ your\ namespace
perl-namespace-clean-0.11-1.noarch.rpm namespace-clean - Keep imports and functions out of your namespace
php-pear-Mail-mimeDecode-1.5.0-4.el5.noarch.rpm Class to decode mime messages