Package org.w3c.dom.ls

Examples of org.w3c.dom.ls.LSInput


        throws XNIException, IOException {
        // resolve entity using DOM entity resolver
        if (fEntityResolver != null) {
            // For entity resolution the type of the resource would be  XML TYPE
            // DOM L3 LS spec mention only the XML 1.0 recommendation right now
            LSInput inputSource =
                resourceIdentifier == null
                    ? fEntityResolver.resolveResource(
                        null,
                        null,
                        null,
                        null,
                        null)
                    : fEntityResolver.resolveResource(
                        getType(resourceIdentifier),
                        resourceIdentifier.getNamespace(),
                        resourceIdentifier.getPublicId(),
                        resourceIdentifier.getLiteralSystemId(),
                        resourceIdentifier.getBaseSystemId());
            if (inputSource != null) {
                String publicId = inputSource.getPublicId();
                String systemId = inputSource.getSystemId();
                String baseSystemId = inputSource.getBaseURI();
                InputStream byteStream = inputSource.getByteStream();
                Reader charStream = inputSource.getCharacterStream();
                String encoding = inputSource.getEncoding();
                String data = inputSource.getStringData();

                /**
                 * An LSParser looks at inputs specified in LSInput in
                 * the following order: characterStream, byteStream,
                 * stringData, systemId, publicId.
View Full Code Here


        NSFILEMAP.put(ToolConstants.WSDL_NAMESPACE_URI, "wsdl.xsd");
        NSFILEMAP.put(ToolConstants.SCHEMA_URI, "XMLSchema.xsd");
    }
    public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId,
            String baseURI) {
        LSInput lsin = null;
        String resURL = null;
        String localFile = null;
        if (systemId != null) {
            String schemaLocation = "";
            if (baseURI != null) {
                schemaLocation = baseURI.substring(0, baseURI.lastIndexOf("/") + 1);
            }
            if (systemId.indexOf("http://") < 0) {
                resURL = schemaLocation + systemId;
            } else {
                resURL = systemId;
            }
        } else if (namespaceURI != null) {
            resURL = namespaceURI;
        }
       
        if (resURL != null && resURL.startsWith("http://")) {
            String filename = NSFILEMAP.get(resURL);
            if (filename != null) {
                localFile = ToolConstants.CXF_SCHEMAS_DIR_INJAR + filename;
            } else {
                URL url;
                try {
                    url = new URL(resURL);
                    URLConnection urlCon = url.openConnection();
                    urlCon.setUseCaches(false);
                    lsin = new LSInputImpl();
                    lsin.setSystemId(resURL);
                    lsin.setByteStream(urlCon.getInputStream());
                } catch (Exception e) {
                    return null;
                }
              
            }
        } else if (resURL != null && !resURL.startsWith("http:")) {
            localFile = resURL;
        else {
            return null;
        }
       
       
        URIResolver resolver;
        try {          
            resolver = new URIResolver(localFile);
            if (resolver.isResolved()) {
                lsin = new LSInputImpl();
                lsin.setSystemId(localFile);
                lsin.setByteStream(resolver.getInputStream());
            }
        } catch (IOException e) {
            return null;
        }      
        return lsin;
View Full Code Here

      return bindingClass;
   }

   public LSInput resolveAsLSInput(String nsURI, String baseURI, String schemaLocation)
   {
      LSInput lsInput = null;
      InputSource is = getInputSource(nsURI, baseURI, schemaLocation);
      if (is != null)
      {
         String publicId = is.getPublicId();
         String systemId = is.getSystemId();
         lsInput = new LSInputAdaptor(publicId, systemId, baseURI);
         lsInput.setCharacterStream(is.getCharacterStream());
         lsInput.setByteStream(is.getByteStream());
         lsInput.setEncoding(is.getEncoding());
      }
      return lsInput;
   }
View Full Code Here

//                              + "NAMESPACE_URI: "  + namespaceURI +  "\n"   
//                              + "PUBLIC_ID: "  + publicId +  "\n"  
//                              + "SYSTEM_ID: "  + systemId +  "\n"  
//                              + "BASE_URI: "  + baseURI +  "\n" ); 

            final LSInput lsInput = new LSInputImpl();

            // In all Java EE schema xsd files, the <xsd:include schemaLocation=../> always reference to a relative path.
            // so the systemId here will be the xsd file name.
            final URL schemaURL = JaxbJavaee.getSchemaURL(systemId);

            InputStream is = null;
            if (schemaURL != null) {
                try {
                    is = schemaURL.openStream();
                } catch (final IOException e) {
                    //should not happen
                    throw new RuntimeException(e);
                }
            }

            lsInput.setSystemId(systemId);
            lsInput.setByteStream(is);

            return lsInput;
        }
View Full Code Here

                try {
                    XMLInputSource is = fEntityResolver.resolveEntity(
                        new XMLResourceIdentifierImpl(publicId,systemId,baseUri,null));
                    if(is==null)    return null;
                       
                    LSInput di = new DOMInputImpl();
                    di.setBaseURI(is.getBaseSystemId());
                    di.setByteStream(is.getByteStream());
                    di.setCharacterStream(is.getCharacterStream());
                    di.setEncoding(is.getEncoding());
                    di.setPublicId(is.getPublicId());
                    di.setSystemId(is.getSystemId());
                       
                    return di;
                } catch( IOException e ) {
                    // erors thrown by the callback is not supposed to be
                    // reported to users.
View Full Code Here

    }

    private LSInput loadLSInput(String ns) {
        String path = ToolConstants.CXF_SCHEMAS_DIR_INJAR + NSFILEMAP.get(ns);
        URL url = getClass().getClassLoader().getResource(path);
        LSInput lsin = new LSInputImpl();
        lsin.setSystemId(url.toString());
        try {
            lsin.setByteStream(url.openStream());
        } catch (IOException e) {
            return null;
        }
        return lsin;
    }
View Full Code Here

        LOG.log(Level.FINE, msg.toString());
        if (NSFILEMAP.containsKey(namespaceURI)) {
            return loadLSInput(namespaceURI);
        }

        LSInput lsin = null;
        String resURL = null;
        String localFile = null;
        if (systemId != null) {
            String schemaLocation = "";
            if (baseURI != null) {
                schemaLocation = baseURI.substring(0, baseURI.lastIndexOf("/") + 1);
            }
            if (systemId.indexOf("http://") < 0) {
                resURL = schemaLocation + systemId;
            } else {
                resURL = systemId;
            }
        } else if (namespaceURI != null) {
            resURL = namespaceURI;
        }

        if (resURL != null && resURL.startsWith("http://")) {
            String filename = NSFILEMAP.get(resURL);
            if (filename != null) {
                localFile = ToolConstants.CXF_SCHEMAS_DIR_INJAR + filename;
            } else {
                URL url;
                URLConnection urlCon = null;
                try {
                    url = new URL(resURL);
                    urlCon = url.openConnection();
                    urlCon.setUseCaches(false);
                    lsin = new LSInputImpl();
                    lsin.setSystemId(resURL);
                    lsin.setByteStream(urlCon.getInputStream());
                    msg = new Message("RESOLVE_FROM_REMOTE", LOG, url);
                    LOG.log(Level.FINE, msg.toString());
                    return lsin;
                } catch (Exception e) {
                    e.printStackTrace();
                    return null;
                }
            }
        } else if (resURL != null && !resURL.startsWith("http:")) {
            localFile = resURL;
        else {
            return null;
        }


        URIResolver resolver;
        try {
            msg = new Message("RESOLVE_FROM_LOCAL", LOG, localFile);
            LOG.log(Level.FINE, msg.toString());

            resolver = new URIResolver(localFile);
            if (resolver.isResolved()) {
                lsin = new LSInputImpl();
                lsin.setSystemId(localFile);
                lsin.setByteStream(resolver.getInputStream());
            }
        } catch (IOException e) {
            return null;
        }
        return lsin;
View Full Code Here

        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS domLS = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSParser lsParser = domLS.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);

        LSInput input = domLS.createLSInput();
        input.setStringData(xml);
        Document document = lsParser.parse(input);

        LSSerializer lsSerializer = domLS.createLSSerializer();
        lsSerializer.getDomConfig().setParameter("comments", Boolean.FALSE);
        lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
View Full Code Here

//                              + "NAMESPACE_URI: "  + namespaceURI +  "\n"   
//                              + "PUBLIC_ID: "  + publicId +  "\n"  
//                              + "SYSTEM_ID: "  + systemId +  "\n"  
//                              + "BASE_URI: "  + baseURI +  "\n" ); 
             
            LSInput lsInput = new LSInputImpl()
             
            // In all Java EE schema xsd files, the <xsd:include schemaLocation=../> always reference to a relative path.
            // so the systemId here will be the xsd file name.
            URL schemaURL = JaxbJavaee.getSchemaURL(systemId);

            InputStream is = null;
            if (schemaURL!=null) {
                try {
                    is = schemaURL.openStream();
                } catch (IOException e) {
                    //should not happen
                    throw new RuntimeException(e);
                }
            }
                       
            lsInput.setSystemId(systemId)
            lsInput.setByteStream(is)
         
            return  lsInput; 
       
View Full Code Here

                try {
                    XMLInputSource is = fEntityResolver.resolveEntity(
                        new XMLResourceIdentifierImpl(publicId,systemId,baseUri,null));
                    if(is==null)    return null;
                       
                    LSInput di = new DOMInputImpl();
                    di.setBaseURI(is.getBaseSystemId());
                    di.setByteStream(is.getByteStream());
                    di.setCharacterStream(is.getCharacterStream());
                    di.setEncoding(is.getEncoding());
                    di.setPublicId(is.getPublicId());
                    di.setSystemId(is.getSystemId());
                       
                    return di;
                } catch( IOException e ) {
                    // erors thrown by the callback is not supposed to be
                    // reported to users.
View Full Code Here

TOP

Related Classes of org.w3c.dom.ls.LSInput

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.