Java 类org.w3c.dom.ls.LSInput 实例源码

项目:incubator-netbeans    文件:WSDLSchemaValidator.java   
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;
}
项目:openjdk-jdk10    文件:CatalogResolverImpl.java   
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    InputSource is = resolveEntity(publicId, systemId);

    if (is != null && !is.isEmpty()) {
        return new LSInputImpl(is.getSystemId());
    }

    GroupEntry.ResolveType resolveType = ((CatalogImpl) catalog).getResolve();
    switch (resolveType) {
        case IGNORE:
            return null;
        case STRICT:
            CatalogMessages.reportError(CatalogMessages.ERR_NO_MATCH,
                    new Object[]{publicId, systemId});
    }

    //no action, allow the parser to continue
    return null;
}
项目:openjdk-jdk10    文件:Bug6355326.java   
@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());
    }
}
项目:openjdk-jdk10    文件:DocumentLSTest.java   
@Test
public void testLSInputParsingByteStream() throws Exception {
    DOMImplementationLS impl = (DOMImplementationLS) getDocumentBuilder().getDOMImplementation();
    LSParser domParser = impl.createLSParser(MODE_SYNCHRONOUS, null);
    LSInput src = impl.createLSInput();

    try (InputStream is = new FileInputStream(ASTROCAT)) {
        src.setByteStream(is);
        assertNotNull(src.getByteStream());
        // set certified accessor methods
        boolean origCertified = src.getCertifiedText();
        src.setCertifiedText(true);
        assertTrue(src.getCertifiedText());
        src.setCertifiedText(origCertified); // set back to orig

        src.setSystemId(filenameToURL(ASTROCAT));

        Document doc = domParser.parse(src);
        Element result = doc.getDocumentElement();
        assertEquals(result.getTagName(), "stardb");
    }
}
项目:openjdk-jdk10    文件:DocumentLSTest.java   
@Test
public void testLSInputParsingString() throws Exception {
    DOMImplementationLS impl = (DOMImplementationLS) getDocumentBuilder().getDOMImplementation();
    String xml = "<?xml version='1.0'?><test>runDocumentLS_Q6</test>";

    LSParser domParser = impl.createLSParser(MODE_SYNCHRONOUS, null);
    LSSerializer domSerializer = impl.createLSSerializer();
    // turn off xml decl in serialized string for comparison
    domSerializer.getDomConfig().setParameter("xml-declaration", Boolean.FALSE);
    LSInput src = impl.createLSInput();
    src.setStringData(xml);
    assertEquals(src.getStringData(), xml);

    Document doc = domParser.parse(src);
    String result = domSerializer.writeToString(doc);

    assertEquals(result, "<test>runDocumentLS_Q6</test>");
}
项目:openjdk9    文件:Bug6355326.java   
@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());
    }
}
项目:openjdk9    文件:DocumentLSTest.java   
@Test
public void testLSInputParsingByteStream() throws Exception {
    DOMImplementationLS impl = (DOMImplementationLS) getDocumentBuilder().getDOMImplementation();
    LSParser domParser = impl.createLSParser(MODE_SYNCHRONOUS, null);
    LSInput src = impl.createLSInput();

    try (InputStream is = new FileInputStream(ASTROCAT)) {
        src.setByteStream(is);
        assertNotNull(src.getByteStream());
        // set certified accessor methods
        boolean origCertified = src.getCertifiedText();
        src.setCertifiedText(true);
        assertTrue(src.getCertifiedText());
        src.setCertifiedText(origCertified); // set back to orig

        src.setSystemId(filenameToURL(ASTROCAT));

        Document doc = domParser.parse(src);
        Element result = doc.getDocumentElement();
        assertEquals(result.getTagName(), "stardb");
    }
}
项目:openjdk9    文件:DocumentLSTest.java   
@Test
public void testLSInputParsingString() throws Exception {
    DOMImplementationLS impl = (DOMImplementationLS) getDocumentBuilder().getDOMImplementation();
    String xml = "<?xml version='1.0'?><test>runDocumentLS_Q6</test>";

    LSParser domParser = impl.createLSParser(MODE_SYNCHRONOUS, null);
    LSSerializer domSerializer = impl.createLSSerializer();
    // turn off xml decl in serialized string for comparison
    domSerializer.getDomConfig().setParameter("xml-declaration", Boolean.FALSE);
    LSInput src = impl.createLSInput();
    src.setStringData(xml);
    assertEquals(src.getStringData(), xml);

    Document doc = domParser.parse(src);
    String result = domSerializer.writeToString(doc);

    assertEquals(result, "<test>runDocumentLS_Q6</test>");
}
项目:komplexni-validator    文件:XsdImportsResourceResolver.java   
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    InputStream stream = null;
    try {
        File file = new File(xsdDir, systemId);
        stream = new FileInputStream(file);
        LSInputImpl input = new LSInputImpl();
        input.setPublicId(publicId);
        input.setSystemId(systemId);
        input.setBaseURI(baseURI);
        input.setCharacterStream(new InputStreamReader(stream));
        return input;
    } catch (FileNotFoundException e) {
        return null;
    }
}
项目:javify    文件:DomDocumentBuilder.java   
public Document parse(InputStream in)
  throws SAXException, IOException
{
  LSInput input = ls.createLSInput();
  input.setByteStream(in);
  try
    {
      return parser.parse(input);
    }
  catch (LSException e)
    {
      Throwable e2 = e.getCause();
      if (e2 instanceof IOException)
        throw (IOException) e2;
      else
        throw e;
    }
}
项目:javify    文件:DomDocumentBuilder.java   
public Document parse(InputStream in, String systemId)
  throws SAXException, IOException
{
  LSInput input = ls.createLSInput();
  input.setByteStream(in);
  input.setSystemId(systemId);
  try
    {
      return parser.parse(input);
    }
  catch (LSException e)
    {
      Throwable e2 = e.getCause();
      if (e2 instanceof IOException)
        throw (IOException) e2;
      else
        throw e;
    }
}
项目:eid-applet    文件:XAdESSignatureFacetTest.java   
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId,
        String baseURI) {
    LOG.debug("resolve resource");
    LOG.debug("type: " + type);
    LOG.debug("namespace URI: " + namespaceURI);
    LOG.debug("publicId: " + publicId);
    LOG.debug("systemId: " + systemId);
    LOG.debug("base URI: " + baseURI);
    if ("http://uri.etsi.org/01903/v1.3.2#".equals(namespaceURI)) {
        return new LocalLSInput(publicId, systemId, baseURI, "/XAdES.xsd");
    }
    if ("http://www.w3.org/2000/09/xmldsig#".equals(namespaceURI)) {
        return new LocalLSInput(publicId, systemId, baseURI, "/xmldsig-core-schema.xsd");
    }
    throw new RuntimeException("unsupported resource: " + namespaceURI);
}
项目:jvm-stm    文件:DomDocumentBuilder.java   
public Document parse(InputStream in)
  throws SAXException, IOException
{
  LSInput input = ls.createLSInput();
  input.setByteStream(in);
  try
    {
      return parser.parse(input);
    }
  catch (LSException e)
    {
      Throwable e2 = e.getCause();
      if (e2 instanceof IOException)
        throw (IOException) e2;
      else
        throw e;
    }
}
项目:jvm-stm    文件:DomDocumentBuilder.java   
public Document parse(InputStream in, String systemId)
  throws SAXException, IOException
{
  LSInput input = ls.createLSInput();
  input.setByteStream(in);
  input.setSystemId(systemId);
  try
    {
      return parser.parse(input);
    }
  catch (LSException e)
    {
      Throwable e2 = e.getCause();
      if (e2 instanceof IOException)
        throw (IOException) e2;
      else
        throw e;
    }
}
项目:proarc    文件:SimpleLSResourceResolver.java   
@Override
    public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
        String location = map.get(systemId);
