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 extends XML::Xalan::ParsedSource by providing 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.

$doc_builder->get_document()

Returns an XML::Xalan::DOM::Document object. Inherited from XML::Xalan::ParsedSource.

ON 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), XML::Xalan::DOM(3).