1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| package org.apache.xindice.xml.jaxp; |
21 |
| |
22 |
| import org.apache.commons.logging.Log; |
23 |
| import org.apache.commons.logging.LogFactory; |
24 |
| import org.apache.xindice.xml.dom.DOMImplementationImpl; |
25 |
| import org.apache.xindice.xml.dom.DOMParser; |
26 |
| import org.apache.xindice.xml.dom.DocumentImpl; |
27 |
| |
28 |
| import org.w3c.dom.DOMImplementation; |
29 |
| import org.w3c.dom.Document; |
30 |
| import org.xml.sax.EntityResolver; |
31 |
| import org.xml.sax.ErrorHandler; |
32 |
| import org.xml.sax.InputSource; |
33 |
| import org.xml.sax.SAXException; |
34 |
| |
35 |
| import javax.xml.parsers.DocumentBuilder; |
36 |
| import javax.xml.parsers.ParserConfigurationException; |
37 |
| import java.io.IOException; |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
| |
44 |
| public class DocumentBuilderImpl extends DocumentBuilder { |
45 |
| |
46 |
| private static final Log log = LogFactory.getLog(DocumentBuilderImpl.class); |
47 |
| |
48 |
| private DOMParser parser = null; |
49 |
| private ErrorHandler errors = null; |
50 |
| private EntityResolver entities = null; |
51 |
| |
52 |
| |
53 |
0
| protected DocumentBuilderImpl() throws ParserConfigurationException {
|
54 |
0
| try {
|
55 |
0
| parser = new DOMParser();
|
56 |
| } catch (Exception e) { |
57 |
0
| if (log.isWarnEnabled()) {
|
58 |
0
| log.warn("ignored exception", e);
|
59 |
| } |
60 |
| } |
61 |
| } |
62 |
| |
63 |
0
| public DOMImplementation getDOMImplementation() {
|
64 |
0
| return DOMImplementationImpl.getInstance();
|
65 |
| } |
66 |
| |
67 |
0
| public boolean isNamespaceAware() {
|
68 |
0
| return true;
|
69 |
| } |
70 |
| |
71 |
0
| public boolean isValidating() {
|
72 |
0
| return false;
|
73 |
| } |
74 |
| |
75 |
0
| public void setErrorHandler(ErrorHandler errors) {
|
76 |
0
| this.errors = errors;
|
77 |
| } |
78 |
| |
79 |
0
| public void setEntityResolver(EntityResolver entities) {
|
80 |
0
| this.entities = entities;
|
81 |
| } |
82 |
| |
83 |
0
| public Document parse(InputSource source) throws SAXException, IOException, IllegalArgumentException {
|
84 |
0
| if (source == null) {
|
85 |
0
| throw new IllegalArgumentException();
|
86 |
| } else { |
87 |
0
| parser.parse(source);
|
88 |
| } |
89 |
0
| return parser.getDocument();
|
90 |
| } |
91 |
| |
92 |
0
| public Document newDocument() {
|
93 |
0
| return new DocumentImpl();
|
94 |
| } |
95 |
| } |