Package org.w3c.dom.ls

Examples of org.w3c.dom.ls.LSInput


    }

    @Test
    public void testsExistentClasspathResource()
    {
        LSInput outcome = resolver.resolveResource(IDENTIFIER_TYPE, IDENTIFIER_NAMESPACE, IDENTIFIER_PUBLIC_ID, EXISTENT_CLASSPATH_ABSOLUTE_RESOURCE, null);
        assertThat(outcome, is(not(nullValue())));
        assertThat(outcome.getBaseURI(), is(nullValue()));
        assertCommon(outcome);
    }
View Full Code Here


    @Test
    public void testsExistentAbsoluteFileSystemResource() throws IOException
    {
        File file = temporaryFolder.newFile(UUID.getUUID());
        LSInput outcome = resolver.resolveResource(IDENTIFIER_TYPE, IDENTIFIER_NAMESPACE, IDENTIFIER_PUBLIC_ID, file.getAbsolutePath(), null);
        assertThat(outcome, is(not(nullValue())));
        assertThat(outcome.getBaseURI(), is(nullValue()));
        assertCommon(outcome);
    }
View Full Code Here

    @Test
    public void testsNonExistentAbsoluteFileSystemResource() throws IOException
    {
        String nonExistentAbsoluteFileSystemResource = new File(temporaryFolder.getRoot(), NON_EXISTENT_RESOURCE).getAbsolutePath();
        LSInput outcome = resolver.resolveResource(IDENTIFIER_TYPE, IDENTIFIER_NAMESPACE, IDENTIFIER_PUBLIC_ID, nonExistentAbsoluteFileSystemResource, null);
        assertThat(outcome, is(nullValue()));
    }
View Full Code Here

    @Test
    public void testsExistentFileSystemResourceWithBaseUri() throws IOException
    {
        File file = temporaryFolder.newFile(UUID.getUUID());
        LSInput outcome = resolver.resolveResource(IDENTIFIER_TYPE, IDENTIFIER_NAMESPACE, IDENTIFIER_PUBLIC_ID, file.getName(), file.getPath());
        assertThat(outcome, is(not(nullValue())));
        assertThat(outcome.getBaseURI(), is(not(nullValue())));
        assertCommon(outcome);
    }
