FileDocCategorySizeDatePackage
XmlForm.javaAPI DocExample1769Sun Feb 08 21:34:12 GMT 2004None

XmlForm

public class XmlForm extends Object
Convert a simple XML file to text.
author
Ian Darwin, http://www.darwinsys.com/
version
$Id: XmlForm.java,v 1.19 2004/02/09 03:34:11 ian Exp $

Fields Summary
protected Reader
is
protected String
fileName
protected static PrintStream
msg
Constructors Summary
public XmlForm(String fn)
Construct a converter given an input filename


	        
	   
		fileName = fn;
	
Methods Summary
public voidconvert(boolean verbose)
Convert the file

		try {
			if (verbose)
				System.err.println(">>>Parsing " + fileName + "...");
			// Make the document a URL so relative DTD works.
			//String uri = "file:" + new File(fileName).getAbsolutePath();
			InputStream uri = getClass().getResourceAsStream(fileName);
			DocumentBuilderFactory factory =
				DocumentBuilderFactory.newInstance();
			DocumentBuilder builder = factory.newDocumentBuilder();
			Document doc = builder.parse( uri );
			if (verbose)
				System.err.println(">>>Walking " + fileName + "...");
			XmlFormWalker c = new GenMIF(doc, msg);
			c.convertAll();

		} catch (Exception ex) {
			System.err.println("+================================+");
			System.err.println("|         *Parse Error*          |");
			System.err.println("+================================+");
			System.err.println(ex.getClass());
			System.err.println(ex.getMessage());
			System.err.println("+================================+");
		}
		if (verbose)
			System.err.println(">>>Done " + fileName + "...");
	
public static voidmain(java.lang.String[] av)

		if (av.length == 0) {
			System.err.println("Usage: XmlForm file");
			return;
		}
		for (int i=0; i<av.length; i++) {
			String name = av[i];
			new XmlForm(name).convert(true);
		}
		msg.close();