76
|
1 package test;
|
|
2
|
|
3 import java.io.IOException;
|
|
4 import java.io.StringReader;
|
|
5
|
|
6 import javax.xml.parsers.ParserConfigurationException;
|
|
7 import javax.xml.parsers.SAXParser;
|
|
8 import javax.xml.parsers.SAXParserFactory;
|
|
9
|
|
10 import org.xml.sax.Attributes;
|
|
11 import org.xml.sax.InputSource;
|
|
12 import org.xml.sax.SAXException;
|
|
13 import org.xml.sax.helpers.DefaultHandler;
|
|
14
|
|
15 import rep.Editor;
|
|
16 import rep.Session;
|
|
17 import rep.SessionList;
|
|
18
|
|
19 public class SessionXMLParser extends DefaultHandler{
|
|
20
|
|
21 private SessionList sessionlist;
|
|
22 private Editor editor;
|
|
23
|
|
24 public void startDocument() {
|
|
25 System.out.println("Start Document.");
|
|
26 }
|
|
27
|
|
28 public void startElement(String uri, String localName, String qName, Attributes attributes){
|
|
29
|
|
30 }
|
|
31
|
|
32
|
|
33 public static void main(String[] args) {
|
|
34 String string = null;
|
|
35 if(args.length > 0) {
|
|
36 string = args[0];
|
|
37 }
|
|
38 try {
|
|
39 SAXParserFactory spfactory = SAXParserFactory.newInstance();
|
|
40 SAXParser parser = spfactory.newSAXParser();
|
|
41 InputSource source = new InputSource(new StringReader(string));
|
|
42 parser.parse(source, new SessionXMLParser());
|
|
43 } catch (IOException e) {
|
|
44 // TODO Auto-generated catch block
|
|
45 e.printStackTrace();
|
|
46 } catch (ParserConfigurationException e) {
|
|
47 // TODO Auto-generated catch block
|
|
48 e.printStackTrace();
|
|
49 } catch (SAXException e) {
|
|
50 // TODO Auto-generated catch block
|
|
51 e.printStackTrace();
|
|
52 }
|
|
53 }
|
|
54
|
|
55 }
|