PushParser

[Raku LibXML Project] / [LibXML-Writer Module] / Writer :: PushParser

class LibXML::Writer::PushParser

LibXML push-parser construction

Synopsis

use LibXML::Writer::PushParser;
use  LibXML::SAX::Handler::SAX2;
class SAXShouter is LibXML::SAX::Handler::SAX2 {
    use LibXML::SAX::Builder :sax-cb;
    method startElement($name, |c) is sax-cb {
        nextwith($name.uc, |c);
    }
    method endElement($name, |c) is sax-cb {
        nextwith($name.uc, |c);
    }
    method characters($chars, |c) is sax-cb {
        nextwith($chars.uc, |c);
    }
}

my SAXShouter $sax-handler .= new;
my LibXML::Writer::PushParser $writer .= new: :$sax-handler;

$writer.startDocument();
$writer.startElement('Foo');
$writer.startElement('Bar');
$writer.endElement;
$writer.push('<Baz/>');
$writer.endElement;
$writer.endDocument;
my $doc = $writer.finish-push;
say $doc.Str; # <?xml version="1.0" encoding="UTF-8"?><FOO><BAR/><BAZ/></FOO>

Description

This class allows document construction via an externally defined LibXML::PushParser object.

It is most likely to be useful if the XML is to be consumed via a LibXML SAX handler.

LibXML::Writer v0.0.1

Raku bindings to the libxml2 streaming writer

Authors

  • David Warring

License

Artistic-2.0

Dependencies

LibXML:ver<0.9.5+>

Test Dependencies

Provides

  • LibXML::Raw::TextWriter
  • LibXML::Writer
  • LibXML::Writer::Buffer
  • LibXML::Writer::Document
  • LibXML::Writer::File
  • LibXML::Writer::Node
  • LibXML::Writer::PushParser

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.