org.w3c.dom.ls.LSInput Java Examples

The following examples show how to use org.w3c.dom.ls.LSInput. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoggingLSResourceResolver.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
@Override
@Nullable
public LSInput mainResolveResource (@Nullable final String sType,
                                    @Nullable final String sNamespaceURI,
                                    @Nullable final String sPublicId,
                                    @Nullable final String sSystemId,
                                    @Nullable final String sBaseURI)
{
  if (LOGGER.isInfoEnabled ())
    LOGGER.info ("mainResolveResource (" +
                 sType +
                 ", " +
                 sNamespaceURI +
                 ", " +
                 sPublicId +
                 ", " +
                 sSystemId +
                 ", " +
                 sBaseURI +
                 ")");
  return null;
}
 
Example #2
Source File: AbstractLSResourceResolver.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
@Nullable
public final LSInput resolveResource (@Nonnull @Nonempty final String sType,
                                      @Nullable final String sNamespaceURI,
                                      @Nullable final String sPublicId,
                                      @Nullable final String sSystemId,
                                      @Nullable final String sBaseURI)
{
  final LSInput ret = mainResolveResource (sType, sNamespaceURI, sPublicId, sSystemId, sBaseURI);
  if (ret != null)
    return ret;

  // Pass to parent (if available)
  if (m_aWrappedResourceResolver != null)
    return m_aWrappedResourceResolver.resolveResource (sType, sNamespaceURI, sPublicId, sSystemId, sBaseURI);

  // Not found
  return null;
}
 
Example #3
Source File: WSDLSchemaValidator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    LSInput input = null;
    
    Iterator<ValidatorSchemaFactory> it = mExtSchemaFactories.iterator();
    while(it.hasNext()) {
        ValidatorSchemaFactory fac = it.next();
        LSResourceResolver resolver = fac.getLSResourceResolver();
        if(resolver != null) {
            input = resolver.resolveResource(type, namespaceURI, publicId, systemId, baseURI);
            if(input != null) {
               break;
            }
        }
    }
    
    return input;
}
 
Example #4
Source File: Bug6355326.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testExternalEncoding() {

    try {
        LSInput src = null;
        LSParser dp = null;

        src = createLSInputEncoding();
        dp = createLSParser();

        src.setEncoding("UTF-16");
        Document doc = dp.parse(src);
        Assert.assertTrue("encodingXML".equals(doc.getDocumentElement().getNodeName()), "XML document is not parsed correctly");

    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Exception occured: " + e.getMessage());
    }
}
 
Example #5
Source File: XMLSchemaLoader.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public XSModel load(LSInput is) {
    try {
        Grammar g = loadGrammar(dom2xmlInputSource(is));
        return ((XSGrammar) g).toXSModel();
    } catch (Exception e) {
        reportDOMFatalError(e);
        return null;
    }
}
 
Example #6
Source File: Bug4997818.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test1() throws Exception {
    String xsd1 = "<?xml version='1.0'?>\n" + "<schema xmlns='http://www.w3.org/2001/XMLSchema'\n" + "        xmlns:test='jaxp13_test1'\n"
            + "        targetNamespace='jaxp13_test1'\n" + "        elementFormDefault='qualified'>\n" + "    <import namespace='jaxp13_test2'/>\n"
            + "    <element name='test'/>\n" + "    <element name='child1'/>\n" + "</schema>\n";

    final NullPointerException EUREKA = new NullPointerException("NewSchema015");

    SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
    StringReader reader = new StringReader(xsd1);
    StreamSource source = new StreamSource(reader);
    LSResourceResolver resolver = new LSResourceResolver() {
        public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
            LSInput input;
            if (namespaceURI != null && namespaceURI.endsWith("jaxp13_test2")) {
                throw EUREKA;
            } else {
                input = null;
            }

            return input;
        }
    };
    schemaFactory.setResourceResolver(resolver);

    try {
        schemaFactory.newSchema(new Source[] { source });
        Assert.fail("NullPointerException was not thrown.");
    } catch (RuntimeException e) {
        if (e != EUREKA)
            throw e;
    }
}
 
