1 package nl.mineleni.openls.parser;
2
3 import java.util.Stack;
4
5 import javax.xml.parsers.ParserConfigurationException;
6 import javax.xml.parsers.SAXParser;
7 import javax.xml.parsers.SAXParserFactory;
8
9 import nl.mineleni.openls.XmlNamespaceConstants;
10
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
13 import org.xml.sax.SAXException;
14 import org.xml.sax.helpers.DefaultHandler;
15
16
17
18
19
20
21
22 public abstract class AbstractOpenLSParser extends DefaultHandler {
23
24 private static final Logger LOGGER = LoggerFactory
25 .getLogger(AbstractOpenLSParser.class);
26
27
28 protected StringBuffer eValBuf;
29
30
31 protected SAXParser parser;
32
33
34 protected final Stack<XmlNamespaceConstants> objStack = new Stack<>();
35
36
37
38
39 public AbstractOpenLSParser() {
40 final SAXParserFactory factory = SAXParserFactory.newInstance();
41 factory.setValidating(false);
42 try {
43 this.parser = factory.newSAXParser();
44 } catch (final ParserConfigurationException | SAXException e) {
45 LOGGER.error("Configureren of maken van de saxparser is mislukt: ",
46 e);
47 }
48 }
49
50
51
52
53
54
55 @Override
56 public void characters(final char[] ch, final int start, final int length)
57 throws SAXException {
58 this.eValBuf.append(ch, start, length);
59 }
60
61 }