6 |
|
import java.util.ArrayList; |
7 |
|
|
8 |
|
import org.xml.sax.*; |
9 |
+ |
import org.xml.sax.helpers.*; |
10 |
|
import javax.xml.parsers.SAXParserFactory; |
11 |
|
import javax.xml.parsers.ParserConfigurationException; |
12 |
|
import javax.xml.parsers.SAXParser; |
17 |
|
* @author $Author$ |
18 |
|
* @version $Id$ |
19 |
|
*/ |
20 |
< |
public class XMLPacketMaker extends HandlerBase { |
20 |
> |
public class XMLPacketMaker extends DefaultHandler { |
21 |
|
|
22 |
|
//---FINAL ATTRIBUTES--- |
23 |
|
|
25 |
|
* The current CVS revision of this class |
26 |
|
*/ |
27 |
|
public final String REVISION = "$Revision$"; |
28 |
< |
|
28 |
> |
|
29 |
|
//---STATIC METHODS--- |
30 |
|
|
31 |
|
//---CONSTRUCTORS--- |
39 |
|
_xml = xml; |
40 |
|
} |
41 |
|
|
42 |
+ |
/** |
43 |
+ |
* A static reference to the system saxParser factory |
44 |
+ |
*/ |
45 |
+ |
private static SAXParserFactory factory = SAXParserFactory.newInstance(); |
46 |
+ |
|
47 |
+ |
|
48 |
|
//---PUBLIC METHODS--- |
49 |
|
|
50 |
|
/** |
58 |
|
|
59 |
|
// Create the XMLPacket to store values in. |
60 |
|
XMLPacket packet = new XMLPacket(); |
61 |
< |
|
55 |
< |
// Use the default (non-validating) parser |
56 |
< |
SAXParserFactory factory = SAXParserFactory.newInstance(); |
61 |
> |
|
62 |
|
try { |
63 |
|
// Parse the input |
64 |
|
InputSource inputSource = new InputSource(new StringReader(_xml)); |
65 |
|
SAXParser saxParser = factory.newSAXParser(); |
66 |
+ |
|
67 |
|
saxParser.parse(inputSource, new XMLStringParser(packet)); |
68 |
|
} |
69 |
|
catch (Exception e) { |