1 3 19 20 package com.sun.org.apache.xml.internal.resolver.readers; 21 22 import java.util.Vector ; 23 import com.sun.org.apache.xml.internal.resolver.Catalog; 24 import com.sun.org.apache.xml.internal.resolver.CatalogEntry; 25 import com.sun.org.apache.xml.internal.resolver.CatalogException; 26 import com.sun.org.apache.xml.internal.resolver.helpers.PublicId; 27 28 import org.xml.sax.*; 29 30 import javax.xml.parsers.*; 31 32 43 public class XCatalogReader extends SAXCatalogReader implements SAXCatalogParser { 44 47 protected Catalog catalog = null; 48 49 50 public void setCatalog (Catalog catalog) { 51 this.catalog = catalog; 52 } 53 54 55 public Catalog getCatalog () { 56 return catalog; 57 } 58 59 60 public XCatalogReader(SAXParserFactory parserFactory) { 61 super(parserFactory); 62 } 63 64 67 68 public void setDocumentLocator (Locator locator) { 69 return; 70 } 71 72 73 public void startDocument () 74 throws SAXException { 75 return; 76 } 77 78 79 public void endDocument () 80 throws SAXException { 81 return; 82 } 83 84 96 public void startElement (String namespaceURI, 97 String localName, 98 String qName, 99 Attributes atts) 100 throws SAXException { 101 102 int entryType = -1; 103 Vector entryArgs = new Vector (); 104 105 if (localName.equals("Base")) { 106 entryType = catalog.BASE; 107 entryArgs.add(atts.getValue("HRef")); 108 109 catalog.getCatalogManager().debug.message(4, "Base", atts.getValue("HRef")); 110 } else if (localName.equals("Delegate")) { 111 entryType = catalog.DELEGATE_PUBLIC; 112 entryArgs.add(atts.getValue("PublicId")); 113 entryArgs.add(atts.getValue("HRef")); 114 115 catalog.getCatalogManager().debug.message(4, "Delegate", 116 PublicId.normalize(atts.getValue("PublicId")), 117 atts.getValue("HRef")); 118 } else if (localName.equals("Extend")) { 119 entryType = catalog.CATALOG; 120 entryArgs.add(atts.getValue("HRef")); 121 122 catalog.getCatalogManager().debug.message(4, "Extend", atts.getValue("HRef")); 123 } else if (localName.equals("Map")) { 124 entryType = catalog.PUBLIC; 125 entryArgs.add(atts.getValue("PublicId")); 126 entryArgs.add(atts.getValue("HRef")); 127 128 catalog.getCatalogManager().debug.message(4, "Map", 129 PublicId.normalize(atts.getValue("PublicId")), 130 atts.getValue("HRef")); 131 } else if (localName.equals("Remap")) { 132 entryType = catalog.SYSTEM; 133 entryArgs.add(atts.getValue("SystemId")); 134 entryArgs.add(atts.getValue("HRef")); 135 136 catalog.getCatalogManager().debug.message(4, "Remap", 137 atts.getValue("SystemId"), 138 atts.getValue("HRef")); 139 } else if (localName.equals("XMLCatalog")) { 140 } else { 142 catalog.getCatalogManager().debug.message(1, "Invalid catalog entry type", localName); 144 } 145 146 if (entryType >= 0) { 147 try { 148 CatalogEntry ce = new CatalogEntry(entryType, entryArgs); 149 catalog.addEntry(ce); 150 } catch (CatalogException cex) { 151 if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { 152 catalog.getCatalogManager().debug.message(1, "Invalid catalog entry type", localName); 153 } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { 154 catalog.getCatalogManager().debug.message(1, "Invalid catalog entry", localName); 155 } 156 } 157 } 158 } 159 160 161 public void endElement (String namespaceURI, 162 String localName, 163 String qName) 164 throws SAXException { 165 return; 166 } 167 168 169 public void characters (char ch[], int start, int length) 170 throws SAXException { 171 return; 172 } 173 174 175 public void ignorableWhitespace (char ch[], int start, int length) 176 throws SAXException { 177 return; 178 } 179 180 181 public void processingInstruction (String target, String data) 182 throws SAXException { 183 return; 184 } 185 } 186 | Popular Tags |