NAME

XML::Beautify - Beautifies XML output from XML::Writer (soon to do any XML).

SYNOPSIS

B<WARNING:> This is Alpha Software. The interface is still subject to change. Oh, and keep backups, Doh!!!
B<WARNING:> This does not do well with already indented and formatted XML. I am still working on that. I am currently just reprinting the original string with E<additional whitespace>. I need to fix this by actually rewriting the XML from the element level on down using something like XML::Writer but adding in the whitespace. See E<recursive...>, Doh!

use XML::Beautify qw(:const); # imports three constants (YES,NO,FULL)
$obj_ref = XML::Beautify->new();
$cleanXML = $obj_ref->beautify(\$XMLstr);

B<NB:> This uses Log::AndError for error handling and logging functions. 
This is imported as an @ISA and so anything you can do there you can do here.

DESCRIPTION

Beautifies (converts to tree format) XML output from XML::Writer (soon to do any XML) to facilitate debugging XML or XML::Writer output.

METHODS

beautify()

Brown::Feeds::Entity::beutify()

Usage:
$obj_ref->beautify(\$XML);
Purpose:

Parses the output of

Returns:

($ok, $error) where $ok is 1 on success. $error is a diagnostic error message.

indent_str()

XML::Beautify::indent_str()

Usage:
	$indent_str = $obj_ref->indent_str();  # To retrieve the current value
        or
    $obj_ref->indent_str("\t"); # To set a new value
Purpose:

Sets or gets the indent str.

Returns:

($indent_str) if set.

rem_cr()

XML::Beautify::rem_cr()

Usage:
	$indent_str = $obj_ref->rem_cr();  # To retrieve the current value
        or
    $obj_ref->rem_cr(1); # To set a new value
Purpose:

Sets or gets the option to clean CR from XML before re-formatting.

Returns:

(true) if set.

rem_ws()

XML::Beautify::rem_ws()

Usage:
	$indent_str = $obj_ref->rem_ws();  # To retrieve the current value
        or
    $obj_ref->rem_ws(1); # To set a new value
Purpose:

Sets or gets the option to clean whitespace (Outside of char and cData) from XML before re-formatting. NB: This will remove blank whitespace from char sections if that is all that the char data contains.

Returns:

(true) if set.

orig_indent()

XML::Beautify::orig_indent()

Usage:
	$indent_str = $obj_ref->orig_indent();  # To retrieve the current value
        or
    $obj_ref->orig_indent("\t"); # To set a new value
Purpose:

Sets or gets the original value for the indent incrementer. NB: Beware of setting this.

Returns:

($indent_str) if set.

HISTORY

See Changes file in distribution

TODO

  • Deal with already formatted or mis-formatted XML.

  • Along those lines... Seriously consider reformatting each element in the XML from the data variable returned with the callback function instead of trying to miraculously use the original string.

  • Take an array ref, FH, etc; in addition to the scalar ref as an arg to beautify().

  • Better documentation.

  • Replace static variables. (process started in ver 0.03)

  • See if the current state tracking can be replaced with context(), current_element(), in_element() functions from expat. (Related to above about statics)

AUTHOR

    Thomas Bolioli <Thomas_Bolioli@alumni.adelphi.edu>

COPYRIGHT

Copyright (c) 2001 Thomas Bolioli. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

  • Log::AndError

  • Log::AndError::Constants

  • XML::Parser::Expat

1 POD Error

The following errors were encountered while parsing the POD:

Around line 710:

=over without closing =back