Example #7
Source File: JaxbJavaee.java    From tomee with Apache License 2.0 5 votes vote down vote up
/**
         * Allow the application to resolve external resources.
         */
        public LSInput resolveResource(final String type, final String namespaceURI, final String publicId, final String systemId, final String baseURI) {
//            System.out.println("\n>> Resolving "  +  "\n"   
//                              + "TYPE: "  + type +  "\n"   
//                              + "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;
        }
 
Example #8
Source File: ValidatorHandlerImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Resolves the given resource and adapts the <code>LSInput</code>
 * 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
             * with the DOM Level 3 Load and Save Recommendation
             * use the same lookup order here.
             */
            InputSource inputSource = new InputSource();
            inputSource.setPublicId(pubId);
            inputSource.setSystemId((baseSystemId != null) ? resolveSystemId(systemId, baseSystemId) : systemId);

            if (charStream != null) {
                inputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                inputSource.setByteStream(byteStream);
            }
            else if (data != null && data.length() != 0) {
                inputSource.setCharacterStream(new StringReader(data));
            }
            inputSource.setEncoding(encoding);
            return inputSource;
        }
    }
    return null;
}
 
Example #9
Source File: ValidatorHandlerImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Resolves the given resource and adapts the <code>LSInput</code>
 * 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
             * with the DOM Level 3 Load and Save Recommendation
             * use the same lookup order here.
             */
            InputSource inputSource = new InputSource();
            inputSource.setPublicId(pubId);
            inputSource.setSystemId((baseSystemId != null) ? resolveSystemId(systemId, baseSystemId) : systemId);

            if (charStream != null) {
                inputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                inputSource.setByteStream(byteStream);
            }
            else if (data != null && data.length() != 0) {
                inputSource.setCharacterStream(new StringReader(data));
            }
            inputSource.setEncoding(encoding);
            return inputSource;
        }
    }
    return null;
}
 
Example #10
Source File: ValidatorHandlerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Resolves the given resource and adapts the <code>LSInput</code>
 * 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
             * with the DOM Level 3 Load and Save Recommendation
             * use the same lookup order here.
             */
            InputSource inputSource = new InputSource();
            inputSource.setPublicId(pubId);
            inputSource.setSystemId((baseSystemId != null) ? resolveSystemId(systemId, baseSystemId) : systemId);

            if (charStream != null) {
                inputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                inputSource.setByteStream(byteStream);
            }
            else if (data != null && data.length() != 0) {
                inputSource.setCharacterStream(new StringReader(data));
            }
            inputSource.setEncoding(encoding);
            return inputSource;
        }
    }
    return null;
}
 
Example #11
Source File: XMLSchemaLoader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public XSModel load(LSInput is) {
    try {
        Grammar g = loadGrammar(dom2xmlInputSource(is));
        return ((XSGrammar) g).toXSModel();
    } catch (Exception e) {
        reportDOMFatalError(e);
        return null;
    }
}
 
Example #12
Source File: XSLoaderImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 *  Parse an XML Schema document from a resource identified by a
 * <code>LSInput</code> .
 * @param is  The <code>LSInput</code> from which the source
 *   document is to be read.
 * @return An XSModel representing this schema.
 */
public XSModel load(LSInput is) {
    try {
        fGrammarPool.clear();
        return ((XSGrammar) fSchemaLoader.loadGrammar(fSchemaLoader.dom2xmlInputSource(is))).toXSModel();
    }
    catch (Exception e) {
        fSchemaLoader.reportDOMFatalError(e);
        return null;
    }
}
 
Example #13
Source File: XMLSchemaLoader.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public XSModel load(LSInput is) {
    try {
        Grammar g = loadGrammar(dom2xmlInputSource(is));
        return ((XSGrammar) g).toXSModel();
    } catch (Exception e) {
        reportDOMFatalError(e);
        return null;
    }
}
 
