XML-LibXML-LazyBuilder
view release on metacpan or search on metacpan
lib/XML/LibXML/LazyBuilder.pm view on Meta::CPAN
# NO-OP: Elements get attached to the root from inside the E
# function so it can access the namespace map.
}
else {
$dom->appendChild($node);
}
$dom;
}
sub E ($;$@) {
my ($name, $attr, @contents) = @_;
return sub {
my ($dom, $parent) = @_;
# note, explicit namespace declarations in the attribute set
# are held separately from actual namespace mappings found
# from scanning the document.
my (%ns, %nsdecl, %attr, $elem, $prefix);
lib/XML/LibXML/LazyBuilder.pm view on Meta::CPAN
else {
$elem->appendTextNode ($child);
}
}
$elem;
};
}
# processing instruction
sub P ($;$@) {
my ($target, $attr, @text) = @_;
return sub {
my $dom = shift;
# copy, otherwise this will just keep packing it on if executed
# more than once
my @t = @text;
# turn into k="v" convention
lib/XML/LibXML/LazyBuilder.pm view on Meta::CPAN
else {
unshift @t, $attr;
}
}
return $dom->createProcessingInstruction($target, join '', @t);
};
}
# comment
sub C (;@) {
my @text = @_;
return sub {
my $dom = shift;
$dom->createComment(join '', @text);
};
}
# CDATA
sub D (;@) {
my @text = @_;
return sub {
my $dom = shift;
$dom->createCDATASection(join '', @text);
};
}
# document fragment
sub F (@) {
my @children = @_;
return sub {
my $dom = shift;
my $frag = $dom->createDocumentFragment;
for my $child (@children) {
# same as E
if (_is_really($child, 'CODE')) {
$frag->appendChild($child->($dom));
}
( run in 1.817 second using v1.01-cache-2.11-cpan-524268b4103 )