01: package net.xoetrope.xml.nanoxml;
02:
03: import java.io.Reader;
04:
05: import net.n3.nanoxml.IXMLElement;
06: import net.n3.nanoxml.IXMLParser;
07: import net.n3.nanoxml.IXMLReader;
08: import net.n3.nanoxml.NonValidator;
09: import net.n3.nanoxml.StdXMLBuilder;
10: import net.n3.nanoxml.StdXMLParser;
11: import net.n3.nanoxml.StdXMLReader;
12: import net.xoetrope.debug.DebugLogger;
13:
14: import net.xoetrope.xml.XmlElement;
15: import net.xoetrope.xui.build.BuildProperties;
16: import net.xoetrope.xml.XmlParser;
17:
18: /**
19: * A wrapper for the NanoXml Parser
20: * <p> Copyright (c) Xoetrope Ltd., 2002-2003</p>
21: * <p> $Revision: 1.2 $</p>
22: * <p> License: see License.txt</p>
23: */
24: public class NanoXmlParser implements XmlParser {
25: public NanoXmlParser() {
26: }
27:
28: public XmlElement createXmlElement(String name) {
29: return new NanoXmlElement(name);
30: }
31:
32: public XmlElement parse(Reader input, String schemaSource) {
33: return parse(input);
34: }
35:
36: public XmlElement parse(Reader input) {
37: IXMLElement xml = null;
38: try {
39: IXMLParser parser = new StdXMLParser();
40: parser.setBuilder(new StdXMLBuilder());
41: parser.setValidator(new NonValidator());
42:
43: IXMLReader reader = new StdXMLReader(input);
44: parser.setReader(reader);
45: xml = (IXMLElement) parser.parse();
46: } catch (Exception ex) {
47: if (BuildProperties.DEBUG)
48: DebugLogger.logError("Unable to read/parse the xml: "
49: + ex.getMessage());
50: return null;
51: }
52: return new NanoXmlElement(xml);
53: }
54: }
|