Example #14
Source File: Resolver.java    From xml-maven-plugin with Apache License 2.0 5 votes vote down vote up
private final LSInput newLSInput( InputSource pSource )
{
    final LSInputImpl lsInput = new LSInputImpl();
    lsInput.setByteStream( pSource.getByteStream() );
    lsInput.setCharacterStream( pSource.getCharacterStream() );
    lsInput.setPublicId( lsInput.getPublicId() );
    lsInput.setSystemId( pSource.getSystemId() );
    lsInput.setEncoding( pSource.getEncoding() );
    return lsInput;
}
 
Example #15
Source File: XSLoaderImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 *  Parse an XML Schema document from a resource identified by a
 * <code>LSInput</code> .
 * @param is  The <code>LSInput</code> from which the source
 *   document is to be read.
 * @return An XSModel representing this schema.
 */
public XSModel load(LSInput is) {
    try {
        fGrammarPool.clear();
        return ((XSGrammar) fSchemaLoader.loadGrammar(fSchemaLoader.dom2xmlInputSource(is))).toXSModel();
    }
    catch (Exception e) {
        fSchemaLoader.reportDOMFatalError(e);
        return null;
    }
}
 
Example #16
Source File: SimpleLSResourceResolver.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Resolve a resource with the passed parameters
 *
 * @param sType
 *        The type of the resource being resolved. For XML [
 *        <a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>]
 *        resources (i.e. entities), applications must use the value <code>
 *        "http://www.w3.org/TR/REC-xml"</code>. For XML Schema [
 *        <a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML
 *        Schema Part 1</a>] , applications must use the value <code>
 *        "http://www.w3.org/2001/XMLSchema"</code>. Other types of resources
 *        are outside the scope of this specification and therefore should
 *        recommend an absolute URI in order to use this method.
 * @param sNamespaceURI
 *        The namespace of the resource being resolved, e.g. the target
 *        namespace of the XML Schema [
 *        <a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML
 *        Schema Part 1</a>] when resolving XML Schema resources.
 * @param sPublicId
 *        The public identifier of the external entity being referenced, or
 *        <code>null</code> if no public identifier was supplied or if the
 *        resource is not an entity.
 * @param sSystemId
 *        the path of the resource to find - may be relative to the including
 *        resource. The system identifier, a URI reference [
 *        <a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>], of
 *        the external resource being referenced, or <code>null</code> if no
 *        system identifier was supplied.
 * @param sBaseURI
 *        The systemId of the including resource.The absolute base URI of the
 *        resource being parsed, or <code>null</code> if there is no base URI.
 * @return <code>null</code> if the resource could not be resolved.
 */
@Override
@Nullable
public final LSInput mainResolveResource (@Nonnull @Nonempty final String sType,
                                          @Nullable final String sNamespaceURI,
                                          @Nullable final String sPublicId,
                                          @Nullable final String sSystemId,
                                          @Nullable final String sBaseURI)
{
  try
  {
    // Try to get the resource
    final IReadableResource aResolvedResource = internalResolveResource (sType,
                                                                         sNamespaceURI,
                                                                         sPublicId,
                                                                         sSystemId,
                                                                         sBaseURI);
    return new ResourceLSInput (aResolvedResource);
  }
  catch (final Exception ex)
  {
    throw new IllegalStateException ("Failed to resolve resource '" +
                                     sType +
                                     "', '" +
                                     sNamespaceURI +
                                     "', '" +
                                     sPublicId +
                                     "', '" +
                                     sSystemId +
                                     "', '" +
                                     sBaseURI +
                                     "'",
                                     ex);
  }
}
 
