--- projects/cms/source/util/uk/org/iscream/cms/util/XMLPacketMaker.java 2001/01/28 05:47:05 1.9 +++ projects/cms/source/util/uk/org/iscream/cms/util/XMLPacketMaker.java 2001/03/01 16:55:11 1.10 @@ -14,7 +14,7 @@ import javax.xml.parsers.SAXParser; * XMLPacketMaker - Creates an XMLPacket object. * * @author $Author: tdb $ - * @version $Id: XMLPacketMaker.java,v 1.9 2001/01/28 05:47:05 tdb Exp $ + * @version $Id: XMLPacketMaker.java,v 1.10 2001/03/01 16:55:11 tdb Exp $ */ public class XMLPacketMaker extends HandlerBase { @@ -23,7 +23,7 @@ public class XMLPacketMaker extends HandlerBase { /** * The current CVS revision of this class */ - public final String REVISION = "$Revision: 1.9 $"; + public final String REVISION = "$Revision: 1.10 $"; //---STATIC METHODS--- @@ -45,8 +45,9 @@ public class XMLPacketMaker extends HandlerBase { * class was constructed with. * * @return an XMLPacket representing the XML String given + * @throws InvalidXMLException if the XML cannot be parsed */ - public XMLPacket createXMLPacket() { + public XMLPacket createXMLPacket() throws InvalidXMLException { // Create the XMLPacket to store values in. XMLPacket packet = new XMLPacket(); @@ -54,17 +55,16 @@ public class XMLPacketMaker extends HandlerBase { // Use the default (non-validating) parser SAXParserFactory factory = SAXParserFactory.newInstance(); try { - // Parse the input InputSource inputSource = new InputSource(new StringReader(_xml)); SAXParser saxParser = factory.newSAXParser(); saxParser.parse(inputSource, new XMLStringParser(packet)); - } catch (Exception e) { - return null; + // couldn't parse the XML for some reason + throw new InvalidXMLException("Could not parse the XML: "+_xml); } - + // parsed successfully, return the packet return packet; }