public void parse(InputSource input) throws IOException, SAXException { try { reader.parse(input); } catch(SAXNotSupportedException e) { String message = e.getMessage(); if(message != null && message.contains("namespace-prefix")) { reader.setFeature(NAMESPACE_PREFIXES_FEATURE, false); reader.parse(input); } else { throw e; } } }
public void parse(InputSource input) throws IOException, SAXException { try { reader.parse(input); } catch(SAXNotSupportedException e) { String message = e.getMessage(); if(message != null && message.contains("namespace-prefix")) { reader.setFeature(NAMESPACE_PREFIXES_FEATURE, false); reader.parse(input); } else { throw e; } } }
public void parse (String systemId) throws IOException, SAXException { try { reader.parse(systemId); } catch(SAXNotSupportedException e) { String message = e.getMessage(); if(message != null && message.contains("namespace-prefix")) { reader.setFeature(NAMESPACE_PREFIXES_FEATURE, false); reader.parse(systemId); } else { throw e; } } }
public void parse (String systemId) throws IOException, SAXException { try { reader.parse(systemId); } catch(SAXNotSupportedException e) { String message = e.getMessage(); if(message != null && message.contains("namespace-prefix")) { reader.setFeature(NAMESPACE_PREFIXES_FEATURE, false); reader.parse(systemId); } else { throw e; } } }
/** create an xml parser, setup to validate using schema, register * appropriate schema locations, and an error handler * @param handler - handler to use * @param schemaLocations * @return */ private static XMLReader createParser(DefaultHandler handler,Map schemaLocations) { String locationString = mkSchemaLocationString(schemaLocations); try { XMLReader reader = XMLReaderFactory.createXMLReader(); reader.setFeature("http://xml.org/sax/features/validation",true); reader.setFeature("http://apache.org/xml/features/validation/schema",true); reader.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation",locationString); reader.setErrorHandler(handler); reader.setContentHandler(handler); return reader; } catch (SAXNotRecognizedException e) { fail("required features not rcognized by this xml parser " + e.getMessage()); } catch (SAXNotSupportedException e) { fail("required features not supported by this xml parser " + e.getMessage()); } catch (SAXException e) { fail("cannot create xml reader " + e.getMessage()); } throw new IllegalStateException("Cannot be reached"); } /** collapse the map into a space-separated string, suitable for passing to the parser */
public void setFeature(String name, boolean value) throws ParserConfigurationException { // If this is the secure processing feature, save it then return. if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { if (System.getSecurityManager() != null && (!value)) { throw new ParserConfigurationException( SAXMessageFormatter.formatMessage(null, "jaxp-secureprocessing-feature", null)); } fSecureProcess = value; return; } if (features == null) { features = new Hashtable(); } features.put(name, value ? Boolean.TRUE : Boolean.FALSE); // Test the feature by possibly throwing SAX exceptions try { new DocumentBuilderImpl(this, attributes, features); } catch (SAXNotSupportedException e) { features.remove(name); throw new ParserConfigurationException(e.getMessage()); } catch (SAXNotRecognizedException e) { features.remove(name); throw new ParserConfigurationException(e.getMessage()); } } }
public void setFeature(String name, boolean value) throws ParserConfigurationException { // If this is the secure processing feature, save it then return. if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { if (System.getSecurityManager() != null && (!value)) { throw new ParserConfigurationException( SAXMessageFormatter.formatMessage(null, "jaxp-secureprocessing-feature", null)); } fSecureProcess = value; return; } if (features == null) { features = new Hashtable(); } features.put(name, value ? Boolean.TRUE : Boolean.FALSE); // Test the feature by possibly throwing SAX exceptions try { new DocumentBuilderImpl(this, attributes, features); } catch (SAXNotSupportedException e) { features.remove(name); throw new ParserConfigurationException(e.getMessage()); } catch (SAXNotRecognizedException e) { features.remove(name); throw new ParserConfigurationException(e.getMessage()); } } }
throw new ParserConfigurationException(e.getMessage());
throw new PhylogenyParserException( "sax not supported exception: " + e.getMessage() );