1 23 24 package org.enhydra.xml.xmlc.html.parsers.swing; 25 26 import java.io.IOException ; 27 import java.io.Reader ; 28 29 import org.enhydra.xml.io.ErrorReporter; 30 import org.enhydra.xml.xmlc.XMLCException; 31 import org.enhydra.xml.xmlc.dom.XMLCDocument; 32 import org.enhydra.xml.xmlc.dom.XMLCDomFactory; 33 import org.enhydra.xml.xmlc.html.parsers.HTMLDocBuilder; 34 import org.enhydra.xml.xmlc.html.parsers.HTMLParserBase; 35 import org.enhydra.xml.xmlc.metadata.MetaData; 36 import org.enhydra.xml.xmlc.metadata.ParserType; 37 import org.enhydra.xml.xmlc.misc.LineNumberMap; 38 import org.enhydra.xml.xmlc.misc.LineNumberMapReader; 39 import org.enhydra.xml.xmlc.parsers.ParseTracer; 40 import org.enhydra.xml.xmlc.parsers.XMLCParser; 41 import org.xml.sax.InputSource ; 42 43 44 46 47 50 public class SwingHTMLParser extends HTMLParserBase implements XMLCParser { 51 54 public XMLCDocument parse(InputSource input, 55 LineNumberMap lineNumberMap, 56 XMLCDomFactory domFactory, 57 MetaData metaData, 58 ErrorReporter errorReporter, 59 ParseTracer tracer) 60 throws IOException , XMLCException { 61 HTMLDocBuilder docBuilder = new HTMLDocBuilder(domFactory, 62 input); 63 validateConf(ParserType.SWING, metaData); 64 65 Reader reader = null; 68 if (lineNumberMap == null) { 69 LineNumberMapReader mapReader = new LineNumberMapReader(input); 70 reader = mapReader; 71 lineNumberMap = mapReader.getLineNumberMap(); 72 } else { 73 reader = input.getCharacterStream(); 74 } 75 76 SwingParser parser = new SwingParser(); 77 parser.parse(docBuilder, errorReporter, tracer, reader, lineNumberMap); 78 if (errorReporter.getErrorCnt() != 0) { 79 handleParseErrors(errorReporter); 80 } 81 82 addPCDataContentElements(docBuilder.getXMLCDocument()); 83 return docBuilder.getXMLCDocument(); 84 } 85 } 86 | Popular Tags |