1 31 32 package org.opencms.xml; 33 34 import org.opencms.util.CmsStringUtil; 35 36 import org.dom4j.DocumentHelper; 37 import org.dom4j.Element; 38 import org.dom4j.util.XMLErrorHandler; 39 import org.xml.sax.SAXParseException ; 40 41 50 public class CmsXmlValidationErrorHandler extends XMLErrorHandler { 51 52 53 private Element m_warnings; 54 55 58 public CmsXmlValidationErrorHandler() { 59 60 super(); 61 m_warnings = DocumentHelper.createElement("warnings"); 62 } 63 64 67 public void error(SAXParseException e) { 68 69 String message = e.getMessage(); 70 if (CmsStringUtil.isNotEmpty(message)) { 71 72 if (message.startsWith("sch-props-correct.2")) { 73 warning(e); 77 return; 78 } 79 } 80 81 super.error(e); 82 } 83 84 89 public Element getWarnings() { 90 91 return m_warnings; 92 } 93 94 97 public void warning(SAXParseException e) { 98 99 Element element = m_warnings.addElement(WARNING_QNAME); 100 addException(element, e); 101 } 102 } | Popular Tags |