//        System.out.printf("\ntype: %s\nnsURI: %s\npublicId: %s\nsystemId: %s\nbaseURI: %s\n",
//                type, namespaceURI, publicId, systemId, baseURI);
        if (location == null) {
            for (Class<?> base : bases) {
                URL resource = base.getResource(systemId);
                if (resource != null) {
                    systemId = resource.toExternalForm();
                    break;
                }
            }
        }
        LSInput input = dls.createLSInput();
        input.setSystemId(systemId);
//        System.out.println("Real system ID: " + systemId);
        return input;
    }
项目:yawl    文件:ResourceResolver.java   
public LSInput resolveResource(String type, String namespaceURI,
                               String publicId, String systemId, String baseURI) {
    try {
        URL url = new URL(namespaceURI + '/' + systemId);
        String content = cache.get(url);
        if (content == null) {
            content = streamToString(new URL(namespaceURI + '/' + systemId).openStream());
            if (content != null) cache.put(url, content);
        }
        return new Input(publicId, systemId, stringToStream(content));
    }
    catch (MalformedURLException mue) {
        mue.printStackTrace();
        return null;
    }
    catch (IOException ioe) {
        ioe.printStackTrace();
        return null;
    }
}
项目:jing-trang    文件:SchemaFactoryImplTest.java   
@Test
public void testInstanceResourceResolver() throws SAXException, IOException {
  SchemaFactory f = factory();
  Validator v = f.newSchema(charStreamSource(element("doc", element("inner")))).newValidator();
  Assert.assertNull(v.getResourceResolver());
  LSResourceResolver rr = new LSResourceResolver() {
    public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
      // In Java 5 Xerces absolutized the systemId relative to the current directory
      int slashIndex = systemId.lastIndexOf('/');
      if (slashIndex >= 0)
        systemId = systemId.substring(slashIndex + 1);
      Assert.assertEquals(systemId, "e.xml");
      Assert.assertEquals(type, "http://www.w3.org/TR/REC-xml");
      LSInput in = new LSInputImpl();
      in.setStringData("<inner/>");
      return in;
    }
  };
  v.setResourceResolver(rr);
  Assert.assertSame(v.getResourceResolver(), rr);
  v.validate(charStreamSource("<!DOCTYPE doc [ <!ENTITY e SYSTEM 'e.xml'> ]><doc>&e;</doc>"));
}
项目:jing-trang    文件:SchemaFactoryImplTest.java   
@Test
public void testSchemaResourceResolver() throws SAXException, IOException {
  SchemaFactory f = factory();
  Assert.assertNull(f.getResourceResolver());
  LSResourceResolver rr = new LSResourceResolver() {
    public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
      Assert.assertEquals(systemId, "myschema");
      Assert.assertEquals(type, getLSType());
      Assert.assertNull(baseURI);
      Assert.assertNull(namespaceURI);
      Assert.assertNull(publicId);
      LSInput in = new LSInputImpl();
      in.setStringData(createSchema("doc"));
      return in;
    }
  };
  f.setResourceResolver(rr);
  Assert.assertSame(f.getResourceResolver(), rr);
  Validator v = f.newSchema(charStreamSource(externalRef("myschema"))).newValidator();
  v.validate(charStreamSource("<doc/>"));
}
项目:FHIR-Server    文件:SchemaBaseValidator.java   
@Override
        public LSInput resolveResource(String theType, String theNamespaceURI, String thePublicId, String theSystemId, String theBaseURI) {
            if (theSystemId != null && SCHEMA_NAMES.contains(theSystemId)) {
                LSInputImpl input = new LSInputImpl();
                input.setPublicId(thePublicId);
                input.setSystemId(theSystemId);
                input.setBaseURI(theBaseURI);
//              String pathToBase = "ca/uhn/fhir/model/" + myVersion + "/schema/" + theSystemId;
                String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theSystemId;

                ourLog.debug("Loading referenced schema file: " + pathToBase);

                InputStream baseIs = FhirValidator.class.getClassLoader().getResourceAsStream(pathToBase);
                if (baseIs == null) {
                    throw new InternalErrorException("Schema file not found: " + pathToBase);
                }

                input.setByteStream(baseIs);

                return input;

            }

            throw new ConfigurationException("Unknown schema: " + theSystemId);
        }
项目:switchyard    文件:Descriptor.java   
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
    String schemaLocation = _descriptor.getSchemaLocation(namespaceURI, systemId);
    if (schemaLocation == null && baseURI != null && baseURI.endsWith(".dtd")) {
        String schema = baseURI.substring(0, baseURI.lastIndexOf('/')+1) + systemId;
        schemaLocation = _descriptor.getSchemaLocation(null, schema);
    }
    if (schemaLocation != null) {
        try {
            String xsd = new StringPuller().pull(schemaLocation, getClass());
            if (xsd != null) {
                return new DescriptorLSInput(xsd, publicId, systemId, baseURI);
            }
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        }
    }
    return null;
}
项目:hapi-fhir    文件:SchemaBaseValidator.java   
@Override
public LSInput resolveResource(String theType, String theNamespaceURI, String thePublicId, String theSystemId, String theBaseURI) {
    if (theSystemId != null && SCHEMA_NAMES.contains(theSystemId)) {
        LSInputImpl input = new LSInputImpl();
        input.setPublicId(thePublicId);
        input.setSystemId(theSystemId);
        input.setBaseURI(theBaseURI);
        // String pathToBase = "ca/uhn/fhir/model/" + myVersion + "/schema/" + theSystemId;
        String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theSystemId;

        ourLog.debug("Loading referenced schema file: " + pathToBase);

        InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase);
        if (baseIs == null) {
            IOUtils.closeQuietly(baseIs);
            throw new InternalErrorException("Schema file not found: " + pathToBase);
        }

        input.setByteStream(baseIs);
        //FIXME resource leak
        return input;

    }

    throw new ConfigurationException("Unknown schema: " + theSystemId);
}
项目:automated_digital_publishing    文件:XHTMLValidator.java   
public LSInput resolveResource(String type,
                               String namespaceURI,
                               String publicId,
                               String systemId,
                               String baseURI)
{
    if (systemId.equalsIgnoreCase("http://www.w3.org/2001/xml.xsd") == true)
    {
        File xml = new File(this.localPath + "xml.xsd");

        if (xml.exists() == true)
        {
            return new LocalEntityInput(xml, publicId, true);
        }
        else
        {
            System.out.print("html2epub1: Can't validate - schema 'xml.xsd' is missing.\n");
            System.exit(-83);
            return null;
        }
    }

    System.out.print("html2epub1: Can't validate - unknown resource with public ID '" + publicId + "', system ID '" + systemId + "', type '" + type + "', namespace URI '" + namespaceURI + "' and base URI '" + baseURI + "'.\n");
    System.exit(-84);
    return null;
}
项目:ph-commons    文件:AbstractLSResourceResolver.java   
@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;
}
项目:ph-commons    文件:CollectingLSResourceResolver.java   
@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 (DEBUG_RESOLVE)
    s_aLogger.info ("mainResolveResource (" +
                    sType +
                    ", " +
                    sNamespaceURI +
                    ", " +
                    sPublicId +
                    ", " +
                    sSystemId +
                    ", " +
                    sBaseURI +
                    ")");

  final LSResourceData aData = new LSResourceData (sType, sNamespaceURI, sPublicId, sSystemId, sBaseURI);
  m_aRWLock.writeLocked ( () -> m_aList.add (aData));
  return null;
}
项目:ph-commons    文件:LoggingLSResourceResolver.java   
@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 (s_aLogger.isInfoEnabled ())
    s_aLogger.info ("mainResolveResource (" +
                    sType +
                    ", " +
                    sNamespaceURI +
                    ", " +
                    sPublicId +
                    ", " +
                    sSystemId +
                    ", " +
                    sBaseURI +
                    ")");
  return null;
}
项目:syncope    文件:SyncopeCamelContext.java   
private void loadContext(final Collection<String> routes) {
    try {
        DOMImplementationRegistry reg = DOMImplementationRegistry.newInstance();
        DOMImplementationLS domImpl = (DOMImplementationLS) reg.getDOMImplementation("LS");
        LSParser parser = domImpl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);

        JAXBContext jaxbContext = JAXBContext.newInstance(Constants.JAXB_CONTEXT_PACKAGES);
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        List<RouteDefinition> routeDefs = new ArrayList<>();
        for (String route : routes) {
            try (InputStream input = IOUtils.toInputStream(route, StandardCharsets.UTF_8)) {
                LSInput lsinput = domImpl.createLSInput();
                lsinput.setByteStream(input);

                Node routeElement = parser.parse(lsinput).getDocumentElement();
                routeDefs.add(unmarshaller.unmarshal(routeElement, RouteDefinition.class).getValue());
            }
        }
        camelContext.addRouteDefinitions(routeDefs);
    } catch (Exception e) {
        LOG.error("While loading Camel context {}", e);
        throw new CamelException(e);
    }
}
项目:JamVM-PH    文件:DomDocumentBuilder.java   
public Document parse(InputStream in)
  throws SAXException, IOException
{
  LSInput input = ls.createLSInput();
  input.setByteStream(in);
  try
    {
      return parser.parse(input);
    }
  catch (LSException e)
    {
      Throwable e2 = e.getCause();
      if (e2 instanceof IOException)
        throw (IOException) e2;
      else
        throw e;
    }
}
项目:JamVM-PH    文件:DomDocumentBuilder.java   
public Document parse(InputStream in, String systemId)
  throws SAXException, IOException
{
  LSInput input = ls.createLSInput();
  input.setByteStream(in);
  input.setSystemId(systemId);
  try
    {
      return parser.parse(input);
    }
  catch (LSException e)
    {
      Throwable e2 = e.getCause();
      if (e2 instanceof IOException)
        throw (IOException) e2;
      else
        throw e;
    }
}
项目:wildfly-core    文件:PersistentResourceXMLParserTestCase.java   
private static String normalizeXML(String xml) throws Exception {
    // Remove all white space adjoining tags ("trim all elements")
    xml = xml.replaceAll("\\s*<", "<");
    xml = xml.replaceAll(">\\s*", ">");

    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);
    return lsSerializer.writeToString(document);
}
项目:wildfly-core    文件:ModelTestUtils.java   
/**
 * Normalize and pretty-print XML so that it can be compared using string
 * compare. The following code does the following: - Removes comments -
 * Makes sure attributes are ordered consistently - Trims every element -
 * Pretty print the document
 *
 * @param xml The XML to be normalized
 * @return The equivalent XML, but now normalized
 */
public static String normalizeXML(String xml) throws Exception {
    // Remove all white space adjoining tags ("trim all elements")
    xml = xml.replaceAll("\\s*<", "<");
    xml = xml.replaceAll(">\\s*", ">");

    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);
    return lsSerializer.writeToString(document);
}
项目:wildfly-core    文件:XMLUtils.java   
/**
 * Normalize and pretty-print XML so that it can be compared using string
 * compare. The following code does the following: - Removes comments -
 * Makes sure attributes are ordered consistently - Trims every element -
 * Pretty print the document
 *
 * @param xml The XML to be normalized
 * @return The equivalent XML, but now normalized
 */
public static String normalizeXML(String xml) throws Exception {
    // Remove all white space adjoining tags ("trim all elements")
    xml = xml.replaceAll("\\s*<", "<");
    xml = xml.replaceAll(">\\s*", ">");

    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);
    return lsSerializer.writeToString(document);
}
项目:geometria    文件:GXmlUtils.java   
public static LSResourceResolver getLSResourceResolver() throws Exception {
    logger.info("");
    LSResourceResolver resourceResolver = new LSResourceResolver() {
        public LSInput resolveResource(String type, String namespaceUri,
                String publicId, String systemId, String baseUri) {
            try {
                final InputStream in = GXmlEntity.class.getResource(
                        "/" + systemId).openStream();
                LSInputAdapter adapter = new LSInputAdapter(in);
                return adapter;
            }
            catch (Exception exception) {
                exception.printStackTrace();
                return null;
            }
        }
    };
    return resourceResolver;
}
项目:geometria    文件:GXmlUtils.java   
private static LSResourceResolver getLSResourceResolver() throws Exception {
    logger.info("");
    LSResourceResolver resourceResolver = new LSResourceResolver() {
        public LSInput resolveResource(String type, String namespaceUri,
                String publicId, String systemId, String baseUri) {
            try {
                final InputStream in = GXmlEntity.class.getResource(
                        "/" + systemId).openStream();
                LSInputAdapter adapter = new LSInputAdapter(in);
                return adapter;
            }
            catch (Exception exception) {
                logger.error(GStringUtils.stackTraceToString(exception));
                return null;
            }
        }
    };
    return resourceResolver;
}
项目:geo-publisher    文件:DefaultLSResourceResolver.java   
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {

    try {
        InputStream inputStream = new URL(new URL(baseURI), systemId).openStream();

        LSInput retval = new DefaultLSInput();
        retval.setByteStream(inputStream);
        retval.setBaseURI(baseURI);
        retval.setSystemId(systemId);
        retval.setPublicId(publicId);

        return retval;
    } catch(IOException e) {
        return null;
    }
}
项目:classpath    文件:DomDocumentBuilder.java   
public Document parse(InputStream in)
  throws SAXException, IOException
{
  LSInput input = ls.createLSInput();
  input.setByteStream(in);
  try
    {
      return parser.parse(input);
    }
  catch (LSException e)
    {
      Throwable e2 = e.getCause();
      if (e2 instanceof IOException)
        throw (IOException) e2;
      else
        throw e;
    }
}
项目:classpath    文件:DomDocumentBuilder.java   
public Document parse(InputStream in, String systemId)
  throws SAXException, IOException
{
  LSInput input = ls.createLSInput();
  input.setByteStream(in);
  input.setSystemId(systemId);
  try
    {
      return parser.parse(input);
    }
  catch (LSException e)
    {
      Throwable e2 = e.getCause();
      if (e2 instanceof IOException)
        throw (IOException) e2;
      else
        throw e;
    }
}
项目:cougar    文件:InterceptingResolver.java   
@Override
public LSInput resolveResource(
                String type,
                String namespaceURI,
                String publicId,
                String systemId,
                String baseURI) {

    try {
        if (shouldLoadAsResource(systemId)) {
            log.debug("Loading resource '" + systemId + "' as resource");
            return resourceToLSInput(publicId, systemId);
        }
        else {
               return super.resolveResource(type, namespaceURI, publicId, systemId, baseURI);
        }
    }
    catch (Exception e) {
        // this is cheating, the spec says allow for an exception, but we don't care
        throw new PluginException("Error resolving resource: " + systemId + ": " + e, e);
    }
}
项目:cougar    文件:InterceptingResolver.java   
private LSInput resourceToLSInput(String publicId, String systemId) {

        InputStream is = resourceAsStream(systemId);

        if (is != null) {
            DOMInputImpl result = new DOMInputImpl(); // any old impl would do
            result.setByteStream(is);
            result.setCharacterStream(null);
            result.setPublicId(publicId);
            result.setSystemId(systemId);

            return result;
        }
        else {
            return null;
        }
    }
项目:molgenis    文件:SchemaLoader.java   
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI)
{
    InputStream resourceAsStream;
    try
    {
        resourceAsStream = getSchema(systemId).getInputStream();
    }
    catch (IOException e)
    {

        throw new RuntimeException(e);
    }

    return new LSInputImpl(publicId, systemId, resourceAsStream);
}
项目:incubator-netbeans    文件:WSDLInlineSchemaValidator.java   
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;                      
}