#!/usr/bin/env perl # # xml-xml: read any well-formed xml document and prints it to stdout # in a easy-to-read form, resolving all external entities. # # If the xml can be validated against a dtd or schema this will be done. # It also has the feature of using a standard order for all parameters # so that two equivalent xml documents will come out exactly alike even # if their form on input looks quite different. # # Richard T. Jones # September 15, 2003 # ------------------ use XML::Xerces; sub Usage() { print <new(); $parser->setValidationScheme (2); $parser->setDoNamespaces (1); $parser->setCreateEntityReferenceNodes(0); $parser->setDoSchema (1); $ERROR_HANDLER = XML::Xerces::PerlErrorHandler->new(); $parser->setErrorHandler($ERROR_HANDLER); eval {$parser->parse ($infile)}; XML::Xerces::error($@) if ($@); $doc = $parser->getDocument(); $impl = XML::Xerces::DOMImplementationRegistry::getDOMImplementation('LS'); $writer = $impl->createDOMWriter(); if ($writer->canSetFeature('format-pretty-print',1)) { $writer->setFeature('format-pretty-print',1); } $target = XML::Xerces::StdOutFormatTarget->new(); $writer->writeNode($target,$doc); exit 0;