Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

xmlpretty(1p) [debian man page]

XMLPRETTY(1p)						User Contributed Perl Documentation					     XMLPRETTY(1p)

NAME
xmlpretty - XML pretty printer SYNOPSIS
xmlpretty [--options] [filename] DESCRIPTION
xmlpretty is the commandline interface to XML::Handler::YAWriter, acting as a tool to add and remove pretty printing to XML files. xmlpretty has several methods to add human readablitiy. If you want to add readablity without adding so-called ignorable whitespace, use it in the following way : $ xmlpretty --AddHiddenNewline --AddHiddenAttrTab --CatchEmptyElement uglyfile.xml > prettyfile.xml If you do not want to process the file further, but only want it human readable, add visible whitespace to the file as follows : $ xmlpretty --PrettyWhiteNewline --PrettyWhiteIndent --CatchEmptyElement uglyfile.xml > prettyfile.xml You may use YAWriter to clean whitespace from XML documents. This may work in 99% of the cases where you want to get rid of ignorable whitespace caused by the various forms of pretty printing. $ xmlpretty --NoWhiteSpace --NoComments --AddHiddenNewline --AddHiddenAttrTab --CatchEmptyElement prettyfile.xml > cleanfile.xml Options Options are given in a gnu like --option idiom. AddHiddenNewline boolean Add hidden newline before ">" AddHiddenAttrTab boolean Add hidden tabulation for attributes CatchEmptyElement boolean Catch empty Elements, apply "/>" compression CatchWhiteSpace boolean Catch whitespace with comments 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. NoComments boolean Supress Comments NoDTD boolean Supress DTD NoPI boolean Supress Processing Instructions NoProlog boolean Supress <?xml ... ?> Prolog NoWhiteSpace boolean Supress WhiteSpace to clean documents from prior pretty printing. PrettyWhiteIndent boolean Add visible indent before any eventstring PrettyWhiteNewline boolean Add visible newlines before any eventstring SAX1 boolean (not yet implemented) Output only SAX1 compilant eventstrings Bugs: Automatic recoding between 8bit and 16bit does not yet work correctly ! I have Perl-5.6 at home and here I can specify "use utf8;" in the right places to make recoding work. But I dislike saying "use 5.00555;" because many systems run 5.00503. AUTHOR
Michael Koehne, Kraehe@Copyleft.De Thanks "Derksen, Eduard (Enno), CSCIO" <enno@att.com> helped me with the Escape hash and gave quite a lot of useful comments. SEE ALSO
perl and XML::Parser::PerlSAX perl v5.10.1 2010-02-18 XMLPRETTY(1p)

Check Out this Related Man Page

XML::Filter::Reindent(3)				User Contributed Perl Documentation				  XML::Filter::Reindent(3)

NAME
XML::Filter::Reindent - Reformats whitespace for pretty printing XML SYNOPSIS
use XML::Handler::Composer; use XML::Filter::Reindent; my $composer = new XML::Handler::Composer (%OPTIONS); my $indent = new XML::Filter::Reindent (Handler => $composer, %OPTIONS); DESCRIPTION
XML::Filter::Reindent is a sub class of XML::Filter::DetectWS. XML::Filter::Reindent can be used as a PerlSAX filter to reformat an XML document before sending it to a PerlSAX handler that prints it (like XML::Handler::Composer.) Like XML::Filter::DetectWS, it detects ignorable whitespace and blocks of whitespace characters in certain places. It uses this information and information supplied by the user to determine where whitespace may be modified, deleted or inserted. Based on the indent settings, it then modifies, inserts and deletes characters and ignorable_whitespace events accordingly. This is just a first stab at the implementation. It may be buggy and may change completely! Constructor Options o Handler The PerlSAX handler (or filter) that will receive the PerlSAX events from this filter. o Tab (Default: one space) The number of spaces per indent level for elements etc. in document content. o Newline (Default: "x0A") The newline to use when re-indenting. The default is the internal newline used by XML::Parser, XML::DOM etc., and should be fine when used in combination with XML::Handler::Composer. $self->indent_children ($start_element_event) This method determines whether children of a certain element may be reformatted. The default implementation checks the PreserveWS parame- ter of the specified start_element event and returns 0 if it is set or MAYBE otherwise. The value MAYBE (2) indicates that further inves- tigation is needed, e.g. by examining the element contents. A value of 1 means yes, indent the child nodes, no further investigation is needed. NOTE: the PreserveWS parameter is set by the parent class, XML::Filter::DetectWS, when the element or one of its ancestors has the attribute xml:space="preserve". Override this method to tweak the behavior of this class. $self->indent_element ($start_element_event, $parent_says_indent) This method determines whether a certain element may be re-indented. The default implementation returns the value of the $par- ent_says_indent parameter, which was set to the value returned by indent_children for the parent element. In other words, the element will be re-indented if the parent element allows it. Override this method to tweak the behavior of this class. I'm not sure how useful this hook is. Please provide feedback! Current Implementation The current implementation puts all incoming Perl SAX events in a queue for further processing. When determining which nodes should be re-indented, it sometimes needs information from previous events, hence the use of the queue. The parameter (Compress => 1) is added to matching start_element and end_element events with no events in between This indicates to an XML printer that a compressed notation can be used, e.g <foo/>. If an element allows reformatting of its contents (xml:space="preserve" was not active and indent_children returned MAYBE), the element contents will be reformatted unless it only has one child node and that child is a regular text node (characters event.) In that case, the element will be printed as <foo>text contents</foo>. If you want element nodes with just one text child to be reindented as well, simply override indent_children to return 1 instead of MAYBE (2.) This behavior may be changed or extended in the future. CAVEATS
This code is highly experimental! It has not been tested well and the API may change. The code that detects blocks of whitespace at potential indent positions may need some work. AUTHOR
Send bug reports, hints, tips, suggestions to Enno Derksen at <enno@att.com>. perl v5.8.0 2000-02-16 XML::Filter::Reindent(3)
Man Page