#!/usr/bin/env perl # # schema-hddm: create a hddm template based on a xml schema # # Both templates and schemas are themselves well-formed xml documents, # so the transformation can be done automatically using XSLT tools. # This implementation uses Xalan from xml.apache.org to carry out the # transformation. Some result is passed through the XercesDOMParser # just to check for well-formed xml and improve the readability of the # of the template. # # Richard T. Jones # September 15, 2003 # ------------------ use XML::Xerces; sub Usage() { print <new(); $parser->setValidationScheme (0); $parser->setDoNamespaces (1); $parser->setCreateEntityReferenceNodes(1); $parser->setDoSchema (1); $ERROR_HANDLER = XML::Xerces::PerlErrorHandler->new(); $parser->setErrorHandler($ERROR_HANDLER); eval {$parser->parse ($tmpxml)}; 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); unlink $tmpxml; exit 0;