1 50 51 package com.lowagie.text.xml; 52 53 import java.util.HashMap ; 54 import java.util.Properties ; 55 56 import org.xml.sax.Attributes ; 57 58 import com.lowagie.text.DocListener; 59 60 63 64 public class SAXmyHandler extends SAXiTextHandler { 65 66 67 protected HashMap myTags; 68 69 76 77 public SAXmyHandler(DocListener document, HashMap myTags) { 78 super(document); 79 this.myTags = myTags; 80 } 81 82 90 91 public void startElement(String uri, String lname, String name, Attributes attrs) { 92 if (myTags.containsKey(name)) { 93 XmlPeer peer = (XmlPeer) myTags.get(name); 94 handleStartingTags(peer.getTag(), peer.getAttributes(attrs)); 95 } 96 else { 97 Properties attributes = new Properties (); 98 if (attrs != null) { 99 for (int i = 0; i < attrs.getLength(); i++) { 100 String attribute = attrs.getQName(i); 101 attributes.setProperty(attribute, attrs.getValue(i)); 102 } 103 } 104 handleStartingTags(name, attributes); 105 } 106 } 107 108 115 116 public void endElement(String uri, String lname, String name) { 117 if (myTags.containsKey(name)) { 118 XmlPeer peer = (XmlPeer) myTags.get(name); 119 handleEndingTags(peer.getTag()); 120 } 121 else { 122 handleEndingTags(name); 123 } 124 } 125 } | Popular Tags |