Example #17
Source File: ParserUtils.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
public LSInput resolveResource(String type, 
                               String namespaceURI, 
                               String publicId, 
                               String systemId, 
                               String baseURI) {

    InputStream is = null;

    String resourceName = systemId;
    int index = systemId.lastIndexOf('/');
    if (index != -1) {
        resourceName = systemId.substring(index+1);
    }
    String resourcePath = (ParserUtils.schemaResourcePrefix != null) ?
        (ParserUtils.schemaResourcePrefix + resourceName) :
        resourceName;

    if (ParserUtils.isSchemaResourcePrefixFileUrl) {
        try {
            File f = new File(new URI(resourcePath));
            if (f.exists()) { 
                is = new FileInputStream(f);
            }
        } catch (Exception e) {

        }
    } else {
        is = this.getClass().getResourceAsStream(resourcePath);
    }

    MyLSInput ls = new MyLSInput();
    ls.setByteStream(is);
    ls.setSystemId(systemId); // See CR 6402288

    return ls;
}
 
Example #18
Source File: EntityResolverToLSResourceResolver.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
@Override
public LSInput resolveResource(
        String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    // give the entity resolver an opportunity (mostly to throw an exception)
    try {
        InputSource is = entityResolver.resolveEntity(publicId, systemId);
        if (is != null) {
            return new InputSourceToLSResource(is);
        }
    } catch (SAXException | IOException e) {
        throw new RuntimeException(e);
    }
    // otherwise fall back on the default resolution path
    return delegate.resolveResource(type, namespaceURI, publicId, systemId, baseURI);
}
 
Example #19
Source File: CatalogSupportBase.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId,
        String systemId, String baseURI) {
    for (int i = 0; i < systemIds.length; i++) {
        if (systemId.endsWith(systemIds[i])) {
            return returnValues[i];
        }
    }

    return null;
}
 
Example #20
Source File: ValidatorHandlerImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Resolves the given resource and adapts the <code>LSInput</code>
 * 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
             * with the DOM Level 3 Load and Save Recommendation
             * use the same lookup order here.
             */
            InputSource inputSource = new InputSource();
            inputSource.setPublicId(pubId);
            inputSource.setSystemId((baseSystemId != null) ? resolveSystemId(systemId, baseSystemId) : systemId);

            if (charStream != null) {
                inputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                inputSource.setByteStream(byteStream);
            }
            else if (data != null && data.length() != 0) {
                inputSource.setCharacterStream(new StringReader(data));
            }
            inputSource.setEncoding(encoding);
            return inputSource;
        }
    }
    return null;
}
 
Example #21
Source File: Bug6376823.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private LSInput getXmlSource(String xml1) {
    LSInput src = implLS.createLSInput();
    try {
        src.setStringData(xml1);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Exception occured: " + e.getMessage());
    }
    return src;
}
 
Example #22
Source File: ClassLoaderLSResourceResolver.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * @see org.w3c.dom.ls.LSResourceResolver#resolveResource(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
 */
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    if (!type.equals(XMLConstants.W3C_XML_SCHEMA_NS_URI)) {
        return null;
    }
    LOG.error(type);
    LOG.error(namespaceURI);
    LOG.error(publicId);
    LOG.error(systemId);
    LOG.error(baseURI);
    String path = resolveSystemId(systemId);
    if (path == null) {
        return null;
    }
    LOG.debug("Looking up resource '" + path + "' for system id '" + systemId + "'");
    InputStream is = getClass().getClassLoader().getResourceAsStream(path);
    if (is == null) {
        String message = "Unable to find schema (" + path + ") for: " + systemId;
        LOG.error(message);
        throw new RuntimeException/*SAXException*/(message);
    }
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        DOMImplementation domImpl = builder.getDOMImplementation();
        DOMImplementationLS dils = (DOMImplementationLS) domImpl;
        LSInput input = dils.createLSInput();
        input.setByteStream(is);
        return input;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #23
Source File: SchemaValidator.java    From cxf with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #24
Source File: XMLSchemaLoader.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public XSModel load(LSInput is) {
    try {
        Grammar g = loadGrammar(dom2xmlInputSource(is));
        return ((XSGrammar) g).toXSModel();
    } catch (Exception e) {
        reportDOMFatalError(e);
        return null;
    }
}
 
Example #25
Source File: XSLoaderImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 *  Parse an XML Schema document from a resource identified by a
 * <code>LSInput</code> .
 * @param is  The <code>LSInput</code> from which the source
 *   document is to be read.
 * @return An XSModel representing this schema.
 */
public XSModel load(LSInput is) {
    try {
        fGrammarPool.clear();
        return ((XSGrammar) fSchemaLoader.loadGrammar(fSchemaLoader.dom2xmlInputSource(is))).toXSModel();
    }
    catch (Exception e) {
        fSchemaLoader.reportDOMFatalError(e);
        return null;
    }
}
 
Example #26
Source File: LocalResolver.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Override
public LSInput resolveResource(final String type, final String namespaceURI, final String publicId, final String systemId, final String baseURI) {
    final LSInput input = lsImplementation.createLSInput();

    final String path = URI.create(systemId).getPath();

    input.setPublicId(publicId);
    input.setBaseURI(baseURI);
    input.setSystemId(path);
    input.setByteStream(LocalResolver.class.getResourceAsStream("/xsd/" + path));

    return input;
}
 
Example #27
Source File: DoNothingLSResourceResolver.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nullable
public LSInput resolveResource (@Nullable final String sType,
                                @Nullable final String sNamespaceURI,
                                @Nullable final String sPublicId,
                                @Nullable final String sSystemId,
                                @Nullable final String sBaseURI)
{
  return null;
}
 
Example #28
Source File: WSDLInlineSchemaValidator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public LSInput resolveResource(String type, 
                               String namespaceURI, 
                               String publicId, 
                               String systemId, 
                               String baseURI) {
    
     LSInput lsi = mDelegate.resolveResource(type, namespaceURI, publicId, systemId, baseURI);

     if (lsi == null) {
         //if we can not get an input from catalog, then it could that
         //there as a schema in types section which refer to schema compoment from other inline schema
         //so we try to check in other inline schema.
         WSDLSchema schema = findSchema(namespaceURI);
         if(schema != null) {
             Reader in = createInlineSchemaSource(mWsdlText, mWsdlPrefixes, mWsdlLinePositions, schema);
             if(in != null) {
                 //create LSInput object
                 DOMImplementation domImpl = null;
                 try {
                     domImpl =  DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
                 } catch (ParserConfigurationException ex) {
                     Logger.getLogger(getClass().getName()).log(Level.SEVERE, "resolveResource", ex); //NOI18N
                     return null;
                 }

                 DOMImplementationLS dols = (DOMImplementationLS) domImpl.getFeature("LS","3.0");
                 lsi = dols.createLSInput();
                 lsi.setCharacterStream(in);

                 if(mWsdlSystemId != null) {
                     lsi.setSystemId(mWsdlSystemId);
                 }
                 return lsi;  
             }
         }
     }
     return lsi;                      
}
 
Example #29
Source File: XSLoaderImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Parse an XML Schema document from a resource identified by a
 * <code>LSInput</code> .
 * @param is  The <code>LSInput</code> from which the source
 *   document is to be read.
 * @return An XSModel representing this schema.
 */
public XSModel load(LSInput is) {
    try {
        fGrammarPool.clear();
        return ((XSGrammar) fSchemaLoader.loadGrammar(fSchemaLoader.dom2xmlInputSource(is))).toXSModel();
    }
    catch (Exception e) {
        fSchemaLoader.reportDOMFatalError(e);
        return null;
    }
}
 
Example #30
Source File: MetsLSResolverTest.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testResolveResource() throws Exception {
    MetsLSResolver resolver = MetsLSResolver.getInstance();
    LSInput input = resolver.resolveResource(null, null, null, "http://www.openarchives.org/OAI/2.0/oai_dc.xsd", null);
    assertNotNull(input);
    InputStream stream = input.getByteStream();
    assertNotNull(stream);
    stream.close();
}