Package mf.javax.xml.transform.sax

Examples of mf.javax.xml.transform.sax.SAXSource


      }
    }

    catalogManager.debug.message(2, "Resolved URI", href, result);

    SAXSource source = new SAXSource();
    source.setInputSource(new InputSource(result));
    setEntityResolver(source);
    return source;
  }
View Full Code Here


     */
   
    public void validate(Source source, Result result)
        throws SAXException, IOException {
        if (result instanceof SAXResult || result == null) {
            final SAXSource saxSource = (SAXSource) source;
            final SAXResult saxResult = (SAXResult) result;
           
            LexicalHandler lh = null;
            if (result != null) {
                ContentHandler ch = saxResult.getHandler();
                lh = saxResult.getLexicalHandler();
                /** If the lexical handler is not set try casting the ContentHandler. **/
                if (lh == null && ch instanceof LexicalHandler) {
                    lh = (LexicalHandler) ch;
                }
                setContentHandler(ch);
            }
           
            XMLReader reader = null;
            try {
                reader = saxSource.getXMLReader();
                if (reader == null) {
                    // create one now
                    SAXParserFactory spf = SAXParserFactory.newInstance();
                    spf.setNamespaceAware(true);
                    try {
                        reader = spf.newSAXParser().getXMLReader();
                        // If this is a Xerces SAX parser, set the security manager if there is one
                        if (reader instanceof mf.org.apache.xerces.parsers.SAXParser) {
                            Object securityManager = fComponentManager.getProperty(SECURITY_MANAGER);
                            if (securityManager != null) {
                                try {
                                    reader.setProperty(SECURITY_MANAGER, securityManager);
                                }
                                // Ignore the exception if the security manager cannot be set.
                                catch (SAXException exc) {}
                            }
                        }
                    }
                    catch (Exception e) {
                        // this is impossible, but better safe than sorry
                        throw new FactoryConfigurationError(e);
                    }
                }
               
                // If XML names and Namespace URIs are already internalized we
                // can avoid running them through the SymbolTable.
                try {
                    fStringsInternalized = reader.getFeature(STRING_INTERNING);
                }
                catch (SAXException exc) {
                    // The feature isn't recognized or getting it is not supported.
                    // In either case, assume that strings are not internalized.
                    fStringsInternalized = false;
                }
               
                ErrorHandler errorHandler = fComponentManager.getErrorHandler();
                reader.setErrorHandler(errorHandler != null ? errorHandler : DraconianErrorHandler.getInstance());
                reader.setEntityResolver(fResolutionForwarder);
                fResolutionForwarder.setEntityResolver(fComponentManager.getResourceResolver());
                reader.setContentHandler(this);
                reader.setDTDHandler(this);
                try {
                    reader.setProperty(LEXICAL_HANDLER, lh);
                }
                // Ignore the exception if the lexical handler cannot be set.
                catch (SAXException exc) {}
               
                InputSource is = saxSource.getInputSource();
                reader.parse(is);
            }
            finally {
                // Release the reference to user's ContentHandler ASAP
                setContentHandler(null);
View Full Code Here

                xmlInputSource.setByteStream(inputStream);
                xmlInputSource.setCharacterStream(reader);              
                xmlInputSources[i] = xmlInputSource;
            }
            else if (source instanceof SAXSource) {
                SAXSource saxSource = (SAXSource) source;
                InputSource inputSource = saxSource.getInputSource();
                if (inputSource == null) {
                    throw new SAXException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
                            "SAXSourceNullInputSource", null));
                }
                xmlInputSources[i] = new SAXInputSource(saxSource.getXMLReader(), inputSource);
            }
            else if (source instanceof DOMSource) {
                DOMSource domSource = (DOMSource) source;
                //MF
                Node node = (Node) domSource.getNode();
View Full Code Here

           mue);
  }
      }
    }

    SAXSource source = new SAXSource();
    source.setInputSource(new InputSource(result));
    return source;
  }
View Full Code Here

TOP

Related Classes of mf.javax.xml.transform.sax.SAXSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.