1 23 24 package org.enhydra.xml.xmlc.html.parsers; 25 26 import org.enhydra.xml.io.ErrorReporter; 27 import org.enhydra.xml.xmlc.XMLCException; 28 import org.enhydra.xml.xmlc.dom.XMLCDocument; 29 import org.enhydra.xml.xmlc.metadata.MetaData; 30 import org.enhydra.xml.xmlc.metadata.Parser; 31 import org.enhydra.xml.xmlc.metadata.ParserType; 32 import org.enhydra.xml.xmlc.parsers.XMLCParser; 33 34 39 abstract public class HTMLParserBase implements XMLCParser { 40 43 private static final String [] PCDATA_ELEMENTS = { 44 "A", "ABBR", "ACRONYM", "ADDRESS", "B", "BDO", "BIG", "BUTTON", 46 "CAPTION", "CITE", "CODE", "DD", "DEL", "DFN", "DIV", "DT", "EM", 47 "FIELDSET", "H1", "H2", "H3", "H4", "H5", "H6", "I", "INS", "KBD", 48 "LABEL", "LEGEND", "LI", "OBJECT", "OPTION", "P", "PRE", "Q", "SAMP", 49 "SCRIPT", "SMALL", "SPAN", "STRONG", "STYLE", "SUB", "SUP", "TD", 50 "TEXTAREA", "TH", "TITLE", "TT", "VAR", 51 52 "APPLET", "BLOCKQUOTE", "BODY", "CENTER", "FONT", "FORM", "IFRAME", 54 "NOSCRIPT", "S", "STRIKE", "U", 55 56 "NOFRAMES" 58 }; 59 60 63 protected void validateConf(ParserType parserType, 64 MetaData metaData) throws XMLCException { 65 Parser parser = metaData.getParser(); 66 67 Boolean validate = parser.getValidate(); 68 if ((validate != null) && (!validate.booleanValue())) { 69 throw new XMLCException(parserType.getName() + " parser can't disable document validation"); 70 } 71 72 if (parser.getXCatalogURLs().length != 0) { 73 throw new XMLCException("XCatalog not support for HTML"); 74 } 75 } 76 77 80 protected void handleParseErrors(ErrorReporter reporter) throws XMLCException { 81 throw new XMLCException("" + reporter.getErrorCnt() 82 + " parse " 83 + ((reporter.getErrorCnt() > 1) ? "errors" : "error") 84 + " in HTML file"); 85 } 86 87 91 protected void addPCDataContentElements(XMLCDocument xmlcDocument) { 92 for (int idx = 0; idx < PCDATA_ELEMENTS.length; idx++) { 93 xmlcDocument.addPCDataContentElement(PCDATA_ELEMENTS[idx]); 94 } 95 } 96 } 97 | Popular Tags |