/** * Returns an instance of the desired class. There is no provision for: a) same instances each * call b) different instances each call c) this factory being thread safe * * @param targetNamespace * @param desiredSchema URI the uri of which you want a schema instance. * @return Schema an instance of the desired schema. * @throws SAXException */ public static Schema getInstance(URI targetNamespace, URI desiredSchema) throws SAXException { return getInstance(targetNamespace, desiredSchema, Level.WARNING); }
/** * Returns an instance of the targetNamespace if it can be found ... null otherwise. * targetNamespaces which can be found are either hard-coded namespaces * (SchemaFactory.properties), have already been parsed or were registered. * * @param targetNamespace * @see #registerSchema(Strin,Schema) */ public static synchronized Schema getInstance(URI targetNamespace) { return getInstance().getRealInstance(targetNamespace); }
private XSISAXHandler parseSchema(InputStream is1, Level level) throws SAXException { setParser(); XSISAXHandler contentHandler = getSAXHandler(null); XSISAXHandler.setLogLevel(level); try { parser.parse(is1, contentHandler); } catch (IOException e) { throw new SAXException(e); } return contentHandler; }
/** * Registers a Schema instance with the factory. A clone is NOT created within this method. The * Schema passed in is associated with the specified targetNamespace. The Schema is not tested * to ensure the intended targetNamespace (schema.getTargetNamespace()) is equal to * targetNamespace. The ramifications is that you may hack wildly within the repository, but we * aware you may have some 'undocumented features' as a result (odd Schemas being returned). * * @param targetNamespace * @param schema */ public static void registerSchema(URI targetNamespace, Schema schema) { getInstance().registerRealSchema(targetNamespace, schema); }
URI targetNamespace = targetNamespace2; if ((targetNamespace == null) || (schemas.get(targetNamespace) == null)) { setParser(); XSISAXHandler contentHandler = getSAXHandler(desiredSchema); XSISAXHandler.setLogLevel(level); parser.parse(resolveSchema(desiredSchema), contentHandler); } catch (IOException e) { schema = merge(schema, (Schema) schemas.get(targetNamespace)); if (!((Schema) schemas.get(targetNamespace)).includesURI(desiredSchema)) { Schema sh = (Schema) schemas.get(targetNamespace); setParser(); XSISAXHandler contentHandler = getSAXHandler(desiredSchema); XSISAXHandler.setLogLevel(level); parser.parse(resolveSchema(desiredSchema), contentHandler); } catch (IOException e) { throw new SAXException(e); sh = merge(sh, contentHandler.getSchema());
private synchronized Schema getRealInstance(URI targetNamespace2, InputStream is1, Level level) throws SAXException { URI targetNamespace = targetNamespace2; if ((targetNamespace == null) || (schemas.get(targetNamespace) == null)) { XSISAXHandler contentHandler = parseSchema(is1, level); if ((targetNamespace == null) || "".equals(targetNamespace)) { targetNamespace = contentHandler.getSchema().getTargetNamespace(); } Schema schema = contentHandler.getSchema(); if (schemas.get(targetNamespace) != null) { schema = merge(schema, (Schema) schemas.get(targetNamespace)); } schemas.put(targetNamespace, schema); } else { Schema sh = (Schema) schemas.get(targetNamespace); XSISAXHandler contentHandler = parseSchema(is1, level); sh = merge(sh, contentHandler.getSchema()); schemas.put(targetNamespace, sh); // over-write } return (Schema) schemas.get(targetNamespace); }
/** Default constructor. */ protected SchemaFactory() { super(); initResolver(); }
private Map loadSchemas() { schemas = new HashMap(); ClassLoader[] cls = findLoaders(); String serviceId = "META-INF/services/" + Schema.class.getName();
public static Schema getInstance(URI targetNamespace, InputStream is1) throws SAXException { return getInstance(targetNamespace, is1, Level.WARNING); }
public static synchronized Schema getInstance(URI targetNamespace, InputStream is1, Level level) throws SAXException { return getInstance().getRealInstance(targetNamespace, is1, level); }
public static synchronized Schema getInstance(String targetNamespace) { try { URI uri = new URI(targetNamespace); return getInstance(uri); } catch (URISyntaxException e) { return null; } } /**
/** * Returns an instance of the desired class. There is no provision for: a) same instances each * call b) different instances each call c) this factory being thread safe * * @param targetNamespace The targetNamespace to search for. * @param desiredSchema URI the uri of which you want a schema instance. * @param level Level * @return Schema an instance of the desired schema. * @throws SAXException When something goes wrong */ public static synchronized Schema getInstance( URI targetNamespace, URI desiredSchema, Level level) throws SAXException { return getInstance().getRealInstance(targetNamespace, desiredSchema, level); }
public static synchronized Schema[] getSchemas(String prefix) { if (prefix == null) return null; SchemaFactory sf = getInstance(); Iterator i = sf.schemas.values().iterator(); List l = new LinkedList(); while (i.hasNext()) { Schema s = (Schema) i.next(); if (prefix.equals(s.getPrefix())) l.add(s); } return (Schema[]) l.toArray(new Schema[l.size()]); }
/** @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String) */ public void startPrefixMapping(String prefix, String targ) throws SAXException { logger.finest("Target == '" + targ + "'"); try { URI tns = new URI(targ); Schema s = SchemaFactory.getInstance(tns); if (s == null) { prefixURIs.put(prefix, tns); return; } if ((prefix == null) || "".equalsIgnoreCase(prefix)) { defaultNS = s.getTargetNamespace(); } targSchemas.put(s.getTargetNamespace(), s); prefixURIs.put(prefix, tns); } catch (URISyntaxException e) { logger.warning(e.toString()); throw new SAXException(e); } }
Schema s = SchemaFactory.getInstance(tns, uri, logger.getLevel());
} else { XSISAXHandler.setLogLevel(logger.getLevel()); prefix = SchemaFactory.getInstance(namespaceURI).getPrefix();
} else { XSISAXHandler.setLogLevel(logger.getLevel()); prefix = SchemaFactory.getInstance(namespaceURI).getPrefix();
} else { XSISAXHandler.setLogLevel(logger.getLevel()); prefix = SchemaFactory.getInstance(namespaceURI).getPrefix();
incURI = thisURI.normalize().resolve(inc.getSchemaLocation()); cs = SchemaFactory.getInstance(targetNamespace, incURI, logger.getLevel()); SchemaFactory.getInstance( imp.getNamespace(), incURI, logger.getLevel());
so.add(SchemaFactory.getInstance(uri)); targNS.remove(nsIndex); } else { URI uri = new URI(stringOrder[i]); so.add(SchemaFactory.getInstance(uri));