/* * (C) Copyright IBM Corp. 1999,2000,2001 All rights reserved. * * US Government Users Restricted Rights Use, duplication or * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. * * The program is provided "as is" without any warranty express or * implied, including the warranty of non-infringement and the implied * warranties of merchantibility and fitness for a particular purpose. * IBM will not be liable for any damages suffered by you as a result * of using the Program. In no event will IBM be liable for any * special, indirect or consequential damages or lost profits even if * IBM has been advised of the possibility of their occurrence. IBM * will not be liable for any third party claims against you. */ package domhash; import com.ibm.xml.sax.DigestFilter; import com.ibm.xml.sax.NamespaceAdapter; import com.ibm.xml.sax.StandardErrorHandler; import java.io.PrintWriter; import java.security.MessageDigest; import org.apache.xerces.parsers.SAXParser; /** * Prints MD5 digest value of the root element of specified XML document. * * @version $Id: SAXDigestTest.java,v 1.1 2001/04/19 02:56:56 kent Exp $ * @author TAMURA Kent <kent@trl.ibm.co.jp> */ public class SAXDigestTest { public static void main(String[] argv) throws Exception { String systemId = argv[0]; SAXParser saxp = new SAXParser(); NamespaceAdapter nsa = new NamespaceAdapter(saxp); DigestFilter digest = new DigestFilter(MessageDigest.getInstance("MD5")); digest.setNextDocumentHandler(new NSDocumentHandlerDebug()); nsa.setDocumentHandler(digest); nsa.setErrorHandler(new StandardErrorHandler()); System.err.println("Parse: "+systemId); nsa.parse(systemId); System.out.print("\nMD5 digest value of the root element: "); System.out.flush(); PrintWriter pw = new PrintWriter(System.out); DigestFilter.printByteArray(pw, digest.getDigest()); pw.close(); } }