01: package net.sf.saxon.pull;
02:
03: import net.sf.saxon.trans.XPathException;
04:
05: /**
06: * This is a filter that can be added to a pull pipeline to remove START_DOCUMENT and END_DOCUMENT
07: * events.
08: */
09: public class DocumentEventIgnorer extends PullFilter {
10:
11: public DocumentEventIgnorer(PullProvider base) {
12: super (base);
13: }
14:
15: /**
16: * Get the next event.
17: * <p/>
18: * <p>Note that a subclass that overrides this method is responsible for ensuring
19: * that current() works properly. This can be achieved by setting the field
20: * currentEvent to the event returned by any call on next().</p>
21: *
22: * @return an integer code indicating the type of event. The code
23: * {@link #END_OF_INPUT} is returned at the end of the sequence.
24: */
25:
26: public int next() throws XPathException {
27: do {
28: currentEvent = super .next();
29: } while (currentEvent == START_DOCUMENT
30: || currentEvent == END_DOCUMENT);
31: return currentEvent;
32: }
33: }
34:
35: //
36: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
37: // you may not use this file except in compliance with the License. You may obtain a copy of the
38: // License at http://www.mozilla.org/MPL/
39: //
40: // Software distributed under the License is distributed on an "AS IS" basis,
41: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
42: // See the License for the specific language governing rights and limitations under the License.
43: //
44: // The Original Code is: all this file.
45: //
46: // The Initial Developer of the Original Code is Michael H. Kay.
47: //
48: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
49: //
50: // Contributor(s): none.
51: //
|