XML::DocStats 0.01 review
DownloadXML::DocStats is a Perl module to produce a simple analysis of an XML document. SYNOPSIS Analyze the xml document on STDIN, the
|
|
XML::DocStats is a Perl module to produce a simple analysis of an XML document.
SYNOPSIS
Analyze the xml document on STDIN, the STDOUT output format is html:
use XML::DocStats;
my $parse = XML::DocStats->new;
$parse->analyze;
Analyze in-memory xml document:
use XML::DocStats;
my ($xmldata) = @_;
my $parse = XML::DocStats->new(xmlsource=>{String => $xmldata},
BYTES => length($xmldata));
$parse->analyze;
Analyze xml document IO stream, the output format is plain text:
use XML::DocStats;
use IO::File;
my $xmlsource = IO::File->new("< document.xml");
my $parse = XML::DocStats->new(xmlsource=>{ByteStream => $xmlsource});
$parse->format('text');
$parse->analyze;
XML::DocStats parses an xml document using a SAX handler built using Ken MacLeod's XML::Parser::PerlSAX. It produces a listing indented to show the element heirarchy, and collects counts of various xml components along the way. A summary of the counts is produced following the conclusion of the parse. This is useful to visualize the structure and content of an XML document.
The output listing is either in plain text or html.
Each xml thingy is color-coded in the html output for easy reading:
purple denotes elements.
blue denotes text (character data). The text itself is black.
olive denotes attributes and attribute valuesin elements, XML-DCL, DOCTYPE, and PIs.
fuchsia denotes entity references. The name of the entity is in black. fuchsia is also used to denote the root element, and to mark the start and finish of the parse, as well as to label the statistices at the end.
teal denotes the XML declaration.
navy denotes the DOCTYPE declaration.
maroon denotes PIs (processing instructions).
green denotes comments. The text of the comment is black.
red denotes error messages should the xml fail to be well-formed.
Requirements:
Perl
XML::DocStats 0.01 keywords