List of usage examples for javax.xml.parsers SAXParserFactory getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:net.sf.jasperreports.engine.xml.BaseSaxParserFactory.java
protected SAXParserFactory createSAXParserFactory() throws ParserConfigurationException, SAXException { SAXParserFactory parserFactory = SAXParserFactory.newInstance(); if (log.isDebugEnabled()) { log.debug("Instantiated SAX parser factory of type " + parserFactory.getClass().getName()); }/*from w w w . j av a2s .c om*/ parserFactory.setNamespaceAware(true); boolean validating = isValidating(); parserFactory.setValidating(validating); parserFactory.setFeature("http://xml.org/sax/features/validation", validating); return parserFactory; }
From source file:nl.nn.adapterframework.util.XmlUtils.java
public static String getVersionInfo() { StringBuilder sb = new StringBuilder(); sb.append(AppConstants.getInstance().getProperty("application.name") + " " + AppConstants.getInstance().getProperty("application.version")).append(SystemUtils.LINE_SEPARATOR); sb.append("XML tool version info:").append(SystemUtils.LINE_SEPARATOR); SAXParserFactory spFactory = getSAXParserFactory(); sb.append("SAXParserFactory-class =").append(spFactory.getClass().getName()) .append(SystemUtils.LINE_SEPARATOR); DocumentBuilderFactory domFactory1 = getDocumentBuilderFactory(false); sb.append("DocumentBuilderFactory1-class =").append(domFactory1.getClass().getName()) .append(SystemUtils.LINE_SEPARATOR); DocumentBuilderFactory domFactory2 = getDocumentBuilderFactory(true); sb.append("DocumentBuilderFactory2-class =").append(domFactory2.getClass().getName()) .append(SystemUtils.LINE_SEPARATOR); TransformerFactory tFactory1 = getTransformerFactory(false); sb.append("TransformerFactory1-class =").append(tFactory1.getClass().getName()) .append(SystemUtils.LINE_SEPARATOR); TransformerFactory tFactory2 = getTransformerFactory(true); sb.append("TransformerFactory2-class =").append(tFactory2.getClass().getName()) .append(SystemUtils.LINE_SEPARATOR); sb.append("Apache-XML tool version info:").append(SystemUtils.LINE_SEPARATOR); try {/* w w w.j a v a 2s. c om*/ sb.append("Xerces-Version=").append(org.apache.xerces.impl.Version.getVersion()) .append(SystemUtils.LINE_SEPARATOR); } catch (Throwable t) { sb.append("Xerces-Version not found (").append(t.getClass().getName()).append(": ") .append(t.getMessage()).append(")").append(SystemUtils.LINE_SEPARATOR); } try { String xalanVersion; if (IbisContext.getApplicationServerType().startsWith("WAS")) { xalanVersion = nl.nn.org.apache.xalan.Version.getVersion(); } else { xalanVersion = org.apache.xalan.Version.getVersion(); } sb.append("Xalan-Version=" + xalanVersion + SystemUtils.LINE_SEPARATOR); } catch (Throwable t) { sb.append("Xalan-Version not found (").append(t.getClass().getName()).append(": ") .append(t.getMessage()).append(")").append(SystemUtils.LINE_SEPARATOR); } try { // sb.append("XmlCommons-Version="+org.apache.xmlcommons.Version.getVersion()+SystemUtils.LINE_SEPARATOR); } catch (Throwable t) { sb.append("XmlCommons-Version not found (").append(t.getClass().getName()).append(": ") .append(t.getMessage()).append(")").append(SystemUtils.LINE_SEPARATOR); } return sb.toString(); }
From source file:org.apache.ojb.broker.metadata.RepositoryPersistor.java
/** * Read metadata by populating an instance of the target class * using SAXParser.//from w w w. j a v a2s .c o m */ private Object readMetadataFromXML(InputSource source, Class target) throws MalformedURLException, ParserConfigurationException, SAXException, IOException { // TODO: make this configurable boolean validate = false; // get a xml reader instance: SAXParserFactory factory = SAXParserFactory.newInstance(); log.info("RepositoryPersistor using SAXParserFactory : " + factory.getClass().getName()); if (validate) { factory.setValidating(true); } SAXParser p = factory.newSAXParser(); XMLReader reader = p.getXMLReader(); if (validate) { reader.setErrorHandler(new OJBErrorHandler()); } Object result; if (DescriptorRepository.class.equals(target)) { // create an empty repository: DescriptorRepository repository = new DescriptorRepository(); // create handler for building the repository structure ContentHandler handler = new RepositoryXmlHandler(repository); // tell parser to use our handler: reader.setContentHandler(handler); reader.parse(source); result = repository; } else if (ConnectionRepository.class.equals(target)) { // create an empty repository: ConnectionRepository repository = new ConnectionRepository(); // create handler for building the repository structure ContentHandler handler = new ConnectionDescriptorXmlHandler(repository); // tell parser to use our handler: reader.setContentHandler(handler); reader.parse(source); //LoggerFactory.getBootLogger().info("loading XML took " + (stop - start) + " msecs"); result = repository; } else throw new MetadataException( "Could not build a repository instance for '" + target + "', using source " + source); return result; }
From source file:org.kuali.rice.devtools.jpa.eclipselink.conv.ojb.OjbUtil.java
private static Object readMetadataFromXML(InputSource source, Class target) throws ParserConfigurationException, SAXException, IOException { // get a xml reader instance: SAXParserFactory factory = SAXParserFactory.newInstance(); LOG.debug("RepositoryPersistor using SAXParserFactory : " + factory.getClass().getName()); SAXParser p = factory.newSAXParser(); XMLReader reader = p.getXMLReader(); Object result;//from w w w . ja v a 2s.c o m if (DescriptorRepository.class.equals(target)) { // create an empty repository: DescriptorRepository repository = new DescriptorRepository(); // create handler for building the repository structure org.xml.sax.ContentHandler handler = new RepositoryXmlHandler(repository); // tell parser to use our handler: reader.setContentHandler(handler); reader.parse(source); result = repository; } else if (ConnectionRepository.class.equals(target)) { // create an empty repository: ConnectionRepository repository = new ConnectionRepository(); // create handler for building the repository structure org.xml.sax.ContentHandler handler = new ConnectionDescriptorXmlHandler(repository); // tell parser to use our handler: reader.setContentHandler(handler); reader.parse(source); //LoggerFactory.getBootLogger().info("loading XML took " + (stop - start) + " msecs"); result = repository; } else throw new MetadataException( "Could not build a repository instance for '" + target + "', using source " + source); return result; }
From source file:org.mule.config.DefaultMuleConfiguration.java
/** * Mule needs a proper JAXP implementation and will complain when run with a plain JDK * 1.4. Use the supplied launcher or specify a proper JAXP implementation via * <code>-Djava.endorsed.dirs</code>. See the following URLs for more information: * <ul>//from www. ja v a 2s. c o m * <li><a href="http://xerces.apache.org/xerces2-j/faq-general.html#faq-4">Xerces</a> * <li><a href="http://xml.apache.org/xalan-j/faq.html#faq-N100D6">Xalan</a> * <li><a href="http://java.sun.com/j2se/1.4.2/docs/guide/standards/">Endorsed Standards Override Mechanism</a> * </ul> */ protected void validateXML() throws FatalException { SAXParserFactory f = SAXParserFactory.newInstance(); if (f == null || f.getClass().getName().indexOf("crimson") != -1) { throw new FatalException( CoreMessages.valueIsInvalidFor(f.getClass().getName(), "javax.xml.parsers.SAXParserFactory"), this); } }