Search in sources :

Example 26 with SAXNotSupportedException

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 }));
        }
    }
}
Also used : SAXNotSupportedException(org.xml.sax.SAXNotSupportedException) SecurityManager(org.apache.xerces.util.SecurityManager) XMLConfigurationException(org.apache.xerces.xni.parser.XMLConfigurationException) SAXNotRecognizedException(org.xml.sax.SAXNotRecognizedException)

Example 27 with SAXNotSupportedException

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();
    }
}
Also used : SAXNotSupportedException(org.xml.sax.SAXNotSupportedException) RDFHandlerException(org.eclipse.rdf4j.rio.RDFHandlerException) SAXParseException(org.xml.sax.SAXParseException) SAXNotRecognizedException(org.xml.sax.SAXNotRecognizedException) XMLReader(org.xml.sax.XMLReader) SAXNotSupportedException(org.xml.sax.SAXNotSupportedException) SAXNotRecognizedException(org.xml.sax.SAXNotRecognizedException) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException) RDFHandlerException(org.eclipse.rdf4j.rio.RDFHandlerException) IOException(java.io.IOException) SAXParseException(org.xml.sax.SAXParseException) SAXException(org.xml.sax.SAXException) SAXException(org.xml.sax.SAXException) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException)

Example 28 with SAXNotSupportedException

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;
}
Also used : InputSource(org.xml.sax.InputSource) SAXNotSupportedException(org.xml.sax.SAXNotSupportedException) XMLContext(org.hibernate.cfg.annotations.reflection.XMLContext) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) SAXReader(org.dom4j.io.SAXReader) XMLHelper(org.hibernate.internal.util.xml.XMLHelper) ErrorLogger(org.hibernate.internal.util.xml.ErrorLogger)

Example 29 with SAXNotSupportedException

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);
}
Also used : InputSource(org.xml.sax.InputSource) SAXNotSupportedException(org.xml.sax.SAXNotSupportedException) XMLContext(org.hibernate.cfg.annotations.reflection.XMLContext) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) SAXReader(org.dom4j.io.SAXReader) IOException(java.io.IOException) XMLHelper(org.hibernate.internal.util.xml.XMLHelper) ErrorLogger(org.hibernate.internal.util.xml.ErrorLogger) Test(org.junit.Test)

Example 30 with SAXNotSupportedException

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());
}
Also used : SAXNotSupportedException(org.xml.sax.SAXNotSupportedException)

Aggregations

SAXNotSupportedException (org.xml.sax.SAXNotSupportedException)33 SAXNotRecognizedException (org.xml.sax.SAXNotRecognizedException)25 XMLReader (org.xml.sax.XMLReader)16 SAXException (org.xml.sax.SAXException)13 SAXParser (javax.xml.parsers.SAXParser)9 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)8 SAXParserFactory (javax.xml.parsers.SAXParserFactory)8 InputSource (org.xml.sax.InputSource)7 IOException (java.io.IOException)6 InputStream (java.io.InputStream)5 SAXSource (javax.xml.transform.sax.SAXSource)4 BufferedInputStream (java.io.BufferedInputStream)3 Reader (java.io.Reader)2 JAXBContext (javax.xml.bind.JAXBContext)2 JAXBElement (javax.xml.bind.JAXBElement)2 JAXBException (javax.xml.bind.JAXBException)2 Unmarshaller (javax.xml.bind.Unmarshaller)2 Source (javax.xml.transform.Source)2 Transformer (javax.xml.transform.Transformer)2 DOMSource (javax.xml.transform.dom.DOMSource)2