FileDocCategorySizeDatePackage
XMLHelper.javaAPI DocHibernate 3.2.52600Thu Nov 10 08:59:00 GMT 2005org.hibernate.util

XMLHelper

public final class XMLHelper extends Object
Small helper class that lazy loads DOM and SAX reader and keep them for fast use afterwards.

Fields Summary
private static final Log
log
public static final EntityResolver
DEFAULT_DTD_RESOLVER
private org.dom4j.io.DOMReader
domReader
private org.dom4j.io.SAXReader
saxReader
Constructors Summary
Methods Summary
public org.dom4j.io.DOMReadercreateDOMReader()
Create a dom4j DOMReader

		if (domReader==null) domReader = new DOMReader();
		return domReader;
	
public org.dom4j.io.SAXReadercreateSAXReader(java.lang.String file, java.util.List errorsList, org.xml.sax.EntityResolver entityResolver)
Create a dom4j SAXReader which will append all validation errors to errorList


	            	 
	        
		if (saxReader==null) saxReader = new SAXReader();
		saxReader.setEntityResolver(entityResolver);
		saxReader.setErrorHandler( new ErrorLogger(file, errorsList) );
		saxReader.setMergeAdjacentText(true);
		saxReader.setValidation(true);
		return saxReader;
	
public static voiddump(org.dom4j.Element element)

		try {
			// try to "pretty print" it
			OutputFormat outformat = OutputFormat.createPrettyPrint();
			XMLWriter writer = new XMLWriter( System.out, outformat );
			writer.write( element );
			writer.flush();
			System.out.println( "" );
		}
		catch( Throwable t ) {
			// otherwise, just dump it
			System.out.println( element.asXML() );
		}

	
public static org.dom4j.ElementgenerateDom4jElement(java.lang.String elementName)

		return DocumentFactory.getInstance().createElement( elementName );