XML-Handler-YAWriter
view release on metacpan or search on metacpan
YAWriter.pm view on Meta::CPAN
Output option is given.
=item AsString boolean
This option will cause end_document to return the complete XML document
in a single string. Most SAX drivers return the value of end_document
as a result of their parse method. As this may not work with some
combinations of SAX drivers and filters, a join of $ya->{Strings} in
the controlling method is preferred.
=item Encoding string
This will change the default encoding from UTF-8 to anything you like.
You should ensure that given data are already in this encoding or provide
an Escape hash, to tell YAWriter about the recoding.
=item Escape hash
The Escape hash defines substitutions that have to be done to any
string, with the exception of the processing_instruction and doctype_decl
methods, where I think that escaping of target and data would cause more
trouble than necessary.
The default value for Escape is
$XML::Handler::YAWriter::escape = {
'&' => '&',
'<' => '<',
'>' => '>',
'"' => '"',
'--' => '--'
};
YAWriter will use an evaluated sub to make the recoding based on a given
Escape hash reasonably fast. Future versions may use XS to improve this
performance bottleneck.
=item Pretty hash
Hash of string => boolean tuples, to define kind of
prettyprinting. Default to undef. Possible string values:
=over
=item AddHiddenNewline boolean
Add hidden newline before ">"
=item AddHiddenAttrTab boolean
Add hidden tabulation for attributes
=item CatchEmptyElement boolean
Catch empty Elements, apply "/>" compression
=item CatchWhiteSpace boolean
Catch whitespace with comments
=item CompactAttrIndent
Places Attributes on the same line as the Element
=item IsSGML boolean
This option will cause start_document, processing_instruction and doctype_decl
to appear as SGML. The SGML is still well-formed of course, if your SAX events
are well-formed.
=item NoComments boolean
Supress Comments
=item NoDTD boolean
Supress DTD
=item NoPI boolean
Supress Processing Instructions
=item NoProlog boolean
Supress <?xml ... ?> Prolog
=item NoWhiteSpace boolean
Supress WhiteSpace to clean documents from prior pretty printing.
=item PrettyWhiteIndent boolean
Add visible indent before any eventstring
=item PrettyWhiteNewline boolean
Add visible newlines before any eventstring
=item SAX1 boolean (not yet implemented)
Output only SAX1 compliant eventstrings
=back
=back
=head2 Notes:
Correct handling of start_document and end_document is required!
The YAWriter Object initialises its structures during start_document
and does its cleanup during end_document. If you forget to call
start_document, any other method will break during the run. Most likely
place is the encode method, trying to eval undef as a subroutine. If
you forget to call end_document, you should not use a single instance
of YAWriter more than once.
For small documents AsArray may be the fastest method and AsString
the easiest one to receive the output of YAWriter. But AsString and
AsArray may run out of memory with infinite SAX streams. The only
method XML::Handler::Writer calls on a given Output object is the print
( run in 1.779 second using v1.01-cache-2.11-cpan-0d23b851a93 )