use of org.xml.sax.SAXNotSupportedException in project che by eclipse.
the class RefactoringSessionReader method createParser.
/**
* Creates a new parser from the specified factory.
*
* @param factory
* the parser factoring to use
* @return the created parser
* @throws ParserConfigurationException
* if no parser is available with the given configuration
* @throws SAXException
* if an error occurs while creating the parser
*/
private SAXParser createParser(final SAXParserFactory factory) throws ParserConfigurationException, SAXException {
final SAXParser parser = factory.newSAXParser();
final XMLReader reader = parser.getXMLReader();
try {
//$NON-NLS-1$
reader.setFeature("http://xml.org/sax/features/validation", false);
//$NON-NLS-1$
reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
} catch (SAXNotRecognizedException exception) {
// Do nothing
} catch (SAXNotSupportedException exception) {
// Do nothing
}
return parser;
}
use of org.xml.sax.SAXNotSupportedException in project zm-mailbox by Zimbra.
the class W3cDomUtil method getDom4jSAXParserWhichUsesSecureProcessing.
public static SAXParser getDom4jSAXParserWhichUsesSecureProcessing() throws XmlParseException {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setXIncludeAware(false);
factory.setValidating(false);
try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
} catch (SAXNotRecognizedException | SAXNotSupportedException | ParserConfigurationException ex) {
ZimbraLog.misc.error("Problem setting up SAXParser which supports secure XML processing", ex);
throw XmlParseException.PARSE_ERROR();
}
try {
return factory.newSAXParser();
} catch (ParserConfigurationException | SAXException e) {
ZimbraLog.misc.error("Problem setting up SAXParser", e);
throw XmlParseException.PARSE_ERROR();
}
}
use of org.xml.sax.SAXNotSupportedException in project aries by apache.
the class AbstractModelBuilder method parse.
private BeansModel parse(List<URL> osgiBeansDescriptorURLs, List<URL> beanDescriptorURLs) {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);
if (osgiBeansDescriptorURLs.isEmpty()) {
throw new IllegalArgumentException("Missing osgi-beans descriptors");
}
SAXParser parser;
try {
parser = factory.newSAXParser();
} catch (ParserConfigurationException | SAXException e) {
return Throw.exception(e);
}
OSGiBeansHandler handler = getHandler(beanDescriptorURLs);
for (URL osgiBeansDescriptorURL : osgiBeansDescriptorURLs) {
try (InputStream inputStream = osgiBeansDescriptorURL.openStream()) {
InputSource source = new InputSource(inputStream);
if (source.getByteStream().available() == 0) {
throw new IllegalArgumentException("Specified osgi-beans descriptor is empty: " + osgiBeansDescriptorURL);
}
try {
parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", loadXsds());
} catch (IllegalArgumentException | SAXNotRecognizedException | SAXNotSupportedException e) {
// No op, we just don't validate the XML
}
parser.parse(source, handler);
} catch (IOException | SAXException e) {
return Throw.exception(e);
}
}
return handler.createBeansModel();
}
use of org.xml.sax.SAXNotSupportedException in project robovm by robovm.
the class SAXNotSupportedExceptionTest method testSAXNotSupportedException.
public void testSAXNotSupportedException() {
SAXNotSupportedException e = new SAXNotSupportedException();
assertNull(e.getMessage());
}
use of org.xml.sax.SAXNotSupportedException in project robovm by robovm.
the class ExpatReader method parse.
public void parse(InputSource input) throws IOException, SAXException {
if (processNamespacePrefixes && processNamespaces) {
/*
* Expat has XML_SetReturnNSTriplet, but that still doesn't
* include xmlns attributes like this feature requires. We may
* have to implement namespace processing ourselves if we want
* this (not too difficult). We obviously "support" namespace
* prefixes if namespaces are disabled.
*/
throw new SAXNotSupportedException("The 'namespace-prefix' " + "feature is not supported while the 'namespaces' " + "feature is enabled.");
}
// Try the character stream.
Reader reader = input.getCharacterStream();
if (reader != null) {
try {
parse(reader, input.getPublicId(), input.getSystemId());
} finally {
IoUtils.closeQuietly(reader);
}
return;
}
// Try the byte stream.
InputStream in = input.getByteStream();
String encoding = input.getEncoding();
if (in != null) {
try {
parse(in, encoding, input.getPublicId(), input.getSystemId());
} finally {
IoUtils.closeQuietly(in);
}
return;
}
String systemId = input.getSystemId();
if (systemId == null) {
throw new SAXException("No input specified.");
}
// Try the system id.
in = ExpatParser.openUrl(systemId);
try {
parse(in, encoding, input.getPublicId(), systemId);
} finally {
IoUtils.closeQuietly(in);
}
}
Aggregations