Package org.apache.xerces.xni.parser

Examples of org.apache.xerces.xni.parser.XMLInputSource


     */
    public ASModel parseASInputSource(DOMInput is)
                                      throws DOMASException, Exception {
                                     
        // need to wrap the DOMInput with an XMLInputSource
        XMLInputSource xis = this.dom2xmlInputSource(is);
        try {
            return parseASInputSource(xis);
        }
        catch (XNIException e) {
            Exception ex = e.getException();
View Full Code Here


                null,
                href,
                fDocLocation.getBaseSystemId(),
                null);

        XMLInputSource includedSource = null;
        if (fEntityResolver != null) {
            try {
                includedSource =
                    fEntityResolver.resolveEntity(resourceIdentifier);
            }
            catch (IOException e) {
                throw new XIncludeResourceError(
                    "XMLResourceError",
                    new Object[] { e.getMessage()});
            }
        }

        if (includedSource == null) {
            includedSource =
                new XMLInputSource(null, href, fDocLocation.getBaseSystemId());
        }

        if (parse.equals(XINCLUDE_PARSE_XML)) {
            // Instead of always creating a new configuration, the first one can be reused
            if (fChildConfig == null) {
                String parserName = XINCLUDE_DEFAULT_CONFIGURATION;

                fChildConfig =
                    (XMLParserConfiguration)ObjectFactory.newInstance(
                        parserName,
                        ObjectFactory.findClassLoader(),
                        true);

                // use the same error reporter
                // REVISIT: see setErrorReporter()
                fChildConfig.setProperty(ERROR_REPORTER, fErrorReporter);
                // use the same namespace context
                fChildConfig.setProperty(
                    Constants.XERCES_PROPERTY_PREFIX
                        + Constants.NAMESPACE_CONTEXT_PROPERTY,
                    fNamespaceContext);

                XIncludeHandler newHandler =
                    (XIncludeHandler)fChildConfig.getProperty(
                        Constants.XERCES_PROPERTY_PREFIX
                            + Constants.XINCLUDE_HANDLER_PROPERTY);
                newHandler.setParent(this);
                newHandler.setDocumentHandler(this.getDocumentHandler());
            }

            // set all features on parserConfig to match this parser configuration
            copyFeatures(fSettings, fChildConfig);

            // we don't want a schema validator on the new pipeline,
            // so we set it to false, regardless of what was copied above
            fChildConfig.setFeature(
                Constants.XERCES_FEATURE_PREFIX
                    + Constants.SCHEMA_VALIDATION_FEATURE,
                false);

            try {
                fNamespaceContext.pushScope();
                fChildConfig.parse(includedSource);
            }
            catch (XIncludeFatalError e) {
                reportFatalError(e.getKey(), e.getArgs());
            }
            catch (XNIException e) {
                reportFatalError("XMLParseError");
            }
            catch (IOException e) {
                throw new XIncludeResourceError(
                    "XMLResourceError",
                    new Object[] { e.getMessage()});
            }
            finally {
                fNamespaceContext.popScope();
            }
        }
        else if (parse.equals(XINCLUDE_PARSE_TEXT)) {
            String encoding = attributes.getValue(XINCLUDE_ATTR_ENCODING);
            includedSource.setEncoding(encoding);

            XIncludeTextReader reader = null;
            try {
                reader = new XIncludeTextReader(includedSource, this);
                reader.parse();
View Full Code Here

    public void unlockGrammarPool() {
        super.fGrammarPool.unlockPool();
    }

    public Grammar parseGrammar(String s, String s1) throws XNIException, IOException {
        XMLInputSource xmlinputsource = new XMLInputSource(null, s1, null);
        return parseGrammar(s, xmlinputsource);
    }
View Full Code Here

        public void put(URI uri, byte[] bytes) {
            _schemas.put(uri.toASCIIString(), bytes);
        }
       
        public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
            XMLInputSource src = new XMLInputSource(resourceIdentifier);
            String location = "";
            if (resourceIdentifier.getNamespace() != null && _schemas.get(resourceIdentifier.getNamespace()) != null)
                location = resourceIdentifier.getNamespace();
            else if (resourceIdentifier.getLiteralSystemId() != null && _schemas.get(resourceIdentifier.getLiteralSystemId()) != null)
                location = resourceIdentifier.getLiteralSystemId();

            src.setByteStream(new ByteArrayInputStream(_schemas.get(location)));
            return src;
        }
View Full Code Here

        public void put(URI uri, byte[] bytes) {
            _schemas.put(uri.toASCIIString(), bytes);
        }
       
        public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException {
            XMLInputSource src = new XMLInputSource(resourceIdentifier);
            String location = "";
            if (resourceIdentifier.getNamespace() != null && _schemas.get(resourceIdentifier.getNamespace()) != null)
                location = resourceIdentifier.getNamespace();
            else if (resourceIdentifier.getLiteralSystemId() != null && _schemas.get(resourceIdentifier.getLiteralSystemId()) != null)
                location = resourceIdentifier.getLiteralSystemId();
            else if (resourceIdentifier.getBaseSystemId() != null && _schemas.get(resourceIdentifier.getBaseSystemId()) != null)
                location = resourceIdentifier.getBaseSystemId();

            src.setByteStream(new ByteArrayInputStream(_schemas.get(location)));
            return src;
        }
View Full Code Here

            throws XNIException, IOException {

        if (__log.isDebugEnabled())
            __log.debug("resolveEntity(" + resourceIdentifier + ")");

        XMLInputSource src = new XMLInputSource(resourceIdentifier);
        URI location;

        if (resourceIdentifier.getLiteralSystemId() == null) {
            // import without schemaLocation
            if (__log.isDebugEnabled()) __log.debug("resolveEntity: no schema location for "+resourceIdentifier.getNamespace());
            return null;
        } else if (resourceIdentifier.getExpandedSystemId() != null) {
            // schema imported by other schema
            location = _baseURI.resolve(resourceIdentifier.getExpandedSystemId());
        } else {
            location = _baseURI.resolve(resourceIdentifier.getLiteralSystemId());
        }

        if (__log.isDebugEnabled())
            __log.debug("resolveEntity: Expecting to find " + resourceIdentifier.getNamespace()
                    + " at " + location);

        if (_internalSchemas.get(location) != null) {
            src.setByteStream(new ByteArrayInputStream(_internalSchemas.get(location).getBytes()));
            return src;
        }

        try {
            InputStream str = _wsdlFinder.openResource(location);
            if (str != null)
                src.setByteStream(str);
            else {
                __log.debug("resolveEntity: resource not found: " + location);
                throw new IOException("Resource not found: " + location);
            }
        } catch (IOException ioex) {
View Full Code Here

     * @return a List of strings giving the uri's of the newly defined datatypes
     * @throws DatatypeFormatException if there is a problem during load (not that we use Xerces
     * in default mode for load which may provide diagnostic output direct to stderr)
     */
    public static List<String> loadUserDefined(String uri, Reader reader, String encoding, TypeMapper tm) throws DatatypeFormatException {
        return loadUserDefined(new XMLInputSource(null, uri, uri, reader, encoding), tm);
    }
View Full Code Here

     * @return a List of strings giving the uri's of the newly defined datatypes
     * @throws DatatypeFormatException if there is a problem during load (not that we use Xerces
     * in default mode for load which may provide diagnostic output direct to stderr)
     */
    public static List<String> loadUserDefined(String uri, String encoding, TypeMapper tm) throws DatatypeFormatException {
        return loadUserDefined(new XMLInputSource(null, uri, uri), tm);
    }
View Full Code Here

            if (resourceContent instanceof byte[]) {
                try {
                    InputStream in = new ByteArrayInputStream((byte[]) resourceContent);
                    if (!disableSchemaValidation) {
                        validationInfo =
                                SchemaValidator.validate(new XMLInputSource(null, null, null, in,
                                        null));
                    }
                } catch (Exception e) {
                    throw new RegistryException("Exception occured while validating the schema" , e);
                }
View Full Code Here

            }
            WSDLValidationInfo validationInfo = null;
            try {
                if (!disableSchemaValidation) {
                    validationInfo =
                            SchemaValidator.validate(new XMLInputSource(null, sourceURL, null));
                }
            } catch (Exception e) {
                throw new RegistryException("Exception occured while validating the schema" , e);
            }
View Full Code Here

TOP

Related Classes of org.apache.xerces.xni.parser.XMLInputSource

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.