rlm@10
|
1 /**
|
rlm@10
|
2 * Copyright (c) Rich Hickey. All rights reserved.
|
rlm@10
|
3 * The use and distribution terms for this software are covered by the
|
rlm@10
|
4 * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
rlm@10
|
5 * which can be found in the file epl-v10.html at the root of this distribution.
|
rlm@10
|
6 * By using this software in any fashion, you are agreeing to be bound by
|
rlm@10
|
7 * the terms of this license.
|
rlm@10
|
8 * You must not remove this notice, or any other, from this software.
|
rlm@10
|
9 **/
|
rlm@10
|
10
|
rlm@10
|
11 /* rich Dec 17, 2007 */
|
rlm@10
|
12
|
rlm@10
|
13 package clojure.lang;
|
rlm@10
|
14
|
rlm@10
|
15 import org.xml.sax.Attributes;
|
rlm@10
|
16 import org.xml.sax.ContentHandler;
|
rlm@10
|
17 import org.xml.sax.Locator;
|
rlm@10
|
18 import org.xml.sax.SAXException;
|
rlm@10
|
19 import org.xml.sax.helpers.DefaultHandler;
|
rlm@10
|
20
|
rlm@10
|
21 public class XMLHandler extends DefaultHandler{
|
rlm@10
|
22 ContentHandler h;
|
rlm@10
|
23
|
rlm@10
|
24
|
rlm@10
|
25 public XMLHandler(ContentHandler h){
|
rlm@10
|
26 this.h = h;
|
rlm@10
|
27 }
|
rlm@10
|
28
|
rlm@10
|
29 public void setDocumentLocator(Locator locator){
|
rlm@10
|
30 h.setDocumentLocator(locator);
|
rlm@10
|
31 }
|
rlm@10
|
32
|
rlm@10
|
33 public void startDocument() throws SAXException{
|
rlm@10
|
34 h.startDocument();
|
rlm@10
|
35 }
|
rlm@10
|
36
|
rlm@10
|
37 public void endDocument() throws SAXException{
|
rlm@10
|
38 h.endDocument();
|
rlm@10
|
39 }
|
rlm@10
|
40
|
rlm@10
|
41 public void startPrefixMapping(String prefix, String uri) throws SAXException{
|
rlm@10
|
42 h.startPrefixMapping(prefix, uri);
|
rlm@10
|
43 }
|
rlm@10
|
44
|
rlm@10
|
45 public void endPrefixMapping(String prefix) throws SAXException{
|
rlm@10
|
46 h.endPrefixMapping(prefix);
|
rlm@10
|
47 }
|
rlm@10
|
48
|
rlm@10
|
49 public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException{
|
rlm@10
|
50 h.startElement(uri, localName, qName, atts);
|
rlm@10
|
51 }
|
rlm@10
|
52
|
rlm@10
|
53 public void endElement(String uri, String localName, String qName) throws SAXException{
|
rlm@10
|
54 h.endElement(uri, localName, qName);
|
rlm@10
|
55 }
|
rlm@10
|
56
|
rlm@10
|
57 public void characters(char ch[], int start, int length) throws SAXException{
|
rlm@10
|
58 h.characters(ch, start, length);
|
rlm@10
|
59 }
|
rlm@10
|
60
|
rlm@10
|
61 public void ignorableWhitespace(char ch[], int start, int length) throws SAXException{
|
rlm@10
|
62 h.ignorableWhitespace(ch, start, length);
|
rlm@10
|
63 }
|
rlm@10
|
64
|
rlm@10
|
65 public void processingInstruction(String target, String data) throws SAXException{
|
rlm@10
|
66 h.processingInstruction(target, data);
|
rlm@10
|
67 }
|
rlm@10
|
68
|
rlm@10
|
69 public void skippedEntity(String name) throws SAXException{
|
rlm@10
|
70 h.skippedEntity(name);
|
rlm@10
|
71 }
|
rlm@10
|
72
|
rlm@10
|
73 /*
|
rlm@10
|
74 public static void main(String[] args){
|
rlm@10
|
75 try
|
rlm@10
|
76 {
|
rlm@10
|
77 ContentHandler dummy = new DefaultHandler();
|
rlm@10
|
78 SAXParserFactory f = SAXParserFactory.newInstance();
|
rlm@10
|
79 //f.setNamespaceAware(true);
|
rlm@10
|
80 SAXParser p = f.newSAXParser();
|
rlm@10
|
81 p.parse("http://arstechnica.com/journals.rssx",new XMLHandler(dummy));
|
rlm@10
|
82 }
|
rlm@10
|
83 catch(Exception e)
|
rlm@10
|
84 {
|
rlm@10
|
85 e.printStackTrace();
|
rlm@10
|
86 }
|
rlm@10
|
87 }
|
rlm@10
|
88 //*/
|
rlm@10
|
89 }
|