01: /*
02: * Created on Jan 20, 2006
03: */
04: package uk.org.ponder.xml;
05:
06: import java.util.Iterator;
07: import java.util.Map;
08:
09: import uk.org.ponder.streamutil.write.StringPOS;
10:
11: public class XMLUtil {
12:
13: public static void dumpAttributes(Map attrs, XMLWriter xmlw) {
14: for (Iterator keyit = attrs.keySet().iterator(); keyit
15: .hasNext();) {
16: String key = (String) keyit.next();
17: String attrvalue = (String) attrs.get(key);
18: dumpAttribute(key, attrvalue, xmlw);
19: }
20: }
21:
22: public static void dumpAttribute(String name, String value,
23: XMLWriter xmlw) {
24: xmlw.writeRaw(" ").writeRaw(name).writeRaw("=\"");
25: xmlw.write(value);
26: xmlw.writeRaw("\"");
27: }
28:
29: /** A slow method for XML-encoding text **/
30: public static String encode(String toencode) {
31: StringPOS pos = new StringPOS();
32: XMLWriter xmlw = new XMLWriter(pos);
33: xmlw.write(toencode);
34: return pos.toString();
35: }
36:
37: }
|