Package org.apache.xml.resolver

Examples of org.apache.xml.resolver.CatalogException


/* 160 */     factory.setNamespaceAware(false);
/* 161 */     factory.setValidating(false);
/*     */     try {
/* 163 */       builder = factory.newDocumentBuilder();
/*     */     } catch (ParserConfigurationException pce) {
/* 165 */       throw new CatalogException(6);
/*     */     }
/*     */
/* 168 */     Document doc = null;
/*     */     try
/*     */     {
/* 171 */       doc = builder.parse(is);
/*     */     } catch (SAXException se) {
/* 173 */       throw new CatalogException(5);
/*     */     }
/*     */
/* 176 */     Element root = doc.getDocumentElement();
/*     */
/* 178 */     String namespaceURI = Namespaces.getNamespaceURI(root);
/* 179 */     String localName = Namespaces.getLocalName(root);
/*     */
/* 181 */     String domParserClass = getCatalogParser(namespaceURI, localName);
/*     */
/* 184 */     if (domParserClass == null) {
/* 185 */       if (namespaceURI == null) {
/* 186 */         catalog.getCatalogManager().debug.message(1, "No Catalog parser for " + localName);
/*     */       }
/*     */       else {
/* 189 */         catalog.getCatalogManager().debug.message(1, "No Catalog parser for {" + namespaceURI + "}" + localName);
/*     */       }
/*     */
/* 193 */       return;
/*     */     }
/*     */
/* 196 */     DOMCatalogParser domParser = null;
/*     */     try
/*     */     {
/* 199 */       domParser = (DOMCatalogParser)Class.forName(domParserClass).newInstance();
/*     */     } catch (ClassNotFoundException cnfe) {
/* 201 */       catalog.getCatalogManager().debug.message(1, "Cannot load XML Catalog Parser class", domParserClass);
/* 202 */       throw new CatalogException(6);
/*     */     } catch (InstantiationException ie) {
/* 204 */       catalog.getCatalogManager().debug.message(1, "Cannot instantiate XML Catalog Parser class", domParserClass);
/* 205 */       throw new CatalogException(6);
/*     */     } catch (IllegalAccessException iae) {
/* 207 */       catalog.getCatalogManager().debug.message(1, "Cannot access XML Catalog Parser class", domParserClass);
/* 208 */       throw new CatalogException(6);
/*     */     } catch (ClassCastException cce) {
/* 210 */       catalog.getCatalogManager().debug.message(1, "Cannot cast XML Catalog Parser class", domParserClass);
/* 211 */       throw new CatalogException(6);
/*     */     }
/*     */
/* 214 */     Node node = root.getFirstChild();
/* 215 */     while (node != null) {
/* 216 */       domParser.parseCatalogEntry(catalog, node);
View Full Code Here


/*     */   public void readCatalog(Catalog catalog, InputStream is)
/*     */     throws IOException, CatalogException
/*     */   {
/* 233 */     if ((this.parserFactory == null) && (this.parserClass == null)) {
/* 234 */       this.debug.message(1, "Cannot read SAX catalog without a parser");
/* 235 */       throw new CatalogException(6);
/*     */     }
/*     */
/* 238 */     this.debug = catalog.getCatalogManager().debug;
/* 239 */     EntityResolver bResolver = catalog.getCatalogManager().getBootstrapResolver();
/*     */
/* 241 */     this.catalog = catalog;
/*     */     try
/*     */     {
/* 244 */       if (this.parserFactory != null) {
/* 245 */         SAXParser parser = this.parserFactory.newSAXParser();
/* 246 */         SAXParserHandler spHandler = new SAXParserHandler();
/* 247 */         spHandler.setContentHandler(this);
/* 248 */         if (bResolver != null) {
/* 249 */           spHandler.setEntityResolver(bResolver);
/*     */         }
/* 251 */         parser.parse(new InputSource(is), spHandler);
/*     */       } else {
/* 253 */         Parser parser = (Parser)Class.forName(this.parserClass, true, this.loader != null ? this.loader : getClass().getClassLoader()).newInstance();
/* 254 */         parser.setDocumentHandler(this);
/* 255 */         if (bResolver != null) {
/* 256 */           parser.setEntityResolver(bResolver);
/*     */         }
/* 258 */         parser.parse(new InputSource(is));
/*     */       }
/*     */     } catch (ClassNotFoundException cnfe) {
/* 261 */       throw new CatalogException(6);
/*     */     } catch (IllegalAccessException iae) {
/* 263 */       throw new CatalogException(6);
/*     */     } catch (InstantiationException ie) {
/* 265 */       throw new CatalogException(6);
/*     */     } catch (ParserConfigurationException pce) {
/* 267 */       throw new CatalogException(5);
/*     */     } catch (SAXException se) {
/* 269 */       Exception e = se.getException();
/*     */
/* 271 */       UnknownHostException uhe = new UnknownHostException();
/* 272 */       FileNotFoundException fnfe = new FileNotFoundException();
/* 273 */       if (e != null) {
/* 274 */         if (e.getClass() == uhe.getClass()) {
/* 275 */           throw new CatalogException(7, e.toString());
/*     */         }
/* 277 */         if (e.getClass() == fnfe.getClass()) {
/* 278 */           throw new CatalogException(7, e.toString());
/*     */         }
/*     */       }
/*     */
/* 282 */       throw new CatalogException(se);
/*     */     }
/*     */   }
View Full Code Here

/* 236 */         ch = nextch;
/* 237 */         nextch = nextChar();
/*     */       }
/*     */
/* 240 */       if (nextch < 0) {
/* 241 */         throw new CatalogException(8, "Unterminated comment in catalog file; EOF treated as end-of-comment.");
/*     */       }
/*     */
/*     */     }
/*     */
/* 248 */     this.stack[(++this.top)] = nextch;
View Full Code Here

TOP

Related Classes of org.apache.xml.resolver.CatalogException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.