View Full Code Here

        private String schema = IOUtils.toString(JsonSchemaXsdValidationTestCase.class.getClassLoader().getResourceAsStream("customer.xsd"));

        @Override
        public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI)
        {
            return new LSInput()
            {
                @Override
                public Reader getCharacterStream()
                {
                    return new StringReader(schema);
View Full Code Here

            System.out.println( "baseURI: " + baseURI );
            return null;
        }

        InputStream resource = getClass().getClassLoader().getResourceAsStream( resourceName );
        LSInput input;
        try
        {
            input = getLSInput();
        }
        catch( Exception e )
        {
            throw new UnsupportedOperationException( "Internal problem. Please report to qi4j-dev forum at Google Groups.", e  );
        }
        input.setBaseURI( baseURI );
        input.setByteStream( resource );
        input.setPublicId( publicId );
        input.setSystemId( systemId );
        return input;
    }
View Full Code Here

   public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {

       if(Log.isDebugEnabled(Log.XML_RESOLVER))
           Log.debug(Log.XML_RESOLVER, "Jeeves XmlResolver: Before resolution: Type: "+type+" NamespaceURI :"+namespaceURI+" PublicId :"+publicId+" SystemId :"+systemId+" BaseURI:"+baseURI);

    LSInput result = super.resolveResource(type, namespaceURI, publicId, systemId, baseURI);

    if (result != null) { // some changes made so update
      publicId = result.getPublicId();
      systemId = result.getSystemId();
      baseURI  = result.getBaseURI();
    }

       if(Log.isDebugEnabled(Log.XML_RESOLVER))
           Log.debug(Log.XML_RESOLVER, "Jeeves XmlResolver: After resolution: PublicId :"+publicId+" SystemId :"+systemId+" BaseURI:"+baseURI);

    URL externalRef = null;
    try {

      if (publicId != null && publicId.startsWith("http://")) {
        externalRef = new URL(publicId);
      } else if (systemId != null && systemId.startsWith("http://")) {
        externalRef = new URL(systemId);
      } else if (systemId != null && baseURI != null) {
        if (baseURI.startsWith("http://")) {
          URL ref = new URL(baseURI);
                    String thePath = new File(ref.getPath()).getParent().replace('\\', '/');
                    externalRef = new URI(ref.getProtocol(), null, ref.getHost(), ref.getPort(), thePath + "/" + systemId, null, null).toURL();
                }
      }
    } catch (MalformedURLException e) { // leave this to someone else?
      e.printStackTrace();
      return result;
        } catch (URISyntaxException e) { // leave this to someone else?
            e.printStackTrace();
            return result;
        }

    if (externalRef != null) {

      Element elResult = null;
     
      try {
        elResult = isXmlInCache(externalRef.toString());
      } catch (CacheException e) {
                Log.error(Log.XML_RESOLVER, "Request to cache for " + externalRef + " failed.");
        e.printStackTrace();
      }

      if (elResult == null) { // use XMLRequest to get the XML
        XmlRequest xml = new GeonetHttpRequestFactory().createXmlRequest(externalRef);
                if (proxyParams.useProxy) {
          xml.setUseProxy(true);
          xml.setProxyHost(proxyParams.proxyHost);
          xml.setProxyPort(proxyParams.proxyPort);
          if (proxyParams.useProxyAuth) {
                        xml.setProxyCredentials(proxyParams.username, proxyParams.password);
                    }
        }
 
        elResult = null;
        try {
          elResult = xml.execute();
          addXmlToCache(externalRef.toString(), elResult);
                    if(Log.isDebugEnabled(Log.XML_RESOLVER)) {
                        Log.debug(Log.XML_RESOLVER, "Retrieved: \n" + Xml.getString(elResult));
                    }
        } catch (Exception e) {
          Log.error(Log.XML_RESOLVER, "Request on " + externalRef + " failed." + e.getMessage());
        }

      }

      if (result == null) {
        result = new DOMInputImpl(publicId, systemId, baseURI);
      }
      if (elResult != null) {
        result.setStringData(Xml.getString(elResult));
      }
     }
    return result;
  }
View Full Code Here

    }

    public static XSModel createXsModel(final String data) {
        XSLoader schemaLoader = createXsLoader();

        XSModel xsmodel = schemaLoader.load(new LSInput() {

            @Override
            public String getBaseURI() {
                return ".";
            }
View Full Code Here

            try {
                URL base = baseURI == null ? null : new URL(baseURI);
                final URL rel = new URL(base, systemId);
                final SDDocument doc = docs.get(rel.toExternalForm());
                if (doc != null) {
                    return new LSInput() {

                        public Reader getCharacterStream() {
                            return null;
                        }
View Full Code Here

         * returned into an <code>InputSource</code>.
         */
        public InputSource resolveEntity(String name, String publicId,
                String baseURI, String systemId) throws SAXException, IOException {
            if (fEntityResolver != null) {
                LSInput lsInput = fEntityResolver.resolveResource(XML_TYPE, null, publicId, systemId, baseURI);
                if (lsInput != null) {
                    final String pubId = lsInput.getPublicId();
                    final String sysId = lsInput.getSystemId();
                    final String baseSystemId = lsInput.getBaseURI();
                    final Reader charStream = lsInput.getCharacterStream();
                    final InputStream byteStream = lsInput.getByteStream();
                    final String data = lsInput.getStringData();
                    final String encoding = lsInput.getEncoding();

                    /**
                     * An LSParser looks at inputs specified in LSInput in
                     * the following order: characterStream, byteStream,
                     * stringData, systemId, publicId. For consistency
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.