use of org.xml.sax.SAXNotSupportedException in project iaf by ibissource.
the class XMLSchemaFactory method setFeature.
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
if (name == null) {
throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(), "FeatureNameNull", null));
}
if (name.startsWith(JAXP_SOURCE_FEATURE_PREFIX)) {
if (name.equals(StreamSource.FEATURE) || name.equals(SAXSource.FEATURE) || name.equals(DOMSource.FEATURE) || name.equals(StAXSource.FEATURE)) {
throw new SAXNotSupportedException(SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(), "feature-read-only", new Object[] { name }));
}
}
if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
fSecurityManager = value ? new SecurityManager() : null;
fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
return;
} else if (name.equals(USE_GRAMMAR_POOL_ONLY)) {
fUseGrammarPoolOnly = value;
return;
}
try {
fXMLSchemaLoader.setFeature(name, value);
} catch (XMLConfigurationException e) {
String identifier = e.getIdentifier();
if (e.getType() == XMLConfigurationException.NOT_RECOGNIZED) {
throw new SAXNotRecognizedException(SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(), "feature-not-recognized", new Object[] { identifier }));
} else {
throw new SAXNotSupportedException(SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(), "feature-not-supported", new Object[] { identifier }));
}
}
}
use of org.xml.sax.SAXNotSupportedException in project rdf4j by eclipse.
the class RDFXMLParser method parse.
private void parse(InputSource inputSource) throws IOException, RDFParseException, RDFHandlerException {
clear();
try {
documentURI = inputSource.getSystemId();
saxFilter.setParseStandAloneDocuments(getParserConfig().get(XMLParserSettings.PARSE_STANDALONE_DOCUMENTS));
// saxFilter.clear();
saxFilter.setDocumentURI(documentURI);
XMLReader xmlReader;
if (getParserConfig().isSet(XMLParserSettings.CUSTOM_XML_READER)) {
xmlReader = getParserConfig().get(XMLParserSettings.CUSTOM_XML_READER);
} else {
xmlReader = XMLReaderFactory.createXMLReader();
}
xmlReader.setContentHandler(saxFilter);
xmlReader.setErrorHandler(this);
// not explicitly set
for (RioSetting<Boolean> aSetting : getCompulsoryXmlFeatureSettings()) {
try {
xmlReader.setFeature(aSetting.getKey(), getParserConfig().get(aSetting));
} catch (SAXNotRecognizedException e) {
reportWarning(String.format("%s is not a recognized SAX feature.", aSetting.getKey()));
} catch (SAXNotSupportedException e) {
reportWarning(String.format("%s is not a supported SAX feature.", aSetting.getKey()));
}
}
// not explicitly set
for (RioSetting<?> aSetting : getCompulsoryXmlPropertySettings()) {
try {
xmlReader.setProperty(aSetting.getKey(), getParserConfig().get(aSetting));
} catch (SAXNotRecognizedException e) {
reportWarning(String.format("%s is not a recognized SAX property.", aSetting.getKey()));
} catch (SAXNotSupportedException e) {
reportWarning(String.format("%s is not a supported SAX property.", aSetting.getKey()));
}
}
// the parser config
for (RioSetting<Boolean> aSetting : getOptionalXmlFeatureSettings()) {
try {
if (getParserConfig().isSet(aSetting)) {
xmlReader.setFeature(aSetting.getKey(), getParserConfig().get(aSetting));
}
} catch (SAXNotRecognizedException e) {
reportWarning(String.format("%s is not a recognized SAX feature.", aSetting.getKey()));
} catch (SAXNotSupportedException e) {
reportWarning(String.format("%s is not a supported SAX feature.", aSetting.getKey()));
}
}
// the parser config
for (RioSetting<?> aSetting : getOptionalXmlPropertySettings()) {
try {
if (getParserConfig().isSet(aSetting)) {
xmlReader.setProperty(aSetting.getKey(), getParserConfig().get(aSetting));
}
} catch (SAXNotRecognizedException e) {
reportWarning(String.format("%s is not a recognized SAX property.", aSetting.getKey()));
} catch (SAXNotSupportedException e) {
reportWarning(String.format("%s is not a supported SAX property.", aSetting.getKey()));
}
}
xmlReader.parse(inputSource);
} catch (SAXParseException e) {
Exception wrappedExc = e.getException();
if (wrappedExc == null) {
reportFatalError(e, e.getLineNumber(), e.getColumnNumber());
} else {
reportFatalError(wrappedExc, e.getLineNumber(), e.getColumnNumber());
}
} catch (SAXException e) {
Exception wrappedExc = e.getException();
if (wrappedExc == null) {
reportFatalError(e);
} else if (wrappedExc instanceof RDFParseException) {
throw (RDFParseException) wrappedExc;
} else if (wrappedExc instanceof RDFHandlerException) {
throw (RDFHandlerException) wrappedExc;
} else {
reportFatalError(wrappedExc);
}
} finally {
// Clean up
saxFilter.clear();
xmlLang = null;
elementStack.clear();
usedIDs.clear();
clear();
}
}
use of org.xml.sax.SAXNotSupportedException in project hibernate-orm by hibernate.
the class JPAOverriddenAnnotationReaderTest method buildContext.
private XMLContext buildContext(String ormfile) throws SAXException, DocumentException, IOException {
XMLHelper xmlHelper = new XMLHelper(ClassLoaderServiceTestingImpl.INSTANCE);
InputStream is = ClassLoaderServiceTestingImpl.INSTANCE.locateResourceStream(ormfile);
assertNotNull("ORM.xml not found: " + ormfile, is);
XMLContext context = new XMLContext(BootstrapContextImpl.INSTANCE);
ErrorLogger errorLogger = new ErrorLogger();
SAXReader saxReader = xmlHelper.createSAXReader(errorLogger, EJB3DTDEntityResolver.INSTANCE);
// saxReader.setValidation( false );
try {
saxReader.setFeature("http://apache.org/xml/features/validation/schema", true);
} catch (SAXNotSupportedException e) {
saxReader.setValidation(false);
}
org.dom4j.Document doc;
try {
doc = saxReader.read(new InputSource(new BufferedInputStream(is)));
} finally {
is.close();
}
if (errorLogger.hasErrors()) {
System.out.println(errorLogger.getErrors().get(0));
}
assertFalse(errorLogger.hasErrors());
context.addDocument(doc);
return context;
}
use of org.xml.sax.SAXNotSupportedException in project hibernate-orm by hibernate.
the class XMLContextTest method testAll.
@Test
public void testAll() throws Exception {
final XMLHelper xmlHelper = new XMLHelper(ClassLoaderServiceTestingImpl.INSTANCE);
final XMLContext context = new XMLContext(BootstrapContextImpl.INSTANCE);
InputStream is = ClassLoaderServiceTestingImpl.INSTANCE.locateResourceStream("org/hibernate/test/annotations/reflection/orm.xml");
Assert.assertNotNull("ORM.xml not found", is);
final ErrorLogger errorLogger = new ErrorLogger();
final SAXReader saxReader = xmlHelper.createSAXReader(errorLogger, EJB3DTDEntityResolver.INSTANCE);
try {
saxReader.setFeature("http://apache.org/xml/features/validation/schema", true);
} catch (SAXNotSupportedException e) {
saxReader.setValidation(false);
}
org.dom4j.Document doc;
try {
doc = saxReader.read(new InputSource(new BufferedInputStream(is)));
} finally {
try {
is.close();
} catch (IOException ioe) {
// log.warn( "Could not close input stream", ioe );
}
}
Assert.assertFalse(errorLogger.hasErrors());
context.addDocument(doc);
}
use of org.xml.sax.SAXNotSupportedException in project j2objc by google.
the class SAXNotSupportedExceptionTest method testSAXNotSupportedException.
public void testSAXNotSupportedException() {
SAXNotSupportedException e = new SAXNotSupportedException();
assertNull(e.getMessage());
}
Aggregations