NAME
XML::Xalan::DocumentBuilder - Provides Perl SAX2 handlers
SYNOPSIS
use XML::Xalan;
...
my $doc_builder = $tr->create_document_builder();
my $parser = AnySAX2Parser->new(
Handler => $doc_builder->get_content_handler()
);
# fires SAX2 events..
$parser->parse_file($file);
# then transform the document builder object..
$tr->transform_to_file($doc_builder, $xsl, $output);
DESCRIPTION
This class provides Perl SAX2 handlers, so an XML::Xalan::Transformer
object can transform input source parsed by any Perl SAX 2.0 conformant parser.
Currently supported handlers are content handler, dtd handler, and lexical handler.
METHODS
- $doc_builder->get_content_handler()
-
Returns an
XML::Xalan::ContentHandler
object. - $doc_builder->get_dtd_handler()
-
Returns an
XML::Xalan::DTDHandler
object. - $doc_builder->get_lexical_handler()
-
Returns an
XML::Xalan::LexicalHandler
object.
REUSABILITY
XML::Xalan::DocumentBuilder
object is only reusable with the same input source. This means the following snippet won't work:
# reuse the document builder with different input sources:
for (1..100) {
$p->parse_uri("$_.xml");
my $res = $tr->transform_to_file($db, "foo.xsl", "$_.out");
}
This is not a bug, as it is imposed by the underlying C++ implementation.
Thus, for different input sources, you should recreate the document builder and parser object for each of them:
for (1..100) {
my $db = $tr->create_document_builder();
my $p = XML::SAX::PurePerl->new(
Handler => $db->get_content_handler();
);
$p->parse_uri("$_.xml");
my $res = $tr->transform_to_file($db, "foo.xsl", "$_.out");
$tr->destroy_document_builder($db);
}
AUTHOR
Edwin Pratomo, edpratomo@cpan.org
SEE ALSO
XML::Xalan::Transformer
(3).