Package org.xml.sax

Examples of org.xml.sax.InputSource


            }
        }
        if ((url != null) && url.startsWith("jar:")) {
            return getLocalResource(url, url.substring(url.indexOf("!/") + 2));
        } else if ((url != null) && url.startsWith("file:")) {
            return new InputSource(url);
        } else {
            Logger.log(Logger.FULL_DEBUG, Launcher.RESOURCES,
                    "WebXmlParser.NoLocalResource", url);
            return new InputSource(url);
        }
    }
View Full Code Here


        }
    }

    private InputSource getLocalResource(String url, String local) {
        if (this.commonLoader.getResource(local) == null)
            return new InputSource(url);
        InputSource is = new InputSource(this.commonLoader.getResourceAsStream(local));
        is.setSystemId(url);
        return is;
    }
View Full Code Here

        outputDir = new File(dir);
    }

    void generateBean(String path) {
        System.out.println("Generating bean from resource : " + path);
        InputSource src = null;
        src = new InputSource(new File(path).toURI().toString());
       
        ConfigurationMetadataBuilder builder = new ConfigurationMetadataBuilder(false);
        builder.setValidation(true);
        ConfigurationMetadata model = null;
View Full Code Here

       
       
        WSDLFactory factory = WSDLFactory.newInstance();
        WSDLReader reader = factory.newWSDLReader();
        reader.setFeature("javax.wsdl.verbose", false);
        InputSource input = new InputSource(url.openStream());
        Definition def = reader.readWSDL(null, input);
        Port port = def.getService(new QName("http://objectweb.org/hello_world_rpclit",
                                             "SOAPServiceRPCLit1")).getPort("SoapPortRPCLit1");
        WSDLMetaDataCache wsdl = new WSDLMetaDataCache(def, port);
       
View Full Code Here

       
       
        WSDLFactory factory = WSDLFactory.newInstance();
        WSDLReader reader = factory.newWSDLReader();
        reader.setFeature("javax.wsdl.verbose", false);
        InputSource input = new InputSource(url.openStream());
        Definition def = reader.readWSDL(null, input);
        Port port = def.getService(new QName("http://objectweb.org/hello_world_doc_lit_bare",
                                             "SOAPService")).getPort("SoapPort");
        WSDLMetaDataCache wsdl = new WSDLMetaDataCache(def, port);
       
View Full Code Here

        elementDefinitions = new HashMap<String, QName>();
        typeDefinitions = new HashMap<String, String>();  
       
        LOG.fine("Creating type schema for namespace " + namespaceURI);

        InputSource is = getSchemaInputSource(baseURI, location);

        Document document = null;
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);
            DocumentBuilder parser = factory.newDocumentBuilder();
            document = parser.parse(is);
        } catch (ParserConfigurationException ex) {
            throw new ConfigurationException(new Message("PARSER_CONFIGURATION_ERROR_EXC",
                                                         LOG, location), ex);
        } catch (SAXException ex) {
            throw new ConfigurationException(new Message("PARSE_ERROR_EXC", LOG), ex);
        } catch (IOException ex) {
            throw new ConfigurationException(new Message("FILE_OPEN_ERROR_EXC", LOG, location), ex);
        }

        deserialize(document);

        Source src = new DOMSource(document);
        src.setSystemId(is.getSystemId());

        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        final LSResourceResolver oldResolver = factory.getResourceResolver();
    
        LSResourceResolver resolver = new LSResourceResolver() {

            public LSInput resolveResource(String type, String nsURI,
                                           String publicId, String systemId, String baseURI) {
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine("resolving resource type: " + type + "\n"
                            + "                   namespaceURI:" + nsURI + "\n"
                            + "                   publicId:" + publicId + "\n"
                            + "                   systemId:" + systemId + "\n"
                            + "                   baseURI:" + baseURI);
                }
               
                if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(type)) {
                    LSInput lsi = new SchemaInput(type, nsURI, publicId, systemId, baseURI);
                    String resourceName = systemId;
                   
                    InputSource src = getSchemaInputSource(baseURI, resourceName);
                    lsi.setByteStream(src.getByteStream());
                    lsi.setSystemId(src.getSystemId());
                    return lsi;
                }
                return oldResolver == null ? null
                    : oldResolver.resolveResource(type, nsURI, publicId, systemId, baseURI);
            }
View Full Code Here

                    Message msg = new Message("FILE_OPEN_ERROR_EXC", LOG, location);
                    throw new ConfigurationException(msg);
                }
                File file = new File(path);
                if (file.exists()) {
                    return new InputSource(file.toURI().toString());
                }
            } else {
                //TODO - other protocols like HTTP?               
            }
        }
       
        // uri path is a system resource            
        URL url = DefaultResourceManager.instance().resolveResource(location, URL.class);
        if (null != url) {
            return new InputSource(url.toString());
        }
       
        //ok, try URL resolving
        if (baseURI != null) {
            try {
                url = new URL(baseURI);
                url = new URL(url, location);
                InputStream ins = url.openStream();
                if (ins != null) {
                    InputSource src = new InputSource(ins);
                    src.setSystemId(url.toString());
                    return src;
                }
            } catch (MalformedURLException e) {
                //ignore
            } catch (IOException e) {
View Full Code Here

        parseXML(is);
        return model;
    }

    public ConfigurationMetadata build(InputStream is) throws IOException {
        return build(new InputSource(is));
    }
View Full Code Here

        throws Exception
    {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        builder.setEntityResolver(new XslTransformerEntityResolver(url));
        return builder.parse(new InputSource(url));
    }
View Full Code Here

        public InputSource resolveEntity(
            final String publicId,
            final String systemId)
            throws SAXException, IOException
        {
            InputSource source = null;
            String path = systemId;
            if (path != null && path.startsWith(SYSTEM_ID_FILE))
            {
                final String xmlResource = this.xmlDocument;
                path = path.replaceFirst(
                        SYSTEM_ID_FILE,
                        "");

                // - remove any extra starting slashes
                path = path.replaceAll(
                        "\\+",
                        "/").replaceAll(
                        "/+",
                        "/");

                // - if we still have one starting slash, remove it
                if (path.startsWith("/"))
                {
                    path = path.substring(
                            1,
                            path.length());
                }
                final String xmlResourceName = xmlResource.replaceAll(
                        ".*(\\+|/)",
                        "");
                URL uri = null;
                InputStream inputStream = null;
                uri = new File(StringUtils.replace(
                            xmlResource,
                            xmlResourceName,
                            path)).toURL();
                if (uri != null)
                {
                    inputStream = uri.openStream();
                }
                if (inputStream != null)
                {
                    source = new InputSource(inputStream);
                    source.setPublicId(publicId);
                    source.setSystemId(uri.toString());
                }
            }
            return source;
        }
View Full Code Here

TOP

Related Classes of org.xml.sax.InputSource

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.