01: /*
02: * Copyright 2007-2008 Andy Clark
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package sample;
18:
19: import org.cyberneko.html.HTMLConfiguration;
20: import org.cyberneko.html.filters.DefaultFilter;
21:
22: import org.apache.xerces.xni.Augmentations;
23: import org.apache.xerces.xni.QName;
24: import org.apache.xerces.xni.XMLAttributes;
25: import org.apache.xerces.xni.parser.XMLParserConfiguration;
26: import org.apache.xerces.xni.parser.XMLInputSource;
27:
28: /**
29: * This class demonstrates that the NekoHTML parser can be used with
30: * a minimal set of Xerces2 classes if you program directory the the
31: * Xerces Native Interface (XNI).
32: *
33: * @author Andy Clark
34: */
35: public class Minimal extends DefaultFilter {
36:
37: //
38: // MAIN
39: //
40:
41: public static void main(String[] argv) throws Exception {
42: XMLParserConfiguration parser = new HTMLConfiguration();
43: parser.setDocumentHandler(new Minimal());
44: for (int i = 0; i < argv.length; i++) {
45: XMLInputSource source = new XMLInputSource(null, argv[i],
46: null);
47: parser.parse(source);
48: }
49: } // main(String[])
50:
51: //
52: // XMLDocumentHandler methods
53: //
54:
55: public void startElement(QName element, XMLAttributes attrs,
56: Augmentations augs) {
57: System.out.println("(" + element.rawname);
58: }
59:
60: public void endElement(QName element, Augmentations augs) {
61: System.out.println(")" + element.rawname);
62: }
63:
64: } // class Minimal
|