/** * <p> * Get the 'correct' implementation of a JAXP <code>SAXParserFactory</code>; this is * intended to ensure that local implementations (e.g., Crimson) don't sneak into * the mix. * </p> * @return the Xerces-specific implementaiton */ public static SAXParserFactory getSAXParserFactory() { return new SAXParserFactoryImpl(); }
/** * Get XMLReader. * * @return the XMLReader value * @throws WSIException if there are problems getting the XMLReader * implementation. */ public static XMLReader getXMLReader() throws WSIException { XMLReader xmlReader = null; try { xmlReader = (new org.apache.xerces.jaxp.SAXParserFactoryImpl()) .newSAXParser().getXMLReader(); // Set namespace aware xmlReader.setFeature(FEATURE_NAMESPACE_PREFIXES, true); xmlReader.setFeature(FEATURE_NAMESPACES, true); } catch (Exception e) { throw new WSIException("Could not get XMLReader implementation.", e); } return xmlReader; }
/** * returns the particular property requested for in the underlying * implementation of org.xml.sax.XMLReader. */ public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException { if (name == null) { throw new NullPointerException(); } if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { return fSecureProcess; } else if (name.equals(NAMESPACES_FEATURE)) { return isNamespaceAware(); } else if (name.equals(VALIDATION_FEATURE)) { return isValidating(); } else if (name.equals(XINCLUDE_FEATURE)) { return isXIncludeAware(); } // Check for valid name by creating a dummy XMLReader to get // feature value return newSAXParserImpl().getXMLReader().getFeature(name); }
xmlReader.setFeature0(NAMESPACES_FEATURE, spf.isNamespaceAware()); xmlReader.setFeature0(NAMESPACE_PREFIXES_FEATURE, !spf.isNamespaceAware()); if (spf.isXIncludeAware()) { xmlReader.setFeature0(XINCLUDE_FEATURE, true); if (spf.isValidating()) { fInitErrorHandler = new DefaultValidationErrorHandler(); xmlReader.setErrorHandler(fInitErrorHandler); fInitErrorHandler = xmlReader.getErrorHandler(); xmlReader.setFeature0(VALIDATION_FEATURE, spf.isValidating()); this.grammar = spf.getSchema(); if (grammar != null) { XMLParserConfiguration config = xmlReader.getXMLParserConfiguration();
XMLReader getXMLReader() throws ParserConfigurationException, SAXException { // create sax parser SAXParserFactory saxFactory = new org.apache.xerces.jaxp.SAXParserFactoryImpl(); saxFactory.setNamespaceAware(true); saxFactory.setValidating(false); try { saxFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); } catch (Exception ex) { Logger.getLogger(OdfPackage.class.getName()).log(Level.SEVERE, null, ex); } SAXParser parser = saxFactory.newSAXParser(); XMLReader xmlReader = parser.getXMLReader(); // More details at http://xerces.apache.org/xerces2-j/features.html#namespaces xmlReader.setFeature("http://xml.org/sax/features/namespaces", true); // More details at http://xerces.apache.org/xerces2-j/features.html#namespace-prefixes xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); // More details at http://xerces.apache.org/xerces2-j/features.html#xmlns-uris xmlReader.setFeature("http://xml.org/sax/features/xmlns-uris", true); return xmlReader; }
/** * Get XMLReader. * * @return the XMLReader value * @throws WSIException if there are problems getting the XMLReader * implementation. */ public static XMLReader getXMLReader() throws WSIException { XMLReader xmlReader = null; try { xmlReader = (new org.apache.xerces.jaxp.SAXParserFactoryImpl()) .newSAXParser().getXMLReader(); // Set namespace aware xmlReader.setFeature(FEATURE_NAMESPACE_PREFIXES, true); xmlReader.setFeature(FEATURE_NAMESPACES, true); } catch (Exception e) { throw new WSIException("Could not get XMLReader implementation.", e); } return xmlReader; }
public static XMLConformanceMapEntityResolver newInstance(XMLConformanceTest test) throws Exception { try { SAXParserFactory saxFactory = new SAXParserFactoryImpl(); saxFactory.setNamespaceAware(false); XMLReader xmlReader = saxFactory.newSAXParser().getXMLReader(); XMLConformanceMapEntityResolver resolver = new XMLConformanceMapEntityResolver(test.getEntityResolver()); xmlReader.setEntityResolver(resolver); xmlReader.parse(test.getUrl().toExternalForm()); return resolver; } catch(Exception e) { return null; } }
/** * Attaches the reader to the catalog. */ private void attachReaderToCatalog (Catalog catalog) { SAXParserFactory spf = new SAXParserFactoryImpl(); spf.setNamespaceAware(true); spf.setValidating(false); SAXCatalogReader saxReader = new SAXCatalogReader(spf); saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName, "catalog", "org.apache.xml.resolver.readers.OASISXMLCatalogReader"); catalog.addReader("application/xml", saxReader); } }
/** * Returns the SAXParserFactory used for constructing parsers. */ private SAXParserFactory createParserFactory() { SAXParserFactory factory = new SAXParserFactoryImpl(); factory.setXIncludeAware(getXIncludeSupported()); return factory; }
XMLReader getXMLReader() throws ParserConfigurationException, SAXException { SAXParserFactory saxFactory = new org.apache.xerces.jaxp.SAXParserFactoryImpl(); saxFactory.setNamespaceAware(true); saxFactory.setValidating(false);
XMLReader getXMLReader() throws ParserConfigurationException, SAXException { SAXParserFactory saxFactory = new org.apache.xerces.jaxp.SAXParserFactoryImpl(); saxFactory.setNamespaceAware(true); saxFactory.setValidating(false);
SAXParserFactory saxFactory = new org.apache.xerces.jaxp.SAXParserFactoryImpl(); saxFactory.setNamespaceAware(true); saxFactory.setValidating(false);
try SAXParserFactory parserfactory = new SAXParserFactoryImpl(); parserfactory.setFeature(_APACHE_FEATURE_NAMESPACE_PREFIXES, true); parserfactory.setFeature(_APACHE_FEATURE_NAMESPACES, true);