1 /*
2 * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved.
3 *
4 * This software is open source.
5 * See the bottom of this file for the licence.
6 *
7 * $Id: SAXModifyReader.java,v 1.1 2004/08/02 18:44:07 maartenc Exp $
8 */
9
10 package org.dom4j.io;
11
12 import org.dom4j.DocumentFactory;
13 import org.xml.sax.SAXException;
14 import org.xml.sax.XMLReader;
15
16 /***
17 * The SAXModifier parses, updates and writes an XML document.<br>
18 *
19 * The input that is parsed is directly written to the specified output, unless the current xml element has an
20 * associated ElementHandler.<br>
21 * The {@link org.dom4j.ElementHandler} objects make it possible to update the document on the fly,
22 * without having read tje complete document.
23 *
24 * @see org.dom4j.io.SAXReader
25 * @see org.dom4j.io.XMLWriters
26 * @author Wonne Keysers (Realsoftware.be)
27 */
28 class SAXModifyReader extends SAXReader {
29
30 private XMLWriter xmlWriter;
31 private boolean pruneElements;
32
33 public SAXModifyReader() {
34 }
35
36 public SAXModifyReader(boolean validating) {
37 super(validating);
38 }
39
40 public SAXModifyReader(DocumentFactory factory) {
41 super(factory);
42 }
43
44 public SAXModifyReader(DocumentFactory factory, boolean validating) {
45 super(factory, validating);
46 }
47
48 public SAXModifyReader(XMLReader xmlReader) {
49 super(xmlReader);
50 }
51
52 public SAXModifyReader(XMLReader xmlReader, boolean validating) {
53 super(xmlReader, validating);
54 }
55
56 public SAXModifyReader(String xmlReaderClassName) throws SAXException {
57 super(xmlReaderClassName);
58 }
59
60 public SAXModifyReader(String xmlReaderClassName, boolean validating) throws SAXException {
61 super(xmlReaderClassName, validating);
62 }
63
64 public void setXMLWriter(XMLWriter xmlWriter) {
65 this.xmlWriter = xmlWriter;
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(getDocumentFactory(), getDispatchHandler());
78
79 handler.setXMLWriter(xmlWriter);
80
81 return handler;
82 }
83
84 protected XMLWriter getXMLWriter() {
85 return this.xmlWriter;
86 }
87
88 }
89
90
91
92
93 /*
94 * Redistribution and use of this software and associated documentation
95 * ("Software"), with or without modification, are permitted provided
96 * that the following conditions are met:
97 *
98 * 1. Redistributions of source code must retain copyright
99 * statements and notices. Redistributions must also contain a
100 * copy of this document.
101 *
102 * 2. Redistributions in binary form must reproduce the
103 * above copyright notice, this list of conditions and the
104 * following disclaimer in the documentation and/or other
105 * materials provided with the distribution.
106 *
107 * 3. The name "DOM4J" must not be used to endorse or promote
108 * products derived from this Software without prior written
109 * permission of MetaStuff, Ltd. For written permission,
110 * please contact dom4j-info@metastuff.com.
111 *
112 * 4. Products derived from this Software may not be called "DOM4J"
113 * nor may "DOM4J" appear in their names without prior written
114 * permission of MetaStuff, Ltd. DOM4J is a registered
115 * trademark of MetaStuff, Ltd.
116 *
117 * 5. Due credit should be given to the DOM4J Project -
118 * http://www.dom4j.org
119 *
120 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
121 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
122 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
123 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
124 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
125 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
126 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
127 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
128 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
129 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
130 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
131 * OF THE POSSIBILITY OF SUCH DAMAGE.
132 *
133 * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved.
134 *
135 * $Id: SAXModifyReader.java,v 1.1 2004/08/02 18:44:07 maartenc Exp $
136 */