public void initialize(String pipelineURI, String uriResolverClassName, String entityResolverClassName) { try{ if (uriResolverClassName != null && uriResolverClassName.trim().length()!=0) theURIResolver = (URIResolver) getClass().getClassLoader().loadClass(uriResolverClassName).newInstance(); else theURIResolver = null; if (entityResolverClassName != null && entityResolverClassName.trim().length()!=0) theEntityResolver = (EntityResolver) getClass().getClassLoader().loadClass(entityResolverClassName).newInstance(); else theEntityResolver = null; if (pipelineURI != null && pipelineURI.trim().length()!=0) thePipelineURI = pipelineURI; else thePipelineURI = null; } catch (Throwable t){ compilationErrors.clear(); compilationErrors.add(new DocumentPositionedInfo(DocumentPositionedInfo.SEVERITY_ERROR, "Error initializing adapter: "+t.getMessage())); dumpStackTrace(t); } }
static void validateAgainstAUDTDs(InputSource input, final Path updaterJar, final Task task) throws IOException, SAXException { XMLUtil.parse(input, true, false, XMLUtil.rethrowHandler(), new EntityResolver() { ClassLoader loader = new AntClassLoader(task.getProject(), updaterJar); public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { String remote = "http://www.netbeans.org/dtds/"; if (systemId.startsWith(remote)) { String rsrc = "org/netbeans/updater/resources/" + systemId.substring(remote.length()); URL u = loader.getResource(rsrc); if (u != null) { return new InputSource(u.toString()); } else { task.log(rsrc + " not found in " + updaterJar, Project.MSG_WARN); } } return null; } }); }
/** * Return the current entity resolver. * * @return The current entity resolver, or null if none * has been registered. * @see #setEntityResolver */ public EntityResolver getEntityResolver() { EntityResolver entityResolver = null; try { XMLEntityResolver xmlEntityResolver = (XMLEntityResolver)fConfiguration.getProperty(ENTITY_RESOLVER); if (xmlEntityResolver != null) { if (xmlEntityResolver instanceof EntityResolverWrapper) { entityResolver = ((EntityResolverWrapper) xmlEntityResolver).getEntityResolver(); } else if (xmlEntityResolver instanceof EntityResolver2Wrapper) { entityResolver = ((EntityResolver2Wrapper) xmlEntityResolver).getEntityResolver(); } } } catch (XMLConfigurationException e) { // do nothing } return entityResolver; }
public void parse(InputSource source, ContentHandler handler, ErrorHandler errorHandler, EntityResolver entityResolver) throws SAXException, IOException { String systemId = source.getSystemId(); Document dom = forest.get(systemId); if (dom == null) { // if no DOM tree is built for it, // let the fall back parser parse the original document. // // for example, XSOM parses datatypes.xsd (XML Schema part 2) // but this will never be built into the forest. fallbackParser.parse(source, handler, errorHandler, entityResolver); return; } scanner.scan(dom, handler); }
/** * Similar to {@link #createNamespaceHandlerResolver(BundleContext, String, ClassLoader)} , this method creates * a special OSGi entity resolver that considers the bundle class path first, falling back to the entity resolver * service provided by the Spring DM extender. * * @param bundleContext the OSGi context of which the resolver should be aware of * @param filter OSGi service filter * @param bundleClassLoader classloader for creating the OSGi namespace resolver proxy * @return a OSGi aware entity resolver */ private EntityResolver createEntityResolver(BundleContext bundleContext, String filter, ClassLoader bundleClassLoader) { Assert.notNull(bundleContext, "bundleContext is required"); // create local namespace resolver EntityResolver localEntityResolver = new DelegatingEntityResolver(bundleClassLoader); // hook in OSGi namespace resolver EntityResolver osgiServiceEntityResolver = lookupEntityResolver(bundleContext, filter, localEntityResolver); ChainedEntityResolver delegate = new ChainedEntityResolver(); delegate.addEntityResolver(localEntityResolver, "LocalEntityResolver for bundle " + OsgiStringUtils.nullSafeNameAndSymName(bundleContext.getBundle())); // hook in OSGi namespace resolver delegate.addEntityResolver(osgiServiceEntityResolver, "OSGi Service resolver"); return delegate; }
public XSOMParser createXSOMParser(final DOMForest forest) { XSOMParser p = createXSOMParser(forest.createParser()); p.setEntityResolver(new EntityResolver() { public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { // DOMForest only parses documents that are reachable through systemIds, // and it won't pick up references like <xs:import namespace="..." /> without // @schemaLocation. So we still need to use an entity resolver here to resolve // these references, yet we don't want to just run them blindly, since if we do that // DOMForestParser always get the translated system ID when catalog is used // (where DOMForest records trees with their original system IDs.) if(systemId!=null && forest.get(systemId)!=null) return new InputSource(systemId); if(opt.entityResolver!=null) return opt.entityResolver.resolveEntity(publicId,systemId); return null; } }); return p; }
public void parse( InputSource source, ContentHandler contentHandler, ErrorHandler errorHandler, EntityResolver entityResolver ) throws SAXException, IOException { String systemId = source.getSystemId(); Document dom = forest.get(systemId); if(dom==null) { // if no DOM tree is built for it, // let the fall back parser parse the original document. // // for example, XSOM parses datatypes.xsd (XML Schema part 2) // but this will never be built into the forest. fallbackParser.parse( source, contentHandler, errorHandler, entityResolver ); return; } scanner.scan( dom, contentHandler ); }
protected static EntityResolver createRelativePathResolver(final String workingDirectory) { return new EntityResolver() { public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { if (systemId != null && systemId.startsWith("file:/")) { URI workingDirectoryURI = new File(workingDirectory).toURI(); URI workingFile; try { // Construction new File(new URI(String)).toURI() is used to be sure URI has correct representation without redundant '/' workingFile = convertToNewWorkingDirectory(currentJavaWorkingDirectory, workingDirectoryURI, new File(new URI(systemId)).toURI()); return new InputSource(workingFile.toString()); } catch (URISyntaxException ex) { //Should not get here } } return null; } }; }
public static Document Load(URL url, EntityResolver er) { // try { // InputStream is = url.openStream(); // BufferedInputStream buffer = new BufferedInputStream(is); // return Load(buffer,er); // } catch (IOException e) { // throw new ProgrammingException("XMLHELPER","Error accessing to '"+url.toExternalForm()+"'",e); // } return null; }
/** * convert an array of {@link InputSource InputSource} into an * array of {@link Source Source} * * @param schemas array of {@link InputSource InputSource} * @return array of {@link Source Source} */ private static Source[] getSchemaSource(InputSource[] schemas, EntityResolver entityResolver) throws SAXException { SAXSource[] sources = new SAXSource[schemas.length]; for (int i = 0; i < schemas.length; i++) { sources[i] = new SAXSource(schemas[i]); // sources[i].getXMLReader().setEntityResolver(entityResolver); } return sources; }
/** Returns a XML parser. The same parser can be returned assuming that config files * are parser sequentially. * * @return XML parser with set content handler, errror handler * and entity resolver. */ public XMLReader getXMLParser (DefaultHandler h) throws SAXException { if (parser == null) { // get non validating, not namespace aware parser parser = XMLUtil.createXMLReader(); parser.setEntityResolver(new EntityResolver () { /** Implementation of entity resolver. Points to the local DTD * for our public ID */ public InputSource resolveEntity (String publicId, String systemId) throws SAXException { if (ModeParser.INSTANCE_DTD_ID_1_0.equals(publicId) || ModeParser.INSTANCE_DTD_ID_1_1.equals(publicId) || ModeParser.INSTANCE_DTD_ID_1_2.equals(publicId) || ModeParser.INSTANCE_DTD_ID_2_0.equals(publicId) || ModeParser.INSTANCE_DTD_ID_2_1.equals(publicId) || ModeParser.INSTANCE_DTD_ID_2_2.equals(publicId) || ModeParser.INSTANCE_DTD_ID_2_3.equals(publicId) || GroupParser.INSTANCE_DTD_ID_2_0.equals(publicId) || TCGroupParser.INSTANCE_DTD_ID_2_0.equals(publicId) || TCRefParser.INSTANCE_DTD_ID_1_0.equals(publicId) || TCRefParser.INSTANCE_DTD_ID_2_0.equals(publicId) || TCRefParser.INSTANCE_DTD_ID_2_1.equals(publicId) || TCRefParser.INSTANCE_DTD_ID_2_2.equals(publicId) || WindowManagerParser.INSTANCE_DTD_ID_1_0.equals(publicId) || WindowManagerParser.INSTANCE_DTD_ID_1_1.equals(publicId) || WindowManagerParser.INSTANCE_DTD_ID_2_0.equals(publicId) || WindowManagerParser.INSTANCE_DTD_ID_2_1.equals(publicId)) { InputStream is = new ByteArrayInputStream(new byte[0]); return new InputSource(is); } return null; // i.e. follow advice of systemID } }); } parser.setContentHandler(h); parser.setErrorHandler(h); return parser; }
/** * Instantiate catalog resolver using new catalog API (javax.xml.catalog.*) * added in JDK9. Usage of new API removes dependency on internal API * (com.sun.org.apache.xml.internal) for modular runtime. */ private static EntityResolver createCatalogResolver(ArrayList<URL> urls) throws Exception { // Prepare array of catalog URIs URI[] uris = urls.stream() .map(u -> URI.create(u.toExternalForm())) .toArray(URI[]::new); //Create CatalogResolver with new JDK9+ API return (EntityResolver) CatalogManager.catalogResolver(CATALOG_FEATURES, uris); }
/** * Sets the resolver used to resolve external entities. The EntityResolver * interface supports resolution of public and system identifiers. * * @param resolver The new entity resolver. Passing a null value will * uninstall the currently installed resolver. */ public void setEntityResolver(EntityResolver resolver) { try { XMLEntityResolver xer = (XMLEntityResolver) fConfiguration.getProperty(ENTITY_RESOLVER); if (fUseEntityResolver2 && resolver instanceof EntityResolver2) { if (xer instanceof EntityResolver2Wrapper) { EntityResolver2Wrapper er2w = (EntityResolver2Wrapper) xer; er2w.setEntityResolver((EntityResolver2) resolver); } else { fConfiguration.setProperty(ENTITY_RESOLVER, new EntityResolver2Wrapper((EntityResolver2) resolver)); } } else { if (xer instanceof EntityResolverWrapper) { EntityResolverWrapper erw = (EntityResolverWrapper) xer; erw.setEntityResolver(resolver); } else { fConfiguration.setProperty(ENTITY_RESOLVER, new EntityResolverWrapper(resolver)); } } } catch (XMLConfigurationException e) { // do nothing } }
private static void assertValidate(String xml) throws Exception { XMLUtil.parse(new InputSource(new ByteArrayInputStream(xml.getBytes("UTF-8"))), false, true, XMLUtil.defaultErrorHandler(), new EntityResolver() { public @Override InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { return new InputSource(new ByteArrayInputStream(new byte[0])); /* XXX when #192595 is implemented, can move DTDs here from core.windows, set validate=true above, and use: InputSource r = EntityCatalog.getDefault().resolveEntity(publicId, systemId); if (r != null) { return r; } else { throw new IOException("network connection to " + systemId); } */ } }); }
public static EntityResolver create(String configuration) { switch (configuration) { case "blank": return blank(); case "simple": return withDefaultSimpleCatalogManager(); case "simpleConfigured": return withConfiguredSimpleCatalogManager(); case "": case "asPlugin": return asInPlugin(); default: throw new IllegalArgumentException("Unknown configuration: " + configuration); } }
public ReResolvingInputSourceWrapper(EntityResolver entityResolver, InputSource inputSource, String publicId, String systemId) { this.entityResolver = entityResolver; this.inputSource = inputSource; this.setPublicId(publicId); this.setSystemId(systemId); }
public ReResolvingEntityResolverWrapper(EntityResolver entityResolver) { if (entityResolver == null) { throw new IllegalArgumentException( "Provided entity resolver must not be null."); } this.entityResolver = entityResolver; }
/** * Return the EntityResolver to use, building a default resolver * if none specified. */ protected EntityResolver getEntityResolver() { if (this.entityResolver == null) { // Determine default EntityResolver to use. ResourceLoader resourceLoader = getResourceLoader(); if (resourceLoader != null) { this.entityResolver = new ResourceEntityResolver(resourceLoader); } else { this.entityResolver = new DelegatingEntityResolver(getBeanClassLoader()); } } return this.entityResolver; }
/** * Create a JAXP DocumentBuilder that this bean definition reader * will use for parsing XML documents. Can be overridden in subclasses, * adding further initialization of the builder. * @param factory the JAXP DocumentBuilderFactory that the DocumentBuilder * should be created with * @param entityResolver the SAX EntityResolver to use * @param errorHandler the SAX ErrorHandler to use * @return the JAXP DocumentBuilder * @throws ParserConfigurationException if thrown by JAXP methods */ protected DocumentBuilder createDocumentBuilder( DocumentBuilderFactory factory, EntityResolver entityResolver, ErrorHandler errorHandler) throws ParserConfigurationException { DocumentBuilder docBuilder = factory.newDocumentBuilder(); if (entityResolver != null) { docBuilder.setEntityResolver(entityResolver); } if (errorHandler != null) { docBuilder.setErrorHandler(errorHandler); } return docBuilder; }
/** * Parses the WSDL and gives WSDLModel. If wsdl parameter is null, then wsdlLoc is used to get the WSDL. If the WSDL * document could not be obtained then {@link MetadataResolverFactory} is tried to get the WSDL document, if not found * then as last option, if the wsdlLoc has no '?wsdl' as query parameter then it is tried by appending '?wsdl'. * * @param wsdlLoc * Either this or <tt>wsdl</tt> parameter must be given. * Null location means the system won't be able to resolve relative references in the WSDL, */ public static WSDLModel parse(@Nullable URL wsdlLoc, @NotNull Source wsdlSource, @NotNull EntityResolver resolver, boolean isClientSide, Container container, Class serviceClass, @NotNull PolicyResolver policyResolver, boolean isUseStreamFromEntityResolverWrapper, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException { assert resolver != null; RuntimeWSDLParser wsdlParser = new RuntimeWSDLParser(wsdlSource.getSystemId(), new EntityResolverWrapper(resolver, isUseStreamFromEntityResolverWrapper), isClientSide, container, policyResolver, extensions); Parser parser; try{ parser = wsdlParser.resolveWSDL(wsdlLoc, wsdlSource, serviceClass); if(!hasWSDLDefinitions(parser.parser)){ throw new XMLStreamException(ClientMessages.RUNTIME_WSDLPARSER_INVALID_WSDL(parser.systemId, WSDLConstants.QNAME_DEFINITIONS, parser.parser.getName(), parser.parser.getLocation())); } }catch(XMLStreamException e){ //Try MEX if there is WSDLLoc available if(wsdlLoc == null) throw e; return tryWithMex(wsdlParser, wsdlLoc, resolver, isClientSide, container, e, serviceClass, policyResolver, extensions); }catch(IOException e){ //Try MEX if there is WSDLLoc available if(wsdlLoc == null) throw e; return tryWithMex(wsdlParser, wsdlLoc, resolver, isClientSide, container, e, serviceClass, policyResolver, extensions); } wsdlParser.extensionFacade.start(wsdlParser.context); wsdlParser.parseWSDL(parser, false); wsdlParser.wsdlDoc.freeze(); wsdlParser.extensionFacade.finished(wsdlParser.context); wsdlParser.extensionFacade.postFinished(wsdlParser.context); if(wsdlParser.wsdlDoc.getServices().isEmpty()) throw new WebServiceException(ClientMessages.WSDL_CONTAINS_NO_SERVICE(wsdlLoc)); return wsdlParser.wsdlDoc; }
/** * Deprecated version that assumes {@code isTransportSynchronous==false} */ @Deprecated public static <T> WSEndpoint<T> create( @NotNull Class<T> implType, boolean processHandlerAnnotation, @Nullable Invoker invoker, @Nullable QName serviceName, @Nullable QName portName, @Nullable Container container, @Nullable WSBinding binding, @Nullable SDDocumentSource primaryWsdl, @Nullable Collection<? extends SDDocumentSource> metadata, @Nullable EntityResolver resolver) { return create(implType,processHandlerAnnotation,invoker,serviceName,portName,container,binding,primaryWsdl,metadata,resolver,false); }
public static <T> WSEndpoint<T> createEndpoint( Class<T> implType, boolean processHandlerAnnotation, @Nullable Invoker invoker, @Nullable QName serviceName, @Nullable QName portName, @Nullable Container container, @Nullable WSBinding binding, @Nullable SDDocumentSource primaryWsdl, @Nullable Collection<? extends SDDocumentSource> metadata, EntityResolver resolver, boolean isTransportSynchronous, boolean isStandard) { EndpointFactory factory = container != null ? container.getSPI(EndpointFactory.class) : null; if (factory == null) factory = EndpointFactory.getInstance(); return factory.create( implType,processHandlerAnnotation, invoker,serviceName,portName,container,binding,primaryWsdl,metadata,resolver,isTransportSynchronous,isStandard); }
/** * Implements {@link WSEndpoint#create}. * * No need to take WebServiceContext implementation. When InvokerPipe is * instantiated, it calls InstanceResolver to set up a WebServiceContext. * We shall only take delegate to getUserPrincipal and isUserInRole from adapter. * * <p> * Nobody else should be calling this method. */ public static <T> WSEndpoint<T> createEndpoint( Class<T> implType, boolean processHandlerAnnotation, @Nullable Invoker invoker, @Nullable QName serviceName, @Nullable QName portName, @Nullable Container container, @Nullable WSBinding binding, @Nullable SDDocumentSource primaryWsdl, @Nullable Collection<? extends SDDocumentSource> metadata, EntityResolver resolver, boolean isTransportSynchronous) { return createEndpoint(implType, processHandlerAnnotation, invoker, serviceName, portName, container, binding, primaryWsdl, metadata, resolver, isTransportSynchronous, true); }
/** * Parses the WSDL and gives WSDLModel. If wsdl parameter is null, then wsdlLoc is used to get the WSDL. If the WSDL * document could not be obtained then {@link MetadataResolverFactory} is tried to get the WSDL document, if not found * then as last option, if the wsdlLoc has no '?wsdl' as query parameter then it is tried by appending '?wsdl'. * * @param wsdlLoc * Either this or {@code wsdl} parameter must be given. * Null location means the system won't be able to resolve relative references in the WSDL, */ public static WSDLModel parse(@Nullable URL wsdlLoc, @NotNull Source wsdlSource, @NotNull EntityResolver resolver, boolean isClientSide, Container container, Class serviceClass, @NotNull PolicyResolver policyResolver, boolean isUseStreamFromEntityResolverWrapper, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException { assert resolver != null; RuntimeWSDLParser wsdlParser = new RuntimeWSDLParser(wsdlSource.getSystemId(), new EntityResolverWrapper(resolver, isUseStreamFromEntityResolverWrapper), isClientSide, container, policyResolver, extensions); Parser parser; try{ parser = wsdlParser.resolveWSDL(wsdlLoc, wsdlSource, serviceClass); if(!hasWSDLDefinitions(parser.parser)){ throw new XMLStreamException(ClientMessages.RUNTIME_WSDLPARSER_INVALID_WSDL(parser.systemId, WSDLConstants.QNAME_DEFINITIONS, parser.parser.getName(), parser.parser.getLocation())); } }catch(XMLStreamException e){ //Try MEX if there is WSDLLoc available if(wsdlLoc == null) throw e; return tryWithMex(wsdlParser, wsdlLoc, resolver, isClientSide, container, e, serviceClass, policyResolver, extensions); }catch(IOException e){ //Try MEX if there is WSDLLoc available if(wsdlLoc == null) throw e; return tryWithMex(wsdlParser, wsdlLoc, resolver, isClientSide, container, e, serviceClass, policyResolver, extensions); } wsdlParser.extensionFacade.start(wsdlParser.context); wsdlParser.parseWSDL(parser, false); wsdlParser.wsdlDoc.freeze(); wsdlParser.extensionFacade.finished(wsdlParser.context); wsdlParser.extensionFacade.postFinished(wsdlParser.context); if(wsdlParser.wsdlDoc.getServices().isEmpty()) throw new WebServiceException(ClientMessages.WSDL_CONTAINS_NO_SERVICE(wsdlLoc)); return wsdlParser.wsdlDoc; }
private static InputSource makeInputSource(XMLReader xr, String systemId) throws IOException, SAXException { EntityResolver er = xr.getEntityResolver(); if (er != null) { InputSource inputSource = er.resolveEntity(null, systemId); if (inputSource != null) return inputSource; } return new InputSource(systemId); }
/** * Creates an {@link EntityResolver} that consults {@code /WEB-INF/jax-ws-catalog.xml}. */ private EntityResolver createEntityResolver() { try { return XmlUtil.createEntityResolver(loader.getCatalogFile()); } catch (MalformedURLException e) { throw new WebServiceException(e); } }
private void createEndpoint(String urlPattern) { // Checks permission for "publishEndpoint" SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(ENDPOINT_PUBLISH_PERMISSION); } // See if HttpServer implementation is available try { Class.forName("com.sun.net.httpserver.HttpServer"); } catch (Exception e) { throw new UnsupportedOperationException("Couldn't load light weight http server", e); } container = getContainer(); MetadataReader metadataReader = EndpointFactory.getExternalMetadatReader(implClass, binding); WSEndpoint wse = WSEndpoint.create( implClass, true, invoker, getProperty(QName.class, Endpoint.WSDL_SERVICE), getProperty(QName.class, Endpoint.WSDL_PORT), container, binding, getPrimaryWsdl(metadataReader), buildDocList(), (EntityResolver) null, false ); // Don't load HttpEndpoint class before as it may load HttpServer classes actualEndpoint = new HttpEndpoint(executor, getAdapter(wse, urlPattern)); }
/** * Implements {@link WSEndpoint#create}. * * No need to take WebServiceContext implementation. When InvokerPipe is * instantiated, it calls InstanceResolver to set up a WebServiceContext. * We shall only take delegate to getUserPrincipal and isUserInRole from adapter. * * <p> * Nobody else should be calling this method. */ public <T> WSEndpoint<T> create( Class<T> implType, boolean processHandlerAnnotation, @Nullable Invoker invoker, @Nullable QName serviceName, @Nullable QName portName, @Nullable Container container, @Nullable WSBinding binding, @Nullable SDDocumentSource primaryWsdl, @Nullable Collection<? extends SDDocumentSource> metadata, EntityResolver resolver, boolean isTransportSynchronous) { return create(implType, processHandlerAnnotation, invoker, serviceName, portName, container, binding, primaryWsdl, metadata, resolver, isTransportSynchronous, true); }
/** * Load a SVG document into a diagram * * @param in * The input stream from which to read the SVG * @param offset * Offset the diagram for the height of the document * @return The diagram loaded * @throws SlickException * Indicates a failure to process the document */ private Diagram loadDiagram(InputStream in, boolean offset) throws SlickException { try { DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance(); factory.setValidating(false); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); builder.setEntityResolver(new EntityResolver() { public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { return new InputSource( new ByteArrayInputStream(new byte[0])); } }); Document doc = builder.parse(in); Element root = doc.getDocumentElement(); String widthString = root.getAttribute("width"); while (Character.isLetter(widthString .charAt(widthString.length() - 1))) { widthString = widthString.substring(0, widthString.length() - 1); } String heightString = root.getAttribute("height"); while (Character.isLetter(heightString .charAt(heightString.length() - 1))) { heightString = heightString.substring(0,heightString.length() - 1); } float docWidth = Float.parseFloat(widthString); float docHeight = Float.parseFloat(heightString); diagram = new Diagram(docWidth, docHeight); if (!offset) { docHeight = 0; } loadChildren(root, Transform .createTranslateTransform(0, -docHeight)); return diagram; } catch (Exception e) { throw new SlickException("Failed to load inkscape document", e); } }
public void setEntityResolver(EntityResolver resolver){ this.options.entityResolver = resolver; }
public EntityResolver getEntityResolver() { return EntityCatalog.getDefault(); }
public WhitespaceStripper(ContentHandler handler,ErrorHandler eh,EntityResolver er) { setContentHandler(handler); if(eh!=null) setErrorHandler(eh); if(er!=null) setEntityResolver(er); }
public void setEntityResolver(EntityResolver er) { domParser.setEntityResolver(er); }
public ContentHandler getContentHandler( AnnotationContext contest, String elementName, ErrorHandler errorHandler, EntityResolver entityResolver ) { return new DefaultHandler(); }
/** Sets the SAX entity resolver. */ public void setEntityResolver(EntityResolver entityResolver) { fEntityResolver = entityResolver; }
/** Entity resolver that knows about AU DTDs, so no network is needed. * @author Jesse Glick */ public static EntityResolver createAUResolver() { return new EntityResolver() { @Override public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException { if ("-//NetBeans//DTD Autoupdate Catalog 1.0//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-1_0.dtd").toString()); // NOI18N } else if ("-//NetBeans//DTD Autoupdate Module Info 1.0//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-info-1_0.dtd").toString()); // NOI18N } else if ("-//NetBeans//DTD Autoupdate Catalog 2.0//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-2_0.dtd").toString()); // NOI18N } else if ("-//NetBeans//DTD Autoupdate Module Info 2.0//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-info-2_0.dtd").toString()); // NOI18N } else if ("-//NetBeans//DTD Autoupdate Catalog 2.2//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-2_2.dtd").toString()); // NOI18N } else if ("-//NetBeans//DTD Autoupdate Module Info 2.2//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-info-2_2.dtd").toString()); // NOI18N } else if ("-//NetBeans//DTD Autoupdate Catalog 2.3//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-2_3.dtd").toString()); // NOI18N } else if ("-//NetBeans//DTD Autoupdate Module Info 2.3//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-info-2_3.dtd").toString()); // NOI18N } else if ("-//NetBeans//DTD Autoupdate Catalog 2.4//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-2_4.dtd").toString()); // NOI18N } else if ("-//NetBeans//DTD Autoupdate Module Info 2.4//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-info-2_4.dtd").toString()); // NOI18N } else if ("-//NetBeans//DTD Autoupdate Catalog 2.5//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-2_5.dtd").toString()); // NOI18N } else if ("-//NetBeans//DTD Autoupdate Module Info 2.5//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-info-2_5.dtd").toString()); // NOI18N } else if ("-//NetBeans//DTD Autoupdate Catalog 2.6//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-2_6.dtd").toString()); // NOI18N } else if ("-//NetBeans//DTD Autoupdate Catalog 2.7//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-catalog-2_7.dtd").toString()); // NOI18N } else if ("-//NetBeans//DTD Autoupdate Module Info 2.7//EN".equals(publicID)) { // NOI18N return new InputSource(XMLUtil.class.getResource("resources/autoupdate-info-2_7.dtd").toString()); // NOI18N } else { if (systemID.endsWith(".dtd")) { // NOI18N return new InputSource(new ByteArrayInputStream(new byte[0])); } URL u = new URL(systemID); URLConnection oc = u.openConnection(); oc.setConnectTimeout(5000); return new InputSource(oc.getInputStream()); } } }; }
public EntityResolver getEntityResolver() { return _entityResolver; }