1
2
3
4
5
6
7
8 package org.dom4j.io;
9
10 import org.dom4j.DocumentFactory;
11
12 import org.xml.sax.SAXException;
13 import org.xml.sax.XMLReader;
14
15 /***
16 * The SAXModifier parses, updates and writes an XML document. <br>
17 * The input that is parsed is directly written to the specified output, unless
18 * the current xml element has an associated ElementHandler. <br>
19 * The {@link org.dom4j.ElementHandler}objects make it possible to update the
20 * document on the fly, without having read tje complete document.
21 *
22 * @author Wonne Keysers (Realsoftware.be)
23 *
24 * @see org.dom4j.io.SAXReader
25 * @see org.dom4j.io.XMLWriters
26 */
27 class SAXModifyReader extends SAXReader {
28 private XMLWriter xmlWriter;
29
30 private boolean pruneElements;
31
32 public SAXModifyReader() {
33 }
34
35 public SAXModifyReader(boolean validating) {
36 super(validating);
37 }
38
39 public SAXModifyReader(DocumentFactory factory) {
40 super(factory);
41 }
42
43 public SAXModifyReader(DocumentFactory factory, boolean validating) {
44 super(factory, validating);
45 }
46
47 public SAXModifyReader(XMLReader xmlReader) {
48 super(xmlReader);
49 }
50
51 public SAXModifyReader(XMLReader xmlReader, boolean validating) {
52 super(xmlReader, validating);
53 }
54
55 public SAXModifyReader(String xmlReaderClassName) throws SAXException {
56 super(xmlReaderClassName);
57 }
58
59 public SAXModifyReader(String xmlReaderClassName, boolean validating)
60 throws SAXException {
61 super(xmlReaderClassName, validating);
62 }
63
64 public void setXMLWriter(XMLWriter writer) {
65 this.xmlWriter = writer;
66 }
67
68 public boolean isPruneElements() {
69 return pruneElements;
70 }
71
72 public void setPruneElements(boolean pruneElements) {
73 this.pruneElements = pruneElements;
74 }
75
76 protected SAXContentHandler createContentHandler(XMLReader reader) {
77 SAXModifyContentHandler handler = new SAXModifyContentHandler(
78 getDocumentFactory(), getDispatchHandler());
79
80 handler.setXMLWriter(xmlWriter);
81
82 return handler;
83 }
84
85 protected XMLWriter getXMLWriter() {
86 return this.xmlWriter;
87 }
88 }
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125