Package org.apache.ws.commons.schema

Examples of org.apache.ws.commons.schema.XmlSchemaException


        // XXX: If we return null, a NPE is raised in SchemaBuilder.
        // If we return new InputSource(), a XmlSchemaException is raised
        // but without any nice error message. So let's just throw a nice error here.
        if (in == null) {
            throw new XmlSchemaException("Unable to locate imported document "
                                         + "at '" + schemaLocation + "'"
                                         + (baseUri == null
                                            ? "."
                                            : ", relative to '" + baseUri + "'."));
        } else if (in.getByteStream() != null) {
            //workaround bug in XmlSchema - XmlSchema is not closing the InputStreams
            //that are returned for imports.  Thus, with a lot of services starting up
            //or a lot of schemas imported or similar, it's easy to run out of
            //file handles.  We'll just load the file into a byte[] and return that.
            try {
                InputStream ins = IOUtils.loadIntoBAIS(in.getByteStream());
                in.setByteStream(ins);
            } catch (IOException e) {
                throw new XmlSchemaException("Unable to load imported document "
                                             + "at '" + schemaLocation + "'"
                                             + (baseUri == null
                                                ? "."
                                                : ", relative to '" + baseUri + "'."),
                                                e);
View Full Code Here


        // XXX: If we return null, a NPE is raised in SchemaBuilder.
        // If we return new InputSource(), a XmlSchemaException is raised
        // but without any nice error message. So let's just throw a nice error here.
        if (in == null) {
            throw new XmlSchemaException("Unable to locate imported document "
                                         + "at '" + schemaLocation + "'"
                                         + (baseUri == null
                                            ? "."
                                            : ", relative to '" + baseUri + "'."));
        } else if (in.getByteStream() != null
            && !(in.getByteStream() instanceof ByteArrayInputStream)) {
            //workaround bug in XmlSchema - XmlSchema is not closing the InputStreams
            //that are returned for imports.  Thus, with a lot of services starting up
            //or a lot of schemas imported or similar, it's easy to run out of
            //file handles.  We'll just load the file into a byte[] and return that.
            try {
                InputStream ins = IOUtils.loadIntoBAIS(in.getByteStream());
                in.setByteStream(ins);
            } catch (IOException e) {
                throw new XmlSchemaException("Unable to load imported document "
                                             + "at '" + schemaLocation + "'"
                                             + (baseUri == null
                                                ? "."
                                                : ", relative to '" + baseUri + "'."),
                                                e);
View Full Code Here

        // XXX: If we return null, a NPE is raised in SchemaBuilder.
        // If we return new InputSource(), a XmlSchemaException is raised
        // but without any nice error message. So let's just throw a nice error here.
        if (in == null) {
            throw new XmlSchemaException("Unable to locate imported document "
                                         + "at '" + schemaLocation + "'"
                                         + (baseUri == null
                                            ? "."
                                            : ", relative to '" + baseUri + "'."));
        } else if (in.getByteStream() != null
            && !(in.getByteStream() instanceof ByteArrayInputStream)) {
            //workaround bug in XmlSchema - XmlSchema is not closing the InputStreams
            //that are returned for imports.  Thus, with a lot of services starting up
            //or a lot of schemas imported or similar, it's easy to run out of
            //file handles.  We'll just load the file into a byte[] and return that.
            try {
                InputStream ins = IOUtils.loadIntoBAIS(in.getByteStream());
                in.setByteStream(ins);
            } catch (IOException e) {
                throw new XmlSchemaException("Unable to load imported document "
                                             + "at '" + schemaLocation + "'"
                                             + (baseUri == null
                                                ? "."
                                                : ", relative to '" + baseUri + "'."),
                                                e);
View Full Code Here

        // XXX: If we return null, a NPE is raised in SchemaBuilder.
        // If we return new InputSource(), a XmlSchemaException is raised
        // but without any nice error message. So let's just throw a nice error here.
        if (in == null) {
            throw new XmlSchemaException("Unable to locate imported document "
                                         + "at '" + schemaLocation + "'"
                                         + (baseUri == null
                                            ? "."
                                            : ", relative to '" + baseUri + "'."));
        }
View Full Code Here

        // XXX: If we return null, a NPE is raised in SchemaBuilder.
        // If we return new InputSource(), a XmlSchemaException is raised
        // but without any nice error message. So let's just throw a nice error here.
        if (in == null) {
            throw new XmlSchemaException("Unable to locate imported document "
                                         + "at '" + schemaLocation + "'"
                                         + (baseUri == null
                                            ? "."
                                            : ", relative to '" + baseUri + "'."));
        } else if (in.getByteStream() != null) {
            //workaround bug in XmlSchema - XmlSchema is not closing the InputStreams
            //that are returned for imports.  Thus, with a lot of services starting up
            //or a lot of schemas imported or similar, it's easy to run out of
            //file handles.  We'll just load the file into a byte[] and return that.
            try {
                InputStream ins = IOUtils.loadIntoBAIS(in.getByteStream());
                in.setByteStream(ins);
            } catch (IOException e) {
                throw new XmlSchemaException("Unable to load imported document "
                                             + "at '" + schemaLocation + "'"
                                             + (baseUri == null
                                                ? "."
                                                : ", relative to '" + baseUri + "'."),
                                                e);
View Full Code Here

        // XXX: If we return null, a NPE is raised in SchemaBuilder.
        // If we return new InputSource(), a XmlSchemaException is raised
        // but without any nice error message. So let's just throw a nice error here.
        if (in == null) {
            throw new XmlSchemaException("Unable to locate imported document "
                                         + "at '" + schemaLocation + "'"
                                         + (baseUri == null
                                            ? "."
                                            : ", relative to '" + baseUri + "'."));
        } else if (in.getByteStream() != null) {
            //workaround bug in XmlSchema - XmlSchema is not closing the InputStreams
            //that are returned for imports.  Thus, with a lot of services starting up
            //or a lot of schemas imported or similar, it's easy to run out of
            //file handles.  We'll just load the file into a byte[] and return that.
            try {
                InputStream ins = IOUtils.loadIntoBAIS(in.getByteStream());
                in.setByteStream(ins);
            } catch (IOException e) {
                throw new XmlSchemaException("Unable to load imported document "
                                             + "at '" + schemaLocation + "'"
                                             + (baseUri == null
                                                ? "."
                                                : ", relative to '" + baseUri + "'."),
                                                e);
View Full Code Here

        // XXX: If we return null, a NPE is raised in SchemaBuilder.
        // If we return new InputSource(), a XmlSchemaException is raised
        // but without any nice error message. So let's just throw a nice error here.
        if (in == null) {
            throw new XmlSchemaException("Unable to locate imported document "
                                         + "at '" + schemaLocation + "'"
                                         + (baseUri == null
                                            ? "."
                                            : ", relative to '" + baseUri + "'."));
        } else if (in.getByteStream() != null) {
            //workaround bug in XmlSchema - XmlSchema is not closing the InputStreams
            //that are returned for imports.  Thus, with a lot of services starting up
            //or a lot of schemas imported or similar, it's easy to run out of
            //file handles.  We'll just load the file into a byte[] and return that.
            try {
                InputStream ins = IOUtils.loadIntoBAIS(in.getByteStream());
                in.setByteStream(ins);
            } catch (IOException e) {
                throw new XmlSchemaException("Unable to load imported document "
                                             + "at '" + schemaLocation + "'"
                                             + (baseUri == null
                                                ? "."
                                                : ", relative to '" + baseUri + "'."),
                                                e);
View Full Code Here

            InputStream is = location.openStream();
            schema = collection.read(new InputStreamReader(is), null);
            is.close();
        }
        if (namespace != null && schema != null && !namespace.equals(schema.getTargetNamespace())) {
            throw new XmlSchemaException(namespace + " != " + schema.getTargetNamespace());
        }
        return schema;
    }
View Full Code Here

    }

    public XmlSchema loadSchema(String schemaLocation, ClassLoader classLoader) throws IOException, XmlSchemaException {
        int index = schemaLocation.indexOf(' ');
        if (index == -1) {
            throw new XmlSchemaException("Invalid schemaLocation: " + schemaLocation);
        }
        String namespace = schemaLocation.substring(0, index).trim();
        URL url;
        URI uri;
        try {
            uri = new URI(schemaLocation.substring(index + 1).trim());
        } catch (URISyntaxException e) {
            throw new XmlSchemaException("Invalid schemaLocation: " + schemaLocation);
        }
        if (uri.isAbsolute()) {
            url = uri.toURL();
        } else {
            url = classLoader.getResource(uri.toString());
            if (url == null) {
                throw new XmlSchemaException("Resource cannot be resolved: schemaLocation: " + schemaLocation);
            }
        }
        return loadSchema(namespace, url);
    }
View Full Code Here

        // XXX: If we return null, a NPE is raised in SchemaBuilder.
        // If we return new InputSource(), a XmlSchemaException is raised
        // but without any nice error message. So let's just throw a nice error here.
        if (in == null) {
            throw new XmlSchemaException("Unable to locate imported document "
                                         + "at '" + schemaLocation + "'"
                                         + (baseUri == null
                                            ? "."
                                            : ", relative to '" + baseUri + "'."));
        } else if (in.getByteStream() != null
            && !(in.getByteStream() instanceof ByteArrayInputStream)) {
            //workaround bug in XmlSchema - XmlSchema is not closing the InputStreams
            //that are returned for imports.  Thus, with a lot of services starting up
            //or a lot of schemas imported or similar, it's easy to run out of
            //file handles.  We'll just load the file into a byte[] and return that.
            try {
                InputStream ins = IOUtils.loadIntoBAIS(in.getByteStream());
                in.setByteStream(ins);
            } catch (IOException e) {
                throw new XmlSchemaException("Unable to load imported document "
                                             + "at '" + schemaLocation + "'"
                                             + (baseUri == null
                                                ? "."
                                                : ", relative to '" + baseUri + "'."),
                                                e);
View Full Code Here

TOP

Related Classes of org.apache.ws.commons.schema.XmlSchemaException

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.