--- projects/cms/source/util/uk/org/iscream/cms/util/XMLStringParser.java 2000/12/12 20:44:30 1.5 +++ projects/cms/source/util/uk/org/iscream/cms/util/XMLStringParser.java 2001/03/10 00:49:39 1.8 @@ -6,6 +6,7 @@ import java.io.*; import java.util.ArrayList; import org.xml.sax.*; +import org.xml.sax.helpers.*; import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; @@ -13,17 +14,17 @@ import javax.xml.parsers.SAXParser; /** * XMLStringParser - Used to assist in creating XMLPacket objects. * - * @author $Author: ajm $ - * @version $Id: XMLStringParser.java,v 1.5 2000/12/12 20:44:30 ajm Exp $ + * @author $Author: tdb $ + * @version $Id: XMLStringParser.java,v 1.8 2001/03/10 00:49:39 tdb Exp $ */ -public class XMLStringParser extends HandlerBase { +public class XMLStringParser extends DefaultHandler { //---FINAL ATTRIBUTES--- /** * The current CVS revision of this class */ - public final String REVISION = "$Revision: 1.5 $"; + public final String REVISION = "$Revision: 1.8 $"; //---STATIC METHODS--- @@ -73,12 +74,12 @@ public class XMLStringParser extends HandlerBase { * "packet.attributes.machine_name" * within the XMLPacket. */ - public void startElement (String name, AttributeList attrs) throws SAXException { + public void startElement (String name, Attributes attrs) throws SAXException { indentLevel++; tagList.add(name); if (attrs != null) { for (int i = 0; i < attrs.getLength (); i++) { - packet.addParam(getPath()+".attributes."+attrs.getName(i), attrs.getValue(i)); + packet.addParam(getPath()+".attributes."+attrs.getLocalName(i), attrs.getValue(i)); } } } @@ -101,9 +102,7 @@ public class XMLStringParser extends HandlerBase { */ public void characters (char[] buf, int offset, int len) throws SAXException { String s = new String(buf, offset, len); - if (!s.trim().equals("")) { - packet.addParam(getPath(), s); - } + packet.addParam(getPath(), s); } /** @@ -146,8 +145,19 @@ public class XMLStringParser extends HandlerBase { //---ATTRIBUTES--- + /** + * To keep track of our identation level + */ private int indentLevel = 0; + + /** + * An ArrayList of tags + */ private ArrayList tagList = new ArrayList(); + + /** + * A reference to the XMLPacket we are making + */ private XMLPacket